00001 /* 00002 $Id: soundbuffer_session.h,v 1.1 2001/03/06 15:09:12 mbn Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00016 00017 #ifndef header_soundbuffer_session 00018 #define header_soundbuffer_session 00019 00020 #include <stdlib.h> 00021 00022 class CL_SoundCard; 00023 class CL_SoundPlayBackDesc; 00024 class CL_SoundBuffer_Session 00025 //: CL_SoundBuffer_Session provides control over a playing soundeffect. 00026 // Whenever a soundbuffer is played, it returns a CL_SoundBuffer_Session 00027 // class, which can be used to control the sound (its volume, pitch, 00028 // pan, position). It can of course also be used to retrigger the sound 00029 // or to stop it. The soundeffect is stored in the layer1 soundmanager 00030 // until all references to the sound played are removed, meaning that 00031 // the soundeffect (session) will be ready to play and remember its 00032 // state and settings (volume, frequency...) until no CL_SoundBuffer_Session 00033 // refers to it, via a soundbuffer session reference system. 00034 { 00035 public: 00036 CL_SoundBuffer_Session() { handle = NULL; card = NULL; } 00037 //: Creates a soundbuffer session not attached to any object. 00038 00039 CL_SoundBuffer_Session(void *handle, CL_SoundCard *_card); 00040 00041 CL_SoundBuffer_Session(const CL_SoundBuffer_Session ©); 00042 //: Copy constructor. 00043 00044 ~CL_SoundBuffer_Session(); 00045 00046 CL_SoundBuffer_Session& operator=(const CL_SoundBuffer_Session &session); 00047 00048 void *get_handle() const { return handle; } 00049 00050 CL_SoundCard *get_card() const { return card; } 00051 //: Returns a pointer to the card on which the soundbuffer controlled 00052 //: is played/playing. 00054 00055 int get_position() const; 00056 //: Returns the current position of the soundeffect 00058 00059 float get_position_relative() const; 00060 //: Returns the soundeffects relative position, compared 00061 //: to the total length of the soundeffect. 00062 //: The value returned will be between 0->1, where 0 00063 //: means the soundeffect is at the beginning, and 1 00064 //: means that the soundeffect has reached the end. 00066 00067 bool set_position(int new_pos); 00068 //: Sets the soundeffects position to 'new_pos'. 00071 00072 bool set_position_relative(float new_pos); 00073 //: Sets the relative position of the soundeffect. 00074 //: Value must be between 0->1, where 0 sets the 00075 //: soundeffect to the beginning, and 1 sets it 00076 //: to the end of the soundbuffer. 00079 00080 int get_length() const; 00081 //: Returns the total length of the soundeffect played. 00082 //: Value returned will be -1 if the length is unknown (in 00083 //: case of non-static soundeffects like streamed sound) 00085 00086 int get_frequency() const; 00087 //: Returns the frequency of the soundeffect played. 00089 00090 bool set_frequency(int new_freq); 00091 //: Sets the frequency of the soundeffect played. 00094 00095 float get_volume() const; 00096 //: Returns the linear relative volume of the soundeffect. 00097 //: 0 means the soundeffect is muted, 1 means the soundeffect 00098 //: is playing at "max" volume. 00100 00101 bool set_volume(float new_volume); 00102 //: Sets the volume of the soundeffect in a relative measure (0->1) 00103 //: A value of 0 will effectively mute the sound (although it will 00104 //: still be sampled), and a value of 1 will set the volume to "max". 00107 00108 float get_pan() const; 00109 //: Returns the current pan (in a measure from -1 -> 1), where 00110 //: -1 means the soundeffect is only playing in the left speaker, 00111 //: and 1 means the soundeffect is only playing in the right speaker. 00113 00114 bool set_pan(float new_pan); 00115 //: Sets the panning of the soundeffect played in measures from -1 -> 1 00116 //: Setting the pan with a value of -1 will pan the soundeffect to the 00117 //: extreme left (left speaker only), 1 will pan the soundeffect to the 00118 //: extreme right (right speaker only). 00121 00122 void play(); 00123 //: Starts playback of the session. 00124 00125 void stop(); 00126 //: Stops playback of the session. 00127 00128 bool is_playing(); 00129 //: Returns true if the session is playing 00130 00131 void set_looping(bool loop); 00132 //: Determines whether this session should loop 00134 00135 void add_filter(class CL_SoundFilter *filter, bool delete_filter = false); 00136 //: Adds the sound filter to the session. See CL_SoundFilter for details. 00139 00140 void remove_filter(class CL_SoundFilter *filter); 00141 //: Remove the sound filter from the session. See CL_SoundFilter for details. 00142 00143 private: 00144 void *handle; 00145 CL_SoundCard *card; 00146 }; 00147 00148 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001