Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

static_provider_wave.h

Go to the documentation of this file.
00001 /*
00002         $Id: static_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                 Simple sample support.
00016 
00017 */
00018 
00020 
00021 #ifndef header_sampleprovider
00022 #define header_sampleprovider
00023 
00024 #include "../static_soundprovider.h"
00025 #include "../soundbuffer.h"
00026 
00027 class CL_Sample : public CL_StaticSoundProvider
00028 //: ClanLib's datafile samples. This class can read samples from datafiles.
00029 {
00030 public:
00031         static CL_SoundBuffer *create(
00032                 const char *sample_id,
00033                 CL_InputSourceProvider *provider);
00034         //: Loads the sample 'sample_id' from the inputsource provider 'provider'. 
00035         //: Creates a CL_SoundBuffer using this sample and returns it.
00036 
00037         CL_Sample(
00038                 const char *s_id,
00039                 CL_InputSourceProvider *_provider);
00040         //: Constructs a static sound provider that represents 'sample_id' from the
00041         //: inputsource provider 'provider'.
00042 
00043         virtual ~CL_Sample();
00044 
00045         virtual void lock();
00046         //: Locks the sample data.
00047 
00048         virtual void unlock();
00049         //: Unlocks the sample data.
00050 
00051         virtual SoundFormat get_format() const;
00052         //: Returns the sample format used by this sample.
00053 
00054         virtual int data_size() const;
00055         //: Returns the size of the sample.
00056 
00057         virtual void *get_data() const;
00058         //: Returns the sample data. Must be locked before this is done.
00059 
00060         virtual int get_frequency() const;
00061         //: Returns the default frequency used when playing this sample.
00062 
00063 private:
00064         struct WAVE_FORMAT
00065         {
00066                 short formatTag;
00067                 short nChannels;
00068                 int nSamplesPerSec;
00069                 int nAvgBytesPerSec;
00070                 short nBlockAlign;
00071         };
00072 
00073         CL_InputSourceProvider *provider;
00074         std::string sample_id;
00075 
00076         char *sample_data;
00077         SoundFormat sample_format;
00078         int sample_size;
00079         int sample_freq;
00080 
00081         void load_data();
00082 };
00083 
00084 #endif

Generated at Wed Apr 4 19:54:03 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001