comparison framework/MainWindowBase.cpp @ 477:411e019474e5 recording

OK, we can record -- sort of
author Chris Cannam
date Tue, 18 Aug 2015 16:47:54 +0100
parents f93820d36cb0
children 1f86bf6644b8
comparison
equal deleted inserted replaced
476:f4d1fa41b94b 477:411e019474e5
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/WaveFileModel.h"
22 #include "data/model/WritableWaveFileModel.h"
22 #include "data/model/SparseOneDimensionalModel.h" 23 #include "data/model/SparseOneDimensionalModel.h"
23 #include "data/model/NoteModel.h" 24 #include "data/model/NoteModel.h"
24 #include "data/model/FlexiNoteModel.h" 25 #include "data/model/FlexiNoteModel.h"
25 #include "data/model/Labeller.h" 26 #include "data/model/Labeller.h"
26 #include "data/model/TabularModel.h" 27 #include "data/model/TabularModel.h"
2652 } 2653 }
2653 2654
2654 void 2655 void
2655 MainWindowBase::play() 2656 MainWindowBase::play()
2656 { 2657 {
2657 if (m_playSource->isPlaying()) { 2658 if (m_recordTarget->isRecording() || m_playSource->isPlaying()) {
2658 stop(); 2659 stop();
2659 } else { 2660 } else {
2660 playbackFrameChanged(m_viewManager->getPlaybackFrame()); 2661 playbackFrameChanged(m_viewManager->getPlaybackFrame());
2661 m_playSource->play(m_viewManager->getPlaybackFrame()); 2662 m_playSource->play(m_viewManager->getPlaybackFrame());
2662 } 2663 }
2664 }
2665
2666 void
2667 MainWindowBase::record()
2668 {
2669 if (!m_recordTarget) {
2670 //!!! report
2671 return;
2672 }
2673
2674 if (m_recordTarget->isRecording()) {
2675 m_recordTarget->stopRecording();
2676 return;
2677 }
2678
2679 WritableWaveFileModel *model = m_recordTarget->startRecording();
2680 if (!model) {
2681 cerr << "ERROR: MainWindowBase::record: Recording failed" << endl;
2682 //!!! report
2683 return;
2684 }
2685
2686 if (!model->isOK()) {
2687 m_recordTarget->stopRecording();
2688 delete model;
2689 //!!! ???
2690 return;
2691 }
2692
2693 CommandHistory::getInstance()->startCompoundOperation
2694 (tr("Import Recorded Audio"), true);
2695
2696 m_document->addImportedModel(model);
2697
2698 AddPaneCommand *command = new AddPaneCommand(this);
2699 CommandHistory::getInstance()->addCommand(command);
2700
2701 Pane *pane = command->getPane();
2702
2703 if (m_timeRulerLayer) {
2704 m_document->addLayerToView(pane, m_timeRulerLayer);
2705 }
2706
2707 Layer *newLayer = m_document->createImportedLayer(model);
2708
2709 if (newLayer) {
2710 m_document->addLayerToView(pane, newLayer);
2711 }
2712
2713 CommandHistory::getInstance()->endCompoundOperation();
2663 } 2714 }
2664 2715
2665 void 2716 void
2666 MainWindowBase::ffwd() 2717 MainWindowBase::ffwd()
2667 { 2718 {
2888 } 2939 }
2889 2940
2890 void 2941 void
2891 MainWindowBase::stop() 2942 MainWindowBase::stop()
2892 { 2943 {
2944 if (m_recordTarget->isRecording()) {
2945 m_recordTarget->stopRecording();
2946 }
2947
2893 m_playSource->stop(); 2948 m_playSource->stop();
2894 2949
2895 if (m_paneStack && m_paneStack->getCurrentPane()) { 2950 if (m_paneStack && m_paneStack->getCurrentPane()) {
2896 updateVisibleRangeDisplay(m_paneStack->getCurrentPane()); 2951 updateVisibleRangeDisplay(m_paneStack->getCurrentPane());
2897 } else { 2952 } else {