From 0c39051ba80f04b1177833a006f2d442a7170b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 3 Dec 2020 17:11:43 +0100 Subject: add initial files l8 --- labb8/lib/StanfordCPPLib/sound.h | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 labb8/lib/StanfordCPPLib/sound.h (limited to 'labb8/lib/StanfordCPPLib/sound.h') diff --git a/labb8/lib/StanfordCPPLib/sound.h b/labb8/lib/StanfordCPPLib/sound.h new file mode 100755 index 0000000..89e2066 --- /dev/null +++ b/labb8/lib/StanfordCPPLib/sound.h @@ -0,0 +1,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 sounds. + * + *

The following code, for example, plays the sound file + * ringtone.wav: + * + *

+ *    Sound ringtone("ringtone.wav");
+ *    ringtone.play();
+ *
+ */ + +class Sound { + +public: + +/* + * Constructor: Sound + * Usage: Sound sound; + * Sound sound(filename); + * ----------------------------- + * Creates a Sound 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 -- cgit v1.2.1