Mercurial > hg > sonic-visualiser
changeset 1984:015416e3a298 import-audio-data
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 04 Sep 2018 14:10:47 +0100 |
parents | a28cab68eac6 (diff) b316a89ec6a6 (current diff) |
children | c37e67a2ff17 |
files | main/MainWindow.cpp repoint-lock.json repoint-project.json |
diffstat | 4 files changed, 77 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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<WaveFileModel *> + (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("<b>File open failed</b><p>Audio data file %1 could not be opened.").arg(path)); + } +} + +void MainWindow::importLayer() { Pane *pane = m_paneStack->getCurrentPane();
--- 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();
--- 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"
--- 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",