# HG changeset patch # User Chris Cannam # Date 1530194018 -3600 # Node ID dc275d7d9aa60f48b2c86a41931ea1793720d273 # Parent a3cd06d89a45bc32ec62adc6340b32c92d130cab Toward loading audio from CSV files diff -r a3cd06d89a45 -r dc275d7d9aa6 main/MainWindow.cpp --- a/main/MainWindow.cpp Thu Jun 28 12:53:05 2018 +0100 +++ b/main/MainWindow.cpp Thu Jun 28 14:53:38 2018 +0100 @@ -587,8 +587,15 @@ connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); menu->addAction(action); + menu->addSeparator(); + + action = new QAction(tr("Import Audio Data..."), this); + action->setStatusTip(tr("Import audio sample values from a CSV data file")); + connect(action, SIGNAL(triggered()), this, SLOT(importAudioData())); + menu->addAction(action); + action = new QAction(tr("Export Audio Data..."), this); - action->setStatusTip(tr("Export audio from selection into a data file")); + action->setStatusTip(tr("Export audio from selection into a CSV data file")); connect(action, SIGNAL(triggered()), this, SLOT(exportAudioData())); connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); menu->addAction(action); @@ -2880,6 +2887,48 @@ } void +MainWindow::importAudioData() +{ + QString path = getOpenFileName(FileFinder::CSVFile); + if (path == "") return; + + sv_samplerate_t rate = 44100; //!!! + + CSVFormat format(path); + format.setModelType(CSVFormat::WaveFileModel); + format.setSampleRate(rate); + format.setTimingType(CSVFormat::ImplicitTiming); + format.setTimeUnits(CSVFormat::TimeAudioFrames); + + FileOpenStatus status = FileOpenSucceeded; + + WaveFileModel *model = qobject_cast + (DataFileReaderFactory::loadCSV + (path, format, + getMainModel() ? getMainModel()->getSampleRate() : rate)); + + if (!model || !model->isOK()) { + + delete model; + status = FileOpenFailed; + + } else { + + status = addOpenedAudioModel(path, + model, + CreateAdditionalModel, + getDefaultSessionTemplate(), + false); + } + + if (status == FileOpenFailed) { + emit hideSplash(); + QMessageBox::critical(this, tr("Failed to open file"), + tr("File open failed

Audio data file %1 could not be opened.").arg(path)); + } +} + +void MainWindow::importLayer() { Pane *pane = m_paneStack->getCurrentPane(); diff -r a3cd06d89a45 -r dc275d7d9aa6 main/MainWindow.h --- a/main/MainWindow.h Thu Jun 28 12:53:05 2018 +0100 +++ b/main/MainWindow.h Thu Jun 28 14:53:38 2018 +0100 @@ -60,6 +60,7 @@ virtual void applyTemplate(); virtual void exportAudio(); virtual void exportAudioData(); + virtual void importAudioData(); virtual void importLayer(); virtual void exportLayer(); virtual void exportImage(); diff -r a3cd06d89a45 -r dc275d7d9aa6 repoint-lock.json --- a/repoint-lock.json Thu Jun 28 12:53:05 2018 +0100 +++ b/repoint-lock.json Thu Jun 28 14:53:38 2018 +0100 @@ -4,10 +4,10 @@ "pin": "da86fb0bccb3" }, "svcore": { - "pin": "71202259002d" + "pin": "53fa8d57b728" }, "svgui": { - "pin": "13e17e61f898" + "pin": "fcc1f45f7bd5" }, "svapp": { "pin": "d4c16eed673d" @@ -37,7 +37,7 @@ "pin": "d90244c003be" }, "sv-dependency-builds": { - "pin": "a69c1527268d" + "pin": "a9f5ce17330a" }, "icons/scalable": { "pin": "1c6516ba7fc1" diff -r a3cd06d89a45 -r dc275d7d9aa6 repoint-project.json --- a/repoint-project.json Thu Jun 28 12:53:05 2018 +0100 +++ b/repoint-project.json Thu Jun 28 14:53:38 2018 +0100 @@ -16,11 +16,13 @@ }, "svcore": { "vcs": "hg", - "service": "soundsoftware" + "service": "soundsoftware", + "branch": "import-audio-data" }, "svgui": { "vcs": "hg", - "service": "soundsoftware" + "service": "soundsoftware", + "branch": "import-audio-data" }, "svapp": { "vcs": "hg",