annotate data/fileio/DataFileReaderFactory.cpp @ 295:a2dc34ce146a

* Window should be centred on its nominal time. I'm not sure what the reasoning was behind the previous formulations of these two lines.
author Chris Cannam
date Thu, 06 Sep 2007 15:14:47 +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