comparison data/fileio/AudioFileReaderFactory.cpp @ 308:14e0f60435b8

* Make it possible to drop audio files, layer files, session files and images onto SV panes. Need to do a bit more work on where we expect the dropped file to go, particularly in the case of audio files -- at the moment they're always opened in new panes, but it may be better to by default replace whatever is in the target pane.
author Chris Cannam
date Wed, 10 Oct 2007 15:18:02 +0000
parents c022976d18e8
children 3a6725f285d6
comparison
equal deleted inserted replaced
307:b1a3f7bc035d 308:14e0f60435b8
145 } 145 }
146 delete reader; 146 delete reader;
147 reader = 0; 147 reader = 0;
148 } 148 }
149 149
150 reader = new WavFileReader(path); 150 return reader;
151
152 if (targetRate != 0 &&
153 reader->isOK() &&
154 reader->getSampleRate() != targetRate) {
155
156 delete reader;
157 reader = new ResamplingWavFileReader
158 (path,
159 ResamplingWavFileReader::ResampleThreaded,
160 ResamplingWavFileReader::CacheInTemporaryFile,
161 targetRate);
162 }
163
164 if (reader->isOK()) return reader;
165
166 if (reader->getError() != "") {
167 std::cerr << "AudioFileReaderFactory: WAV file reader error: \""
168 << reader->getError().toStdString() << "\"" << std::endl;
169 } else {
170 std::cerr << "AudioFileReaderFactory: WAV file reader failed"
171 << std::endl;
172 }
173 delete reader;
174
175 #ifdef HAVE_OGGZ
176 #ifdef HAVE_FISHSOUND
177 reader = new OggVorbisFileReader
178 (path,
179 OggVorbisFileReader::DecodeThreaded,
180 OggVorbisFileReader::CacheInTemporaryFile);
181 if (reader->isOK()) return reader;
182 if (reader->getError() != "") {
183 std::cerr << "AudioFileReaderFactory: Ogg file reader error: \""
184 << reader->getError().toStdString() << "\"" << std::endl;
185 } else {
186 std::cerr << "AudioFileReaderFactory: Ogg file reader failed"
187 << std::endl;
188 }
189 delete reader;
190 #endif
191 #endif
192
193 #ifdef HAVE_MAD
194 reader = new MP3FileReader
195 (path,
196 MP3FileReader::DecodeThreaded,
197 MP3FileReader::CacheInTemporaryFile);
198 if (reader->isOK()) return reader;
199 if (reader->getError() != "") {
200 std::cerr << "AudioFileReaderFactory: MP3 file reader error: \""
201 << reader->getError().toStdString() << "\"" << std::endl;
202 } else {
203 std::cerr << "AudioFileReaderFactory: MP3 file reader failed"
204 << std::endl;
205 }
206 delete reader;
207 #endif
208
209 #ifdef HAVE_QUICKTIME
210 reader = new QuickTimeFileReader
211 (path,
212 QuickTimeFileReader::DecodeThreaded,
213 QuickTimeFileReader::CacheInTemporaryFile);
214 if (reader->isOK()) return reader;
215 if (reader->getError() != "") {
216 std::cerr << "AudioFileReaderFactory: QuickTime file reader error: \""
217 << reader->getError().toStdString() << "\"" << std::endl;
218 } else {
219 std::cerr << "AudioFileReaderFactory: QuickTime file reader failed"
220 << std::endl;
221 }
222 delete reader;
223 #endif
224
225 return 0;
226 } 151 }
227 152