Mercurial > hg > svcore
annotate data/fileio/DataFileReaderFactory.cpp @ 378:a38cd7823cb2
* PortAudio driver: do not specify frames per buffer, let PA decide
* Remove old non-RubberBand time stretcher -- it doesn't work with varying
buffer sizes such as the PA driver may now be using
* Rewrite getCurrentPlayingFrame for greater correctness when using long
buffer sizes (interpolating according to audio stream timestamp)
* Several changes to make the timestretch management RT safe(r)
author | Chris Cannam |
---|---|
date | Fri, 08 Feb 2008 17:51:15 +0000 |
parents | 14e0f60435b8 |
children | 183ee2a55fc7 |
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 "DataFileReaderFactory.h" |
Chris@148 | 17 #include "MIDIFileReader.h" |
Chris@148 | 18 #include "CSVFileReader.h" |
Chris@148 | 19 |
Chris@150 | 20 #include "model/Model.h" |
Chris@148 | 21 |
Chris@148 | 22 #include <QString> |
Chris@148 | 23 |
Chris@148 | 24 QString |
Chris@148 | 25 DataFileReaderFactory::getKnownExtensions() |
Chris@148 | 26 { |
Chris@148 | 27 return "*.svl *.csv *.lab *.mid *.txt"; |
Chris@148 | 28 } |
Chris@148 | 29 |
Chris@148 | 30 DataFileReader * |
Chris@148 | 31 DataFileReaderFactory::createReader(QString path, size_t mainModelSampleRate) |
Chris@148 | 32 { |
Chris@148 | 33 QString err; |
Chris@148 | 34 |
Chris@148 | 35 DataFileReader *reader = 0; |
Chris@148 | 36 |
Chris@148 | 37 reader = new MIDIFileReader(path, mainModelSampleRate); |
Chris@148 | 38 if (reader->isOK()) return reader; |
Chris@148 | 39 if (reader->getError() != "") err = reader->getError(); |
Chris@148 | 40 delete reader; |
Chris@148 | 41 |
Chris@148 | 42 reader = new CSVFileReader(path, mainModelSampleRate); |
Chris@148 | 43 if (reader->isOK()) return reader; |
Chris@148 | 44 if (reader->getError() != "") err = reader->getError(); |
Chris@148 | 45 delete reader; |
Chris@148 | 46 |
Chris@148 | 47 return 0; |
Chris@148 | 48 } |
Chris@148 | 49 |
Chris@148 | 50 Model * |
Chris@148 | 51 DataFileReaderFactory::load(QString path, size_t mainModelSampleRate) |
Chris@148 | 52 { |
Chris@148 | 53 DataFileReader *reader = createReader(path, mainModelSampleRate); |
Chris@148 | 54 if (!reader) return NULL; |
Chris@148 | 55 |
Chris@308 | 56 try { |
Chris@308 | 57 Model *model = reader->load(); |
Chris@308 | 58 delete reader; |
Chris@308 | 59 return model; |
Chris@308 | 60 } catch (Exception) { |
Chris@308 | 61 delete reader; |
Chris@308 | 62 throw; |
Chris@308 | 63 } |
Chris@148 | 64 } |
Chris@148 | 65 |