Mercurial > hg > sonic-visualiser
changeset 1902:dc275d7d9aa6 import-audio-data
Toward loading audio from CSV files
author | Chris Cannam |
---|---|
date | Thu, 28 Jun 2018 14:53:38 +0100 (2018-06-28) |
parents | a3cd06d89a45 |
children | 05c53d02bf7e |
files | main/MainWindow.cpp main/MainWindow.h repoint-lock.json repoint-project.json |
diffstat | 4 files changed, 58 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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<WaveFileModel *> + (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("<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 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();
--- 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"
--- 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",