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