# HG changeset patch # User Chris Cannam # Date 1536066647 -3600 # Node ID 015416e3a29883eaaaef9579cb0b1b27b078b8f3 # Parent a28cab68eac671ba8a4782c5d53d56b0e750ebce# Parent b316a89ec6a61b634ce3a5dcfd6075ac7231889b Merge from default branch diff -r b316a89ec6a6 -r 015416e3a298 main/MainWindow.cpp --- a/main/MainWindow.cpp Tue Sep 04 11:33:36 2018 +0100 +++ b/main/MainWindow.cpp Tue Sep 04 14:10:47 2018 +0100 @@ -586,12 +586,6 @@ connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); menu->addAction(action); - action = new QAction(tr("Export Audio Data..."), this); - action->setStatusTip(tr("Export audio from selection into a data file")); - connect(action, SIGNAL(triggered()), this, SLOT(exportAudioData())); - connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); - menu->addAction(action); - menu->addSeparator(); action = new QAction(tr("Import Annotation &Layer..."), this); @@ -611,6 +605,19 @@ menu->addAction(action); menu->addSeparator(); + + action = new QAction(tr("Import Audio Data from CSV..."), 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 to CSV..."), this); + 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); + + menu->addSeparator(); action = new QAction(tr("Export Image File..."), this); action->setStatusTip(tr("Export a single pane to an image file")); @@ -2878,6 +2885,60 @@ } 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; + + ProgressDialog *dialog = new ProgressDialog(tr("Importing audio data..."), + true, 0, this, + Qt::ApplicationModal); + + WaveFileModel *model = qobject_cast + (DataFileReaderFactory::loadCSV + (path, format, + getMainModel() ? getMainModel()->getSampleRate() : rate, + dialog)); + + if (dialog->wasCancelled()) { + + delete model; + status = FileOpenCancelled; + + } else if (!model || !model->isOK()) { + + delete model; + status = FileOpenFailed; + + } else { + + status = addOpenedAudioModel(path, + model, + CreateAdditionalModel, + getDefaultSessionTemplate(), + false); + } + + delete dialog; + + 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 b316a89ec6a6 -r 015416e3a298 main/MainWindow.h --- a/main/MainWindow.h Tue Sep 04 11:33:36 2018 +0100 +++ b/main/MainWindow.h Tue Sep 04 14:10:47 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 b316a89ec6a6 -r 015416e3a298 repoint-lock.json --- a/repoint-lock.json Tue Sep 04 11:33:36 2018 +0100 +++ b/repoint-lock.json Tue Sep 04 14:10:47 2018 +0100 @@ -4,13 +4,13 @@ "pin": "da86fb0bccb3" }, "svcore": { - "pin": "a250a54c11cc" + "pin": "fe579dc6a713" }, "svgui": { - "pin": "c0d8356e274f" + "pin": "c2fa7bb1eca9" }, "svapp": { - "pin": "e98a42e94d90" + "pin": "636a5908cf81" }, "checker": { "pin": "2e8a5f665a07" diff -r b316a89ec6a6 -r 015416e3a298 repoint-project.json --- a/repoint-project.json Tue Sep 04 11:33:36 2018 +0100 +++ b/repoint-project.json Tue Sep 04 14:10:47 2018 +0100 @@ -16,15 +16,18 @@ }, "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", - "service": "soundsoftware" + "service": "soundsoftware", + "branch": "import-audio-data" }, "checker": { "vcs": "hg",