device_ds_stream.h

Go to the documentation of this file.
00001 #ifndef DEVICE_DS_STREAM_H
00002 #define DEVICE_DS_STREAM_H
00003 
00004 
00005 #include <windows.h>
00006 #include <mmsystem.h>
00007 #include <dsound.h>
00008 #include "audiere.h"
00009 #include "threads.h"
00010 #include "utility.h"
00011 
00012 
00013 namespace audiere {
00014 
00015   class DSAudioDevice;
00016 
00017   class DSOutputStream
00018     : public RefImplementation<OutputStream>
00019     , public Mutex
00020   {
00021   public:
00022     DSOutputStream(
00023       DSAudioDevice* device,
00024       IDirectSoundBuffer* buffer,
00025       int buffer_length, // in frames
00026       SampleSource* source);
00027     ~DSOutputStream();
00028 
00029     void ADR_CALL play();
00030     void ADR_CALL stop();
00031     bool ADR_CALL isPlaying();
00032     void ADR_CALL reset();
00033 
00034     void ADR_CALL setRepeat(bool repeat);
00035     bool ADR_CALL getRepeat();
00036     void  ADR_CALL setVolume(float volume);
00037     float ADR_CALL getVolume();
00038     void  ADR_CALL setPan(float pan);
00039     float ADR_CALL getPan();
00040     void  ADR_CALL setPitchShift(float shift);
00041     float ADR_CALL getPitchShift();
00042 
00043     bool ADR_CALL isSeekable();
00044     int  ADR_CALL getLength();
00045     void ADR_CALL setPosition(int position);
00046     int  ADR_CALL getPosition();
00047 
00048   private:
00049     void doStop(bool internal);   
00050     void doReset();  
00051     void fillStream();
00052     void update();
00053     int streamRead(int samples_to_read, void* buffer);
00054     void fillSilence(int sample_count, void* buffer);
00055   
00056   private:
00057     RefPtr<DSAudioDevice> m_device;
00058 
00059     IDirectSoundBuffer* m_buffer;
00060     int m_buffer_length;  // in samples
00061     int m_next_read;  // offset (in frames) where we will read next
00062     int m_last_play;  // offset (in frames) where the play cursor was
00063     int m_base_frequency;  // in Hz
00064 
00065     bool m_is_playing;
00066 
00067     SampleSourcePtr m_source;
00068     int m_frame_size;  // convenience: bytes per sample * channel count
00069 
00070     int m_total_read;    // total number of frames read from the stream
00071     int m_total_played;  // total number of frames played 
00072 
00073     float m_volume;
00074     float m_pan;
00075     ::BYTE* m_last_frame; // the last frame read (used for clickless silence)
00076 
00077     friend class DSAudioDevice;
00078   };
00079 
00080 }
00081 
00082 
00083 #endif

Generated on Mon Feb 13 23:07:46 2006 for audiere by  doxygen 1.4.6