00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef AUDIOMIXER_H_INCLUDED
00019 #define AUDIOMIXER_H_INCLUDED
00020
00021 class MidiDriver;
00022
00023 namespace Pentagram {
00024 class AudioChannel;
00025 class AudioSample;
00026
00027 class AudioMixer
00028 {
00029 public:
00030 AudioMixer(int sample_rate, bool stereo, int num_channels);
00031 ~AudioMixer(void);
00032
00033 MidiDriver* getMidiDriver() const { return midi_driver; }
00034
00035 static AudioMixer* get_instance() { return the_audio_mixer; }
00036
00037 void reset();
00038 void createProcesses();
00039
00040 int playSample(AudioSample *sample, int loop, int priority, bool paused, uint32 pitch_shift, int lvol, int rvol);
00041 bool isPlaying(int chan);
00042 void stopSample(int chan);
00043
00044 void setPaused(int chan, bool paused);
00045 bool isPaused(int chan);
00046
00047 void setVolume(int chan, int lvol, int rvol);
00048 void getVolume(int chan, int &lvol, int &rvol);
00049
00050 void openMidiOutput();
00051 void closeMidiOutput();
00052
00053 private:
00054 bool audio_ok;
00055 uint32 sample_rate;
00056 bool stereo;
00057 MidiDriver * midi_driver;
00058 int midi_volume;
00059
00060 int num_channels;
00061 AudioChannel **channels;
00062
00063 void init_midi();
00064 static void sdlAudioCallback(void *userdata, uint8 *stream, int len);
00065
00066 void MixAudio(sint16 *stream, uint32 bytes);
00067
00068 static AudioMixer* the_audio_mixer;
00069
00070 void Lock();
00071 void Unlock();
00072 };
00073
00074 };
00075
00076 #endif //AUDIOMIXER_H_INCLUDED