include/df/sound.hpp

00001 //Sound class - WAVE input/output
00002 
00003 struct SoundData;
00004 
00005 class SoundCallback {
00006   public:
00007     virtual void SoundEvent(Sound *id);
00008 };
00009 
00010 //dir'ection types
00011 #define SND_OUTPUT 0  //dir
00012 #define SND_INPUT  1  //dir
00013 
00014 //Sound dev types (for Get()/Set()) volume levels
00015 #define SND_MASTER 0
00016 #define SND_MUSIC  3
00017 #define SND_WAVE   4
00018 #define SND_PC     5
00019 #define SND_LINE   6
00020 #define SND_MIC    7
00021 #define SND_CD     8
00022 
00023 struct SoundStatus {
00024   int bufs;      //# of buffers
00025   int bufsused;  //# of buffers in use
00026   int bufsfree;  //# of buffers free
00027   int bufsiz;    //Buffer size (bytes)
00028   //NOTE : bufsfree + bufsused == bufs
00029 };
00030 //if (bufsfree>0) then you can call Play() to add another buffer
00031 
00032 class Sound : virtual public SystemCode {
00033   _PROTECTED_:
00034     //common code/data
00035     Thread *This;  //to post messages
00036     SoundCallback *cb;
00037     SoundData *sd;
00038   public:
00039 #ifdef _DF_SOUND_SRC_
00040 #ifdef DF_WIN
00041  #include <df/win32/sound.hpp>
00042 #else
00043  #include <df/linux/sound.hpp>
00044 #endif
00045 #endif
00046     BOOL Valid;
00047     //CTOR
00048     Sound();
00049     //DTOR
00050     ~Sound();
00051     //Creation functions
00052     void SetCallback(SoundCallback *cb);
00053     BOOL Capable(int bits, int freq, int chs);  //check if hardware capable
00054     BOOL Create(uint _dir, int bits, int freq, int chs);   //create an Input/Output Stream
00055     //dir = direction (SND_OUTPUT | SND_INPUT)
00056     //bits = sample size (8 or 16)
00057     //freq = frequency (8k - 44.1k)
00058     //chs = # of channels (1=mono(dot) 2=stereo(line) 4=2D 8=3D)
00059     //bufs = # of sound buffers to use (SND_MIN_BUFFERS-SND_MAX_BUFFERS)
00060     //bufsiz = size of each buffer in bytes (must be multiple of chs)
00061     uint32 GetBufferSize();
00062     BOOL Destroy();  //destroy stream
00063     //Sound control functions
00064     BOOL Play(PTR *sams, int *buflen, BOOL playall = TRUE);  //gives next sound block
00065     BOOL Record(PTR *sams, int *buflen);  //returns next sound block
00066     BOOL Status(SoundStatus *ss);  //returns a filled out SoundStatus struct
00067     BOOL Stop();
00068     //WAV Files
00069     static PTR LoadWAV(char *fn, int *bufsiz, int *bits, int *freq, int *chs);
00070     BOOL CreateMixer();
00071     BOOL MixerSet(int dev, uint32 lvl);
00072     BOOL MixerGet(int dev, uint32 *lvl);
00073 };
00074 

Generated on Mon Mar 5 09:49:14 2007 for DigiForce by  doxygen 1.4.7