00001 #ifndef _AUDIO_SDL_H
00002 #define _AUDIO_SDL_H
00003
00004 extern "C" {
00005 #include <SDL_audio.h>
00006 };
00007 #include "proAudio.h"
00008 #include <map>
00009
00016
00017
00019 class _AudioTrack;
00020
00022 class DeviceAudioSdl : public DeviceAudio {
00023 public:
00025
00032 static DeviceAudio* create(unsigned int nTracks=8, unsigned int frequency=22050, unsigned int chunkSize=1024);
00033
00035 virtual unsigned int sampleFromMemory(const AudioSample & sample, float volume=1.0f);
00037 virtual bool sampleDestroy(unsigned int sample);
00038
00040
00046 virtual unsigned int soundPlay(unsigned int sample, float volumeL=1.0f, float volumeR=1.0f, float disparity=0.0f, float pitch=1.0f );
00054 virtual unsigned int soundLoop(unsigned int sample, float volumeL=1.0f, float volumeR=1.0f, float disparity=0.0f, float pitch=1.0f );
00056
00062 virtual bool soundUpdate(unsigned int sound, float volumeL, float volumeR, float disparity=0.0f, float pitch=1.0f );
00064 virtual bool soundStop(unsigned int sound);
00066 virtual void soundStop();
00068 virtual unsigned int soundActive() const;
00069 protected:
00071 DeviceAudioSdl(unsigned int nTracks, unsigned int frequency, unsigned int chunkSize);
00073 virtual ~DeviceAudioSdl();
00075 SDL_AudioSpec m_spec;
00077 std::map<unsigned int, _AudioTrack> mm_sample;
00079 unsigned int m_sampleCounter;
00081 bool m_isDesiredFormat;
00082
00084 _AudioTrack * ma_sound;
00086 unsigned int m_nSound;
00087
00089 static void cbOutput(void *userData, Uint8 *stream, int len);
00091 void mixOutputFloat(signed short *outputBuffer, unsigned int nFrames);
00093 void mixOutputSInt(Uint8 *stream, int len);
00094 };
00095
00096 #endif // _AUDIO_SDL_H