Mercurial > hg > svapp
changeset 479:6f475df6f833 recording
Make WritableWaveFileModel a true WaveFileModel (and ReadOnlyWaveFileModel the other sort of it). Enable recording from an empty session using that.
author | Chris Cannam |
---|---|
date | Wed, 19 Aug 2015 17:03:31 +0100 |
parents | 1f86bf6644b8 |
children | 1d4cb8befcfd |
files | framework/MainWindowBase.cpp framework/SVFileReader.cpp |
diffstat | 2 files changed, 57 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Wed Aug 19 16:34:06 2015 +0100 +++ b/framework/MainWindowBase.cpp Wed Aug 19 17:03:31 2015 +0100 @@ -18,7 +18,7 @@ #include "view/Pane.h" #include "view/PaneStack.h" -#include "data/model/WaveFileModel.h" +#include "data/model/ReadOnlyWaveFileModel.h" #include "data/model/WritableWaveFileModel.h" #include "data/model/SparseOneDimensionalModel.h" #include "data/model/NoteModel.h" @@ -1330,7 +1330,7 @@ rate = m_playSource->getSourceSampleRate(); } - WaveFileModel *newModel = new WaveFileModel(source, rate); + ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate); if (!newModel->isOK()) { delete newModel; @@ -2655,6 +2655,8 @@ { if (m_recordTarget->isRecording() || m_playSource->isPlaying()) { stop(); + QAction *action = qobject_cast<QAction *>(sender()); + if (action) action->setChecked(false); } else { playbackFrameChanged(m_viewManager->getPlaybackFrame()); m_playSource->play(m_viewManager->getPlaybackFrame()); @@ -2679,6 +2681,7 @@ if (m_recordTarget->isRecording()) { m_recordTarget->stopRecording(); + emit audioFileLoaded(); return; } @@ -2700,9 +2703,54 @@ if (!getMainModel()) { + //!!! duplication with openAudio here + + QString templateName = getDefaultSessionTemplate(); + bool loadedTemplate = false; + + if (templateName != "") { + FileOpenStatus tplStatus = openSessionTemplate(templateName); + if (tplStatus == FileOpenCancelled) { + return; + } + if (tplStatus != FileOpenFailed) { + loadedTemplate = true; + } + } + + if (!loadedTemplate) { + closeSession(); + createDocument(); + } + + Model *prevMain = getMainModel(); + if (prevMain) { + m_playSource->removeModel(prevMain); + PlayParameterRepository::getInstance()->removePlayable(prevMain); + } + m_document->setMainModel(model); setupMenus(); + if (loadedTemplate || (m_sessionFile == "")) { + //!!! shouldn't be dealing directly with title from here -- call a method + setWindowTitle(tr("%1: %2") + .arg(QApplication::applicationName()) + .arg(model->getLocation())); + CommandHistory::getInstance()->clear(); + CommandHistory::getInstance()->documentSaved(); + m_documentModified = false; + } else { + setWindowTitle(tr("%1: %2 [%3]") + .arg(QApplication::applicationName()) + .arg(QFileInfo(m_sessionFile).fileName()) + .arg(model->getLocation())); + if (m_documentModified) { + m_documentModified = false; + documentModified(); // so as to restore "(modified)" window title + } + } + } else { CommandHistory::getInstance()->startCompoundOperation @@ -2727,6 +2775,10 @@ CommandHistory::getInstance()->endCompoundOperation(); } + + updateMenuStates(); + m_recentFiles.addFile(model->getLocation()); + currentPaneChanged(m_paneStack->getCurrentPane()); } void @@ -2959,6 +3011,7 @@ { if (m_recordTarget->isRecording()) { m_recordTarget->stopRecording(); + emit audioFileLoaded(); } m_playSource->stop();
--- a/framework/SVFileReader.cpp Wed Aug 19 16:34:06 2015 +0100 +++ b/framework/SVFileReader.cpp Wed Aug 19 17:03:31 2015 +0100 @@ -26,7 +26,7 @@ #include "data/fileio/FileFinder.h" -#include "data/model/WaveFileModel.h" +#include "data/model/ReadOnlyWaveFileModel.h" #include "data/model/EditableDenseThreeDimensionalModel.h" #include "data/model/SparseOneDimensionalModel.h" #include "data/model/SparseTimeValueModel.h" @@ -489,7 +489,7 @@ if (mm) rate = mm->getSampleRate(); } - model = new WaveFileModel(file, rate); + model = new ReadOnlyWaveFileModel(file, rate); if (!model->isOK()) { delete model; model = 0;