AudioMixer.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2005 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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

Generated on Fri Jul 27 22:27:09 2007 for pentagram by  doxygen 1.4.7