Mercurial > hg > svcore
comparison data/fileio/AudioFileReaderFactory.cpp @ 920:f3cda3280398 tonioni
Add normalised option to CodedAudioFileReader
author | Chris Cannam |
---|---|
date | Fri, 13 Jun 2014 16:03:48 +0100 |
parents | f5cd33909744 |
children | d03b3d956358 |
comparison
equal
deleted
inserted
replaced
919:4c7b4040bd2d | 920:f3cda3280398 |
---|---|
56 | 56 |
57 return rv; | 57 return rv; |
58 } | 58 } |
59 | 59 |
60 AudioFileReader * | 60 AudioFileReader * |
61 AudioFileReaderFactory::createReader(FileSource source, size_t targetRate, | 61 AudioFileReaderFactory::createReader(FileSource source, |
62 size_t targetRate, | |
63 bool normalised, | |
62 ProgressReporter *reporter) | 64 ProgressReporter *reporter) |
63 { | 65 { |
64 return create(source, targetRate, false, reporter); | 66 return create(source, targetRate, normalised, false, reporter); |
65 } | 67 } |
66 | 68 |
67 AudioFileReader * | 69 AudioFileReader * |
68 AudioFileReaderFactory::createThreadingReader(FileSource source, size_t targetRate, | 70 AudioFileReaderFactory::createThreadingReader(FileSource source, |
71 size_t targetRate, | |
72 bool normalised, | |
69 ProgressReporter *reporter) | 73 ProgressReporter *reporter) |
70 { | 74 { |
71 return create(source, targetRate, true, reporter); | 75 return create(source, targetRate, normalised, true, reporter); |
72 } | 76 } |
73 | 77 |
74 AudioFileReader * | 78 AudioFileReader * |
75 AudioFileReaderFactory::create(FileSource source, size_t targetRate, bool threading, | 79 AudioFileReaderFactory::create(FileSource source, |
80 size_t targetRate, | |
81 bool normalised, | |
82 bool threading, | |
76 ProgressReporter *reporter) | 83 ProgressReporter *reporter) |
77 { | 84 { |
78 QString err; | 85 QString err; |
79 | 86 |
80 SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << endl; | 87 SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << endl; |
100 | 107 |
101 int fileRate = reader->getSampleRate(); | 108 int fileRate = reader->getSampleRate(); |
102 | 109 |
103 if (reader->isOK() && | 110 if (reader->isOK() && |
104 (!reader->isQuicklySeekable() || | 111 (!reader->isQuicklySeekable() || |
112 normalised || | |
105 (targetRate != 0 && fileRate != targetRate))) { | 113 (targetRate != 0 && fileRate != targetRate))) { |
106 | 114 |
107 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; | 115 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; |
108 | 116 |
109 delete reader; | 117 delete reader; |
110 reader = new DecodingWavFileReader | 118 reader = new DecodingWavFileReader |
111 (source, | 119 (source, |
112 threading ? | 120 threading ? |
113 DecodingWavFileReader::ResampleThreaded : | 121 DecodingWavFileReader::ResampleThreaded : |
114 DecodingWavFileReader::ResampleAtOnce, | 122 DecodingWavFileReader::ResampleAtOnce, |
115 DecodingWavFileReader::CacheInTemporaryFile, | 123 DecodingWavFileReader::CacheInTemporaryFile, |
116 targetRate ? targetRate : fileRate, | 124 targetRate ? targetRate : fileRate, |
125 normalised, | |
117 reporter); | 126 reporter); |
118 if (!reader->isOK()) { | 127 if (!reader->isOK()) { |
119 delete reader; | 128 delete reader; |
120 reader = 0; | 129 reader = 0; |
121 } | 130 } |
131 threading ? | 140 threading ? |
132 OggVorbisFileReader::DecodeThreaded : | 141 OggVorbisFileReader::DecodeThreaded : |
133 OggVorbisFileReader::DecodeAtOnce, | 142 OggVorbisFileReader::DecodeAtOnce, |
134 OggVorbisFileReader::CacheInTemporaryFile, | 143 OggVorbisFileReader::CacheInTemporaryFile, |
135 targetRate, | 144 targetRate, |
145 normalised, | |
136 reporter); | 146 reporter); |
137 if (!reader->isOK()) { | 147 if (!reader->isOK()) { |
138 delete reader; | 148 delete reader; |
139 reader = 0; | 149 reader = 0; |
140 } | 150 } |
151 threading ? | 161 threading ? |
152 MP3FileReader::DecodeThreaded : | 162 MP3FileReader::DecodeThreaded : |
153 MP3FileReader::DecodeAtOnce, | 163 MP3FileReader::DecodeAtOnce, |
154 MP3FileReader::CacheInTemporaryFile, | 164 MP3FileReader::CacheInTemporaryFile, |
155 targetRate, | 165 targetRate, |
166 normalised, | |
156 reporter); | 167 reporter); |
157 if (!reader->isOK()) { | 168 if (!reader->isOK()) { |
158 delete reader; | 169 delete reader; |
159 reader = 0; | 170 reader = 0; |
160 } | 171 } |
170 threading ? | 181 threading ? |
171 QuickTimeFileReader::DecodeThreaded : | 182 QuickTimeFileReader::DecodeThreaded : |
172 QuickTimeFileReader::DecodeAtOnce, | 183 QuickTimeFileReader::DecodeAtOnce, |
173 QuickTimeFileReader::CacheInTemporaryFile, | 184 QuickTimeFileReader::CacheInTemporaryFile, |
174 targetRate, | 185 targetRate, |
186 normalised, | |
175 reporter); | 187 reporter); |
176 if (!reader->isOK()) { | 188 if (!reader->isOK()) { |
177 delete reader; | 189 delete reader; |
178 reader = 0; | 190 reader = 0; |
179 } | 191 } |
189 threading ? | 201 threading ? |
190 CoreAudioFileReader::DecodeThreaded : | 202 CoreAudioFileReader::DecodeThreaded : |
191 CoreAudioFileReader::DecodeAtOnce, | 203 CoreAudioFileReader::DecodeAtOnce, |
192 CoreAudioFileReader::CacheInTemporaryFile, | 204 CoreAudioFileReader::CacheInTemporaryFile, |
193 targetRate, | 205 targetRate, |
206 normalised, | |
194 reporter); | 207 reporter); |
195 if (!reader->isOK()) { | 208 if (!reader->isOK()) { |
196 delete reader; | 209 delete reader; |
197 reader = 0; | 210 reader = 0; |
198 } | 211 } |
213 | 226 |
214 int fileRate = reader->getSampleRate(); | 227 int fileRate = reader->getSampleRate(); |
215 | 228 |
216 if (reader->isOK() && | 229 if (reader->isOK() && |
217 (!reader->isQuicklySeekable() || | 230 (!reader->isQuicklySeekable() || |
231 normalised || | |
218 (targetRate != 0 && fileRate != targetRate))) { | 232 (targetRate != 0 && fileRate != targetRate))) { |
219 | 233 |
220 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; | 234 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; |
221 | 235 |
222 delete reader; | 236 delete reader; |
223 reader = new DecodingWavFileReader | 237 reader = new DecodingWavFileReader |
224 (source, | 238 (source, |
225 threading ? | 239 threading ? |
226 DecodingWavFileReader::ResampleThreaded : | 240 DecodingWavFileReader::ResampleThreaded : |
227 DecodingWavFileReader::ResampleAtOnce, | 241 DecodingWavFileReader::ResampleAtOnce, |
228 DecodingWavFileReader::CacheInTemporaryFile, | 242 DecodingWavFileReader::CacheInTemporaryFile, |
229 targetRate ? targetRate : fileRate, | 243 targetRate ? targetRate : fileRate, |
244 normalised, | |
230 reporter); | 245 reporter); |
231 } | 246 } |
232 | 247 |
233 if (!reader->isOK()) { | 248 if (!reader->isOK()) { |
234 delete reader; | 249 delete reader; |