diff framework/MainWindowBase.cpp @ 478:1f86bf6644b8 recording

Toward recording without something already loaded (needs more work though)
author Chris Cannam
date Wed, 19 Aug 2015 16:34:06 +0100
parents 411e019474e5
children 6f475df6f833
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Tue Aug 18 16:47:54 2015 +0100
+++ b/framework/MainWindowBase.cpp	Wed Aug 19 16:34:06 2015 +0100
@@ -569,8 +569,6 @@
 	(getMainModel() != 0);
     bool havePlayTarget =
 	(m_playTarget != 0 || m_audioIO != 0);
-    bool haveRecordSource =
-	(m_audioIO != 0);
     bool haveSelection = 
 	(m_viewManager &&
 	 !m_viewManager->getSelections().empty());
@@ -615,7 +613,7 @@
     emit canMeasureLayer(haveCurrentLayer);
     emit canSelect(haveMainModel && haveCurrentPane);
     emit canPlay(haveMainModel && havePlayTarget);
-    emit canRecord(haveRecordSource);
+    emit canRecord(m_soundOptions & WithAudioInput); // always possible then
     emit canFfwd(haveMainModel);
     emit canRewind(haveMainModel);
     emit canPaste(haveClipboardContents);
@@ -2666,11 +2664,19 @@
 void
 MainWindowBase::record()
 {
+    if (!(m_soundOptions & WithAudioInput)) {
+        return;
+    }
+
     if (!m_recordTarget) {
         //!!! report
         return;
     }
 
+    if (!m_audioIO) {
+        createAudioIO();
+    }
+    
     if (m_recordTarget->isRecording()) {
         m_recordTarget->stopRecording();
         return;
@@ -2690,27 +2696,37 @@
         return;
     }
 
-    CommandHistory::getInstance()->startCompoundOperation
-        (tr("Import Recorded Audio"), true);
-
-    m_document->addImportedModel(model);
-
-    AddPaneCommand *command = new AddPaneCommand(this);
-    CommandHistory::getInstance()->addCommand(command);
-
-    Pane *pane = command->getPane();
-
-    if (m_timeRulerLayer) {
-        m_document->addLayerToView(pane, m_timeRulerLayer);
+    PlayParameterRepository::getInstance()->addPlayable(model);
+    
+    if (!getMainModel()) {
+
+        m_document->setMainModel(model);
+        setupMenus();
+
+    } else {
+
+        CommandHistory::getInstance()->startCompoundOperation
+            (tr("Import Recorded Audio"), true);
+
+        m_document->addImportedModel(model);
+
+        AddPaneCommand *command = new AddPaneCommand(this);
+        CommandHistory::getInstance()->addCommand(command);
+
+        Pane *pane = command->getPane();
+
+        if (m_timeRulerLayer) {
+            m_document->addLayerToView(pane, m_timeRulerLayer);
+        }
+
+        Layer *newLayer = m_document->createImportedLayer(model);
+
+        if (newLayer) {
+            m_document->addLayerToView(pane, newLayer);
+        }
+	
+        CommandHistory::getInstance()->endCompoundOperation();
     }
-
-    Layer *newLayer = m_document->createImportedLayer(model);
-
-    if (newLayer) {
-        m_document->addLayerToView(pane, newLayer);
-    }
-	
-    CommandHistory::getInstance()->endCompoundOperation();
 }
 
 void