Mercurial > hg > svcore
annotate data/fileio/DataFileReaderFactory.cpp @ 188:f86b74d1b143
* Simplify maker names in plugin menu
* Make sure derived models have a name (based on the transform)
* Don't start deriving a model from a derived model until the derived model is
ready
* Tidy up completion management in writable wave file model
* Make writable models save/reload correctly from session file (i.e.
regenerating from the original transform)
* Same for dense 3d models -- don't save the data, just the transform details
* Add a comment describing the SV file format
author | Chris Cannam |
---|---|
date | Fri, 13 Oct 2006 12:51:05 +0000 |
parents | 4b2ea82fd0ed |
children | 14e0f60435b8 |
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@148 | 56 Model *model = reader->load(); |
Chris@148 | 57 delete reader; |
Chris@148 | 58 |
Chris@148 | 59 return model; |
Chris@148 | 60 } |
Chris@148 | 61 |