comparison data/fileio/CodedAudioFileReader.h @ 297:c022976d18e8

* Merge from sv-match-alignment branch (excluding alignment-specific document). - add aggregate wave model (not yet complete enough to be added as a true model in a layer, but there's potential) - add play solo mode - add alignment model -- unused in plain SV - fix two plugin leaks - add m3u playlist support (opens all files at once, potentially hazardous) - fix retrieval of pre-encoded URLs - add ability to resample audio files on import, so as to match rates with other files previously loaded; add preference for same - add preliminary support in transform code for range and rate of transform input - reorganise preferences dialog, move dark-background option to preferences, add option for temporary directory location
author Chris Cannam
date Fri, 28 Sep 2007 13:56:38 +0000
parents 92e8dbde73cd
children b92513201610
comparison
equal deleted inserted replaced
296:2b6c99b607f1 297:c022976d18e8
20 20
21 #include <sndfile.h> 21 #include <sndfile.h>
22 #include <QMutex> 22 #include <QMutex>
23 23
24 class WavFileReader; 24 class WavFileReader;
25 class Serialiser;
26 class Resampler;
25 27
26 class CodedAudioFileReader : public AudioFileReader 28 class CodedAudioFileReader : public AudioFileReader
27 { 29 {
28 public: 30 public:
29 virtual ~CodedAudioFileReader(); 31 virtual ~CodedAudioFileReader();
34 }; 36 };
35 37
36 virtual void getInterleavedFrames(size_t start, size_t count, 38 virtual void getInterleavedFrames(size_t start, size_t count,
37 SampleBlock &frames) const; 39 SampleBlock &frames) const;
38 40
41 virtual size_t getNativeRate() const { return m_fileRate; }
42
39 protected: 43 protected:
40 CodedAudioFileReader(CacheMode cacheMode); 44 CodedAudioFileReader(CacheMode cacheMode, size_t targetRate);
41 45
42 void initialiseDecodeCache(); // samplerate, channels must have been set 46 void initialiseDecodeCache(); // samplerate, channels must have been set
43 void addSampleToDecodeCache(float sample); 47 void addSamplesToDecodeCache(float **samples, size_t nframes);
48 void addSamplesToDecodeCache(float *samplesInterleaved, size_t nframes);
49 void addSamplesToDecodeCache(const SampleBlock &interleaved);
44 void finishDecodeCache(); 50 void finishDecodeCache();
45 bool isDecodeCacheInitialised() const { return m_initialised; } 51 bool isDecodeCacheInitialised() const { return m_initialised; }
46 52
53 void startSerialised(QString id);
54 void endSerialised();
55
56 private:
57 void pushBuffer(float *interleaved, size_t sz, bool final);
58
59 protected:
47 QMutex m_cacheMutex; 60 QMutex m_cacheMutex;
48 CacheMode m_cacheMode; 61 CacheMode m_cacheMode;
49 SampleBlock m_data; 62 SampleBlock m_data;
50 bool m_initialised; 63 bool m_initialised;
64 Serialiser *m_serialiser;
65 size_t m_fileRate;
51 66
52 QString m_cacheFileName; 67 QString m_cacheFileName;
53 SNDFILE *m_cacheFileWritePtr; 68 SNDFILE *m_cacheFileWritePtr;
54 WavFileReader *m_cacheFileReader; 69 WavFileReader *m_cacheFileReader;
55 float *m_cacheWriteBuffer; 70 float *m_cacheWriteBuffer;
56 size_t m_cacheWriteBufferIndex; 71 size_t m_cacheWriteBufferIndex;
57 size_t m_cacheWriteBufferSize; // frames 72 size_t m_cacheWriteBufferSize; // frames
73
74 Resampler *m_resampler;
75 float *m_resampleBuffer;
58 }; 76 };
59 77
60 #endif 78 #endif