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

mixer.hpp

Go to the documentation of this file.
00001 #ifndef MIXER_HPP
00002 #define MIXER_HPP
00003 
00004 
00005 #include <map>
00006 #include "config.h"
00007 #include "input.hpp"
00008 
00009 
00010 // always produce 44.1 KHz, 16-bit, stereo audio
00011 class Mixer : public ISampleSource
00012 {
00013 public:
00014   Mixer();
00015   ~Mixer();
00016 
00017   void GetFormat(int& channel_count, int& sample_rate, int& bits_per_sample);
00018   int Read(int sample_count, void* samples);
00019   bool Reset();
00020 
00021   void AddSource(ISampleSource* source);
00022   void RemoveSource(ISampleSource* source);
00023 
00024   bool IsPlaying(ISampleSource* source);
00025   void SetPlaying(ISampleSource* source, bool is_playing);
00026 
00027   int GetVolume(ISampleSource* source);
00028   void SetVolume(ISampleSource* source, int volume);
00029 
00030 private:
00031   struct SourceAttributes {
00032     // immutable
00033     ISampleSource* resampler;
00034     adr_s16 last_l;  // left
00035     adr_s16 last_r;  // right
00036 
00037     // mutable (set by external calls)
00038     bool is_playing;
00039     int volume;
00040   };
00041 
00042   typedef std::map<ISampleSource*, SourceAttributes> SourceMap;
00043 
00044 private:
00045   void Read(ISampleSource* source,
00046             SourceAttributes& attr,
00047             int to_mix,
00048             adr_s16* buffer);
00049 
00050 private:
00051   SourceMap m_sources;
00052 };
00053 
00054 
00055 #endif

Generated at Mon Jun 10 02:55:12 2002 for audiere by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001