comparison data/fileio/AudioFileReaderFactory.cpp @ 148:1a42221a1522

* Reorganising code base. This revision will not compile.
author Chris Cannam
date Mon, 31 Jul 2006 11:49:58 +0000
parents
children c03ec31005e1
comparison
equal deleted inserted replaced
147:3a13b0d4934e 148:1a42221a1522
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #include "AudioFileReaderFactory.h"
17
18 #include "WavFileReader.h"
19 #include "OggVorbisFileReader.h"
20 #include "MP3FileReader.h"
21
22 #include <QString>
23
24 QString
25 AudioFileReaderFactory::getKnownExtensions()
26 {
27 return
28 "*.wav *.aiff *.aif"
29 #ifdef HAVE_MAD
30 " *.mp3"
31 #endif
32 #ifdef HAVE_OGGZ
33 #ifdef HAVE_FISHSOUND
34 " *.ogg"
35 #endif
36 #endif
37 ;
38 }
39
40 AudioFileReader *
41 AudioFileReaderFactory::createReader(QString path)
42 {
43 QString err;
44
45 AudioFileReader *reader = 0;
46
47 reader = new WavFileReader(path);
48 if (reader->isOK()) return reader;
49 if (reader->getError() != "") err = reader->getError();
50 delete reader;
51
52 #ifdef HAVE_OGGZ
53 #ifdef HAVE_FISHSOUND
54 reader = new OggVorbisFileReader(path, true,
55 OggVorbisFileReader::CacheInTemporaryFile);
56 if (reader->isOK()) return reader;
57 if (reader->getError() != "") err = reader->getError();
58 delete reader;
59 #endif
60 #endif
61
62 #ifdef HAVE_MAD
63 reader = new MP3FileReader(path, true,
64 MP3FileReader::CacheInTemporaryFile);
65 if (reader->isOK()) return reader;
66 if (reader->getError() != "") err = reader->getError();
67 delete reader;
68 #endif
69
70 return 0;
71 }
72