Mercurial > hg > svcore
comparison data/fileio/CodedAudioFileReader.h @ 1069:32ab6c48efaa
Merge from branch tonioni
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 09:11:34 +0100 |
parents | 843f67be0ed9 |
children | 4d9816ba0ebe |
comparison
equal
deleted
inserted
replaced
1036:682d64f05e72 | 1069:32ab6c48efaa |
---|---|
36 enum CacheMode { | 36 enum CacheMode { |
37 CacheInTemporaryFile, | 37 CacheInTemporaryFile, |
38 CacheInMemory | 38 CacheInMemory |
39 }; | 39 }; |
40 | 40 |
41 virtual void getInterleavedFrames(int start, int count, | 41 virtual SampleBlock getInterleavedFrames(sv_frame_t start, sv_frame_t count) const; |
42 SampleBlock &frames) const; | |
43 | 42 |
44 virtual int getNativeRate() const { return m_fileRate; } | 43 virtual sv_samplerate_t getNativeRate() const { return m_fileRate; } |
45 | 44 |
46 virtual QString getLocalFilename() const { return m_cacheFileName; } | 45 virtual QString getLocalFilename() const { return m_cacheFileName; } |
47 | 46 |
48 /// Intermediate cache means all CodedAudioFileReaders are quickly seekable | 47 /// Intermediate cache means all CodedAudioFileReaders are quickly seekable |
49 virtual bool isQuicklySeekable() const { return true; } | 48 virtual bool isQuicklySeekable() const { return true; } |
51 signals: | 50 signals: |
52 void progress(int); | 51 void progress(int); |
53 | 52 |
54 protected: | 53 protected: |
55 CodedAudioFileReader(CacheMode cacheMode, | 54 CodedAudioFileReader(CacheMode cacheMode, |
56 int targetRate, | 55 sv_samplerate_t targetRate, |
57 bool normalised); | 56 bool normalised); |
58 | 57 |
59 void initialiseDecodeCache(); // samplerate, channels must have been set | 58 void initialiseDecodeCache(); // samplerate, channels must have been set |
60 | 59 |
61 // may throw InsufficientDiscSpace: | 60 // may throw InsufficientDiscSpace: |
62 void addSamplesToDecodeCache(float **samples, int nframes); | 61 void addSamplesToDecodeCache(float **samples, sv_frame_t nframes); |
63 void addSamplesToDecodeCache(float *samplesInterleaved, int nframes); | 62 void addSamplesToDecodeCache(float *samplesInterleaved, sv_frame_t nframes); |
64 void addSamplesToDecodeCache(const SampleBlock &interleaved); | 63 void addSamplesToDecodeCache(const SampleBlock &interleaved); |
65 | 64 |
66 // may throw InsufficientDiscSpace: | 65 // may throw InsufficientDiscSpace: |
67 void finishDecodeCache(); | 66 void finishDecodeCache(); |
68 | 67 |
70 | 69 |
71 void startSerialised(QString id); | 70 void startSerialised(QString id); |
72 void endSerialised(); | 71 void endSerialised(); |
73 | 72 |
74 private: | 73 private: |
75 void pushBuffer(float *interleaved, int sz, bool final); | 74 void pushBuffer(float *interleaved, sv_frame_t sz, bool final); |
76 void pushBufferResampling(float *interleaved, int sz, float ratio, bool final); | 75 void pushBufferResampling(float *interleaved, sv_frame_t sz, double ratio, bool final); |
77 void pushBufferNonResampling(float *interleaved, int sz); | 76 void pushBufferNonResampling(float *interleaved, sv_frame_t sz); |
78 | 77 |
79 protected: | 78 protected: |
80 QMutex m_cacheMutex; | 79 QMutex m_cacheMutex; |
81 CacheMode m_cacheMode; | 80 CacheMode m_cacheMode; |
82 SampleBlock m_data; | 81 SampleBlock m_data; |
83 mutable QReadWriteLock m_dataLock; | 82 mutable QReadWriteLock m_dataLock; |
84 bool m_initialised; | 83 bool m_initialised; |
85 Serialiser *m_serialiser; | 84 Serialiser *m_serialiser; |
86 int m_fileRate; | 85 sv_samplerate_t m_fileRate; |
87 | 86 |
88 QString m_cacheFileName; | 87 QString m_cacheFileName; |
89 SNDFILE *m_cacheFileWritePtr; | 88 SNDFILE *m_cacheFileWritePtr; |
90 WavFileReader *m_cacheFileReader; | 89 WavFileReader *m_cacheFileReader; |
91 float *m_cacheWriteBuffer; | 90 float *m_cacheWriteBuffer; |
92 int m_cacheWriteBufferIndex; | 91 sv_frame_t m_cacheWriteBufferIndex; |
93 int m_cacheWriteBufferSize; // frames | 92 sv_frame_t m_cacheWriteBufferSize; // frames |
94 | 93 |
95 Resampler *m_resampler; | 94 Resampler *m_resampler; |
96 float *m_resampleBuffer; | 95 float *m_resampleBuffer; |
97 int m_fileFrameCount; | 96 sv_frame_t m_fileFrameCount; |
98 | 97 |
99 bool m_normalised; | 98 bool m_normalised; |
100 float m_max; | 99 float m_max; |
101 float m_gain; | 100 float m_gain; |
102 }; | 101 }; |