00001 /* 00002 $Id: soundbuffer.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 00018 #define header_soundbuffer 00019 00020 #include "soundbuffer_session.h" 00021 #include "../Core/Resources/resource_manager.h" 00022 00023 class CL_StaticSoundProvider; 00024 class CL_StreamSoundProvider; 00025 class CL_SoundCard; 00026 00027 class CL_SoundBuffer 00028 //: Sample interface in ClanLib. 00029 // The CL_SoundBuffer class represents a sample in ClanLib. It can either be 00030 // static or streamed. The soundbuffer gets its sample data from a 00031 // soundprovider, that is passed during construction. 00032 // <br> 00033 // A static sample are normally sound effects and other sounds, that do not 00034 // change. ClanLib will always load the entire sample into memory, and 00035 // possibly upload it to the soundcard. 00036 // <br> 00037 // Streamed samples are either large sample that should be loaded a bit at a 00038 // time (music for instance), or sounds that change from playback to 00039 // playback (a microphone, speech over the net, etc). 00043 { 00044 public: 00045 virtual ~CL_SoundBuffer(); 00046 00047 static CL_SoundBuffer *load( 00048 const char *res_id, 00049 CL_ResourceManager *manager); 00050 00051 static CL_SoundBuffer *create( 00052 CL_StaticSoundProvider *provider, 00053 bool delete_provider=false); 00054 //: Creates a static soundbuffer. If 'delete_provider' is true, the provider 00055 //: will be deleted when the soundbuffer is deleted. 00057 00058 static CL_SoundBuffer *create( 00059 CL_StreamSoundProvider *provider, 00060 bool delete_provider=false); 00061 //: Creates a streamed soundbuffer. If 'delete_provider' is true, the provider 00062 //: will be delete when the soundbuffer is deleted. 00064 00065 CL_SoundBuffer( 00066 const char *res_id, 00067 CL_ResourceManager *manager); 00068 //: Loads a soundbuffer (sample) from a resource. 00069 00070 CL_SoundBuffer( 00071 CL_StaticSoundProvider *provider, 00072 bool delete_provider=false, 00073 class CL_Resource *resource = NULL); 00074 //: Creates a static soundbuffer. If 'delete_provider' is true, the provider 00075 //: will be deleted when the soundbuffer is deleted. 00076 00077 CL_SoundBuffer( 00078 CL_StreamSoundProvider *provider, 00079 bool delete_provider=false, 00080 class CL_Resource *resource = NULL); 00081 //: Creates a streamed soundbuffer. If 'delete_provider' is true, the provider 00082 //: will be delete when the soundbuffer is deleted. 00083 00084 CL_SoundBuffer(const CL_SoundBuffer ©); 00085 //: Create a copy of this soundbuffer. The copy will share the buffer with the 00086 //: original. 00087 00088 CL_StaticSoundProvider *get_static_provider() const; 00089 //: Returns the static soundprovider attached or NULL if it is a streamed 00090 //: sound buffer. 00092 00093 CL_StreamSoundProvider *get_stream_provider() const; 00094 //: Return the streamed soundprovider attached or NULL if it is a static 00095 //: sound buffer. 00097 00098 int get_length() const; 00099 //: Returns the length of the soundbuffer. 00100 //: That is num_samples * bytes_per_sample. 00102 00103 int get_num_samples() const; 00104 //: Returns the number of samples in the soundbuffer. 00106 00107 int get_frequency() const; 00108 //: Returns the start frequency used when the buffer is played. 00110 00111 bool set_frequency(int new_freq); 00112 //: Sets the start frequency used when the buffer is played. 00115 00116 float get_volume() const; 00117 //: Returns the start/default volume used when the buffer is played. 00119 00120 bool set_volume(float new_volume); 00121 //: Sets the default volume used when the buffer is played. 00124 00125 float get_pan() const; 00126 //: Returns the default panning position when the buffer is played. 00128 00129 bool set_pan(float new_pan); 00130 //: Sets the default panning position when the buffer is played. 00133 00134 bool is_playing(CL_SoundBuffer_Session **session=NULL, CL_SoundCard *card=NULL) const; 00135 //: Returns true if an instance of this soundbuffer is playing 00138 00139 void stop(CL_SoundCard *card=NULL); 00140 //: Stops any sessions playing this soundbuffer 00141 00142 CL_SoundBuffer_Session play(bool looping=false, CL_SoundCard *card=NULL); 00143 //: Plays the soundbuffer on the specified soundcard 00144 //: and using the specified playback description. 00148 00149 CL_SoundBuffer_Session prepare(bool looping=false, CL_SoundCard *card=NULL); 00150 //: Prepares the soundbuffer for playback on the specified soundcard. 00154 00156 public: 00157 class CL_SoundBuffer_Generic *impl; 00158 }; 00159 00160 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001