Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 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 | 52c0aff69478 493f2af85497 |
comparison
equal
deleted
inserted
replaced
478:1f86bf6644b8 | 479:6f475df6f833 |
---|---|
16 #include "MainWindowBase.h" | 16 #include "MainWindowBase.h" |
17 #include "Document.h" | 17 #include "Document.h" |
18 | 18 |
19 #include "view/Pane.h" | 19 #include "view/Pane.h" |
20 #include "view/PaneStack.h" | 20 #include "view/PaneStack.h" |
21 #include "data/model/WaveFileModel.h" | 21 #include "data/model/ReadOnlyWaveFileModel.h" |
22 #include "data/model/WritableWaveFileModel.h" | 22 #include "data/model/WritableWaveFileModel.h" |
23 #include "data/model/SparseOneDimensionalModel.h" | 23 #include "data/model/SparseOneDimensionalModel.h" |
24 #include "data/model/NoteModel.h" | 24 #include "data/model/NoteModel.h" |
25 #include "data/model/FlexiNoteModel.h" | 25 #include "data/model/FlexiNoteModel.h" |
26 #include "data/model/Labeller.h" | 26 #include "data/model/Labeller.h" |
1328 rate = Preferences::getInstance()->getFixedSampleRate(); | 1328 rate = Preferences::getInstance()->getFixedSampleRate(); |
1329 } else if (Preferences::getInstance()->getResampleOnLoad()) { | 1329 } else if (Preferences::getInstance()->getResampleOnLoad()) { |
1330 rate = m_playSource->getSourceSampleRate(); | 1330 rate = m_playSource->getSourceSampleRate(); |
1331 } | 1331 } |
1332 | 1332 |
1333 WaveFileModel *newModel = new WaveFileModel(source, rate); | 1333 ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate); |
1334 | 1334 |
1335 if (!newModel->isOK()) { | 1335 if (!newModel->isOK()) { |
1336 delete newModel; | 1336 delete newModel; |
1337 m_openingAudioFile = false; | 1337 m_openingAudioFile = false; |
1338 if (source.wasCancelled()) { | 1338 if (source.wasCancelled()) { |
2653 void | 2653 void |
2654 MainWindowBase::play() | 2654 MainWindowBase::play() |
2655 { | 2655 { |
2656 if (m_recordTarget->isRecording() || m_playSource->isPlaying()) { | 2656 if (m_recordTarget->isRecording() || m_playSource->isPlaying()) { |
2657 stop(); | 2657 stop(); |
2658 QAction *action = qobject_cast<QAction *>(sender()); | |
2659 if (action) action->setChecked(false); | |
2658 } else { | 2660 } else { |
2659 playbackFrameChanged(m_viewManager->getPlaybackFrame()); | 2661 playbackFrameChanged(m_viewManager->getPlaybackFrame()); |
2660 m_playSource->play(m_viewManager->getPlaybackFrame()); | 2662 m_playSource->play(m_viewManager->getPlaybackFrame()); |
2661 } | 2663 } |
2662 } | 2664 } |
2677 createAudioIO(); | 2679 createAudioIO(); |
2678 } | 2680 } |
2679 | 2681 |
2680 if (m_recordTarget->isRecording()) { | 2682 if (m_recordTarget->isRecording()) { |
2681 m_recordTarget->stopRecording(); | 2683 m_recordTarget->stopRecording(); |
2684 emit audioFileLoaded(); | |
2682 return; | 2685 return; |
2683 } | 2686 } |
2684 | 2687 |
2685 WritableWaveFileModel *model = m_recordTarget->startRecording(); | 2688 WritableWaveFileModel *model = m_recordTarget->startRecording(); |
2686 if (!model) { | 2689 if (!model) { |
2698 | 2701 |
2699 PlayParameterRepository::getInstance()->addPlayable(model); | 2702 PlayParameterRepository::getInstance()->addPlayable(model); |
2700 | 2703 |
2701 if (!getMainModel()) { | 2704 if (!getMainModel()) { |
2702 | 2705 |
2706 //!!! duplication with openAudio here | |
2707 | |
2708 QString templateName = getDefaultSessionTemplate(); | |
2709 bool loadedTemplate = false; | |
2710 | |
2711 if (templateName != "") { | |
2712 FileOpenStatus tplStatus = openSessionTemplate(templateName); | |
2713 if (tplStatus == FileOpenCancelled) { | |
2714 return; | |
2715 } | |
2716 if (tplStatus != FileOpenFailed) { | |
2717 loadedTemplate = true; | |
2718 } | |
2719 } | |
2720 | |
2721 if (!loadedTemplate) { | |
2722 closeSession(); | |
2723 createDocument(); | |
2724 } | |
2725 | |
2726 Model *prevMain = getMainModel(); | |
2727 if (prevMain) { | |
2728 m_playSource->removeModel(prevMain); | |
2729 PlayParameterRepository::getInstance()->removePlayable(prevMain); | |
2730 } | |
2731 | |
2703 m_document->setMainModel(model); | 2732 m_document->setMainModel(model); |
2704 setupMenus(); | 2733 setupMenus(); |
2705 | 2734 |
2735 if (loadedTemplate || (m_sessionFile == "")) { | |
2736 //!!! shouldn't be dealing directly with title from here -- call a method | |
2737 setWindowTitle(tr("%1: %2") | |
2738 .arg(QApplication::applicationName()) | |
2739 .arg(model->getLocation())); | |
2740 CommandHistory::getInstance()->clear(); | |
2741 CommandHistory::getInstance()->documentSaved(); | |
2742 m_documentModified = false; | |
2743 } else { | |
2744 setWindowTitle(tr("%1: %2 [%3]") | |
2745 .arg(QApplication::applicationName()) | |
2746 .arg(QFileInfo(m_sessionFile).fileName()) | |
2747 .arg(model->getLocation())); | |
2748 if (m_documentModified) { | |
2749 m_documentModified = false; | |
2750 documentModified(); // so as to restore "(modified)" window title | |
2751 } | |
2752 } | |
2753 | |
2706 } else { | 2754 } else { |
2707 | 2755 |
2708 CommandHistory::getInstance()->startCompoundOperation | 2756 CommandHistory::getInstance()->startCompoundOperation |
2709 (tr("Import Recorded Audio"), true); | 2757 (tr("Import Recorded Audio"), true); |
2710 | 2758 |
2725 m_document->addLayerToView(pane, newLayer); | 2773 m_document->addLayerToView(pane, newLayer); |
2726 } | 2774 } |
2727 | 2775 |
2728 CommandHistory::getInstance()->endCompoundOperation(); | 2776 CommandHistory::getInstance()->endCompoundOperation(); |
2729 } | 2777 } |
2778 | |
2779 updateMenuStates(); | |
2780 m_recentFiles.addFile(model->getLocation()); | |
2781 currentPaneChanged(m_paneStack->getCurrentPane()); | |
2730 } | 2782 } |
2731 | 2783 |
2732 void | 2784 void |
2733 MainWindowBase::ffwd() | 2785 MainWindowBase::ffwd() |
2734 { | 2786 { |
2957 void | 3009 void |
2958 MainWindowBase::stop() | 3010 MainWindowBase::stop() |
2959 { | 3011 { |
2960 if (m_recordTarget->isRecording()) { | 3012 if (m_recordTarget->isRecording()) { |
2961 m_recordTarget->stopRecording(); | 3013 m_recordTarget->stopRecording(); |
3014 emit audioFileLoaded(); | |
2962 } | 3015 } |
2963 | 3016 |
2964 m_playSource->stop(); | 3017 m_playSource->stop(); |
2965 | 3018 |
2966 if (m_paneStack && m_paneStack->getCurrentPane()) { | 3019 if (m_paneStack && m_paneStack->getCurrentPane()) { |