00001 #ifndef RESAMPLER_H 00002 #define RESAMPLER_H 00003 00004 00005 #include "audiere.h" 00006 #include "types.h" 00007 #include "utility.h" 00008 00009 00010 namespace audiere { 00011 00012 class Resampler : public RefImplementation<SampleSource> { 00013 public: 00014 Resampler(SampleSource* source, int rate); 00015 00016 // for now, resamplers always return (2, rate, 16-bit) 00017 void ADR_CALL getFormat( 00018 int& channel_count, 00019 int& sample_rate, 00020 SampleFormat& sample_format); 00021 00022 int ADR_CALL read(int frame_count, void* buffer); 00023 void ADR_CALL reset(); 00024 00025 bool ADR_CALL isSeekable(); 00026 int ADR_CALL getLength(); 00027 void ADR_CALL setPosition(int position); 00028 int ADR_CALL getPosition(); 00029 00030 void setPitchShift(float shift); 00031 float getPitchShift(); 00032 00033 private: 00034 void fillBuffer(); 00035 void resetState(); 00036 00037 private: 00038 RefPtr<SampleSource> m_source; 00039 int m_rate; 00040 int m_native_channel_count; 00041 int m_native_sample_rate; 00042 SampleFormat m_native_sample_format; 00043 00044 enum { NATIVE_BUFFER_SIZE = 4096 }; 00045 s16 m_native_buffer[NATIVE_BUFFER_SIZE * 2]; 00046 s16* m_position; 00047 unsigned m_samples_left; // number of samples left to consume 00048 00049 float m_shift; 00050 00051 unsigned m_time; 00052 s16 m_sl; // left channel 00053 s16 m_sr; // right channel 00054 }; 00055 00056 } 00057 00058 #endif
1.2.17