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