summaryrefslogtreecommitdiffstats
path: root/labb8/lib/StanfordCPPLib/sound.h
blob: 89e20663be705dd2bd5d32396229cdcb488c798d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * File: sound.h
 * -------------
 * This file defines a class that represents a sound.
 */

#ifndef _sound_h
#define _sound_h

/*
 * Class: Sound
 * ------------
 * This class encapsulates a sound file.  The sound file is specified in the
 * constructor and must be a file in either the current directory or a
 * subdirectory named <code>sounds</code>.
 *
 * <p>The following code, for example, plays the sound file
 * <code>ringtone.wav</code>:
 *
 *<pre>
 *    Sound ringtone("ringtone.wav");
 *    ringtone.play();
 *</pre>
 */

class Sound {

public:

/*
 * Constructor: Sound
 * Usage: Sound sound;
 *        Sound sound(filename);
 * -----------------------------
 * Creates a <code>Sound</code> object.  The default constructor
 * creates an empty sound that cannot be played.  The second form
 * initializes the sound by reading in the contents of the specified
 * file.
 */

   Sound(std::string filename);

/*
 * Destructor: ~Sound
 * ------------------
 * Frees the memory associated with the sound.
 */

   virtual ~Sound();

/*
 * Method: play
 * Usage: sound.play();
 * --------------------
 * Starts playing the sound.  This call returns immediately without waiting
 * for the sound to finish.
 */

   void play();

};

#endif