00001 /* 00002 $Id: stream_provider_wave.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 File purpose: 00015 Streamed sample header file 00016 */ 00017 00019 00020 #ifndef header_streamed_wave_sample 00021 #define header_streamed_wave_sample 00022 00023 #include <stdlib.h> 00024 #include "../stream_soundprovider.h" 00025 #include "../soundbuffer.h" 00026 00027 class CL_Streamed_WaveSample : public CL_StreamSoundProvider 00028 //: Streamed sample in wave (.wav) format. 00029 // This class providers playback support for wave (.wav) samples. 00030 // <br> 00031 // Unlike CL_Sample, this class doesn't load the entire PCM stream into 00032 // memory. Instead it slowly loads it from disk as the data is needed. With 00033 // very large samples, this is a very good idea. 00034 // <br> 00035 // If the sample is small and used a lot, you should consider using 00036 // CL_Sample instead. 00043 { 00044 protected: 00045 std::string filename; 00046 CL_InputSourceProvider *inputprovider; 00047 bool looped; 00048 00049 public: 00050 static CL_SoundBuffer *create(const char *filename, CL_InputSourceProvider *inputprovider = NULL, bool looped = false); 00051 // Creates a soundbuffer using this provider. 00057 00058 CL_Streamed_WaveSample(const char *filename, CL_InputSourceProvider *inputprovider = NULL, bool looped = false); 00059 // Constructs an instance of this class. 00065 00066 virtual ~CL_Streamed_WaveSample(); 00067 00068 virtual CL_StreamSoundProvider_Session *begin_session(); 00069 // Called by the sound implementation when a session is begun. 00070 00071 virtual void end_session(CL_StreamSoundProvider_Session *session); 00072 // Called by the sound implementation just before a playback session has 00073 // ended. 00074 }; 00075 00076 class CL_Streamed_WaveSample_Session : public CL_StreamSoundProvider_Session 00077 { 00078 protected: 00079 CL_InputSource *input; 00080 00081 struct WAVE_FORMAT 00082 { 00083 short formatTag; 00084 short nChannels; 00085 int nSamplesPerSec; 00086 int nAvgBytesPerSec; 00087 short nBlockAlign; 00088 }; 00089 00090 SoundFormat sample_format; 00091 int sample_size; 00092 int sample_freq; 00093 int sample_left; 00094 bool looped; 00095 00096 public: 00097 CL_Streamed_WaveSample_Session(CL_InputSource *input, bool looped); 00098 virtual ~CL_Streamed_WaveSample_Session(); 00099 00100 virtual void stop() {}; //FIXME 00101 virtual bool play() { return false; }; //FIXME 00102 virtual bool set_position(int pos) { pos=pos; return false; }; //FIXME 00103 00104 virtual bool eof() const; 00105 virtual int get_data(void *data_ptr, int data_requested); 00106 virtual int get_frequency() const; 00107 virtual SoundFormat get_format() const; 00108 }; 00109 00110 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001