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

device_mixer.h

Go to the documentation of this file.
00001 #ifndef MIXER_H
00002 #define MIXER_H
00003 
00004 
00005 #ifdef _MSC_VER
00006 #pragma warning(disable : 4786)
00007 #endif
00008 
00009 
00010 #include <list>
00011 #include "audiere.h"
00012 #include "repeatable.h"
00013 #include "resampler.h"
00014 #include "threads.h"
00015 #include "types.h"
00016 #include "utility.h"
00017 
00018 
00019 namespace audiere {
00020 
00021   class MixerStream;
00022 
00023 
00025   class MixerDevice
00026     : public RefImplementation<AudioDevice>
00027     , public Synchronized
00028   {
00029   public:
00030     MixerDevice(int rate);
00031 
00032     // update() must be implementated by the specific device to call read()
00033     // and write the samples to the output device.
00034 
00035     OutputStream* ADR_CALL openStream(SampleSource* source);
00036 
00037     OutputStream* ADR_CALL openBuffer(
00038       void* samples,
00039       int frame_count,
00040       int channel_count,
00041       int sample_rate,
00042       SampleFormat sample_format);
00043 
00044   protected:
00045     int read(int sample_count, void* samples);
00046 
00047   private:
00048     std::list<MixerStream*> m_streams;
00049     int m_rate;
00050 
00051     friend class MixerStream;
00052   };
00053 
00054 
00055   class MixerStream : public RefImplementation<OutputStream> {
00056   public:
00057     MixerStream(MixerDevice* device, SampleSource* source, int rate);
00058     ~MixerStream();
00059 
00060     void  ADR_CALL play();
00061     void  ADR_CALL stop();
00062     bool  ADR_CALL isPlaying();
00063     void  ADR_CALL reset();
00064 
00065     void  ADR_CALL setRepeat(bool repeat);
00066     bool  ADR_CALL getRepeat();
00067     void  ADR_CALL setVolume(float volume);
00068     float ADR_CALL getVolume();
00069     void  ADR_CALL setPan(float pan);
00070     float ADR_CALL getPan();
00071     void  ADR_CALL setPitchShift(float shift);
00072     float ADR_CALL getPitchShift();
00073 
00074     bool ADR_CALL isSeekable();
00075     int  ADR_CALL getLength();
00076     void ADR_CALL setPosition(int position);
00077     int  ADR_CALL getPosition();
00078 
00079   private:
00080     void read(int frame_count, s16* buffer);
00081 
00082   private:
00083     RefPtr<MixerDevice> m_device;
00084 
00085     RefPtr<Resampler> m_resampler;
00086     RefPtr<RepeatableStream> m_source;
00087     s16 m_last_l;
00088     s16 m_last_r;
00089     bool m_is_playing;
00090     int m_volume;
00091     int m_pan;
00092 
00093     friend class MixerDevice;
00094   };
00095 
00096 }
00097 
00098 #endif

Generated on Sat Oct 12 01:43:02 2002 for audiere by doxygen1.2.17