changeset 484:01aeda073720 tony-2.0-integration

Merge from branch recording
author Chris Cannam
date Tue, 15 Sep 2015 16:38:09 +0100
parents 01669adb0956 (current diff) 493f2af85497 (diff)
children 21d3cf5c8f21
files framework/MainWindowBase.cpp
diffstat 4 files changed, 65 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/audio/AudioRecordTarget.cpp	Thu Aug 20 14:54:21 2015 +0100
+++ b/audio/AudioRecordTarget.cpp	Tue Sep 15 16:38:09 2015 +0100
@@ -75,6 +75,19 @@
     }
 }
 
+QString
+AudioRecordTarget::getRecordFolder()
+{
+    QDir parent(TempDirectory::getInstance()->getContainingPath());
+    QString subdirname = "recorded"; //!!! tr?
+    if (!parent.mkpath(subdirname)) {
+        cerr << "ERROR: AudioRecordTarget::getRecordFolder: Failed to create recorded dir in \"" << parent.canonicalPath() << "\"" << endl;
+        return "";
+    } else {
+        return parent.filePath(subdirname);
+    }
+}
+
 WritableWaveFileModel *
 AudioRecordTarget::startRecording()
 {
@@ -87,15 +100,9 @@
 
     m_model = 0;
 
-    QDir parent(TempDirectory::getInstance()->getContainingPath());
-    QDir recordedDir;
-    QString subdirname = "recorded"; //!!! tr?
-    if (!parent.mkpath(subdirname)) {
-        cerr << "ERROR: AudioRecordTarget::startRecording: Failed to create recorded dir in \"" << parent.canonicalPath() << "\"" << endl;
-        return 0;
-    } else {
-        recordedDir = parent.filePath(subdirname);
-    }
+    QString folder = getRecordFolder();
+    if (folder == "") return 0;
+    QDir recordedDir(folder);
 
     QDateTime now = QDateTime::currentDateTime();
 
--- a/audio/AudioRecordTarget.h	Thu Aug 20 14:54:21 2015 +0100
+++ b/audio/AudioRecordTarget.h	Tue Sep 15 16:38:09 2015 +0100
@@ -51,6 +51,8 @@
 
     virtual void audioProcessingOverload() { }
 
+    QString getRecordFolder();
+    
     bool isRecording() const { return m_recording; }
     WritableWaveFileModel *startRecording(); // caller takes ownership
     void stopRecording();
--- a/framework/MainWindowBase.cpp	Thu Aug 20 14:54:21 2015 +0100
+++ b/framework/MainWindowBase.cpp	Tue Sep 15 16:38:09 2015 +0100
@@ -155,6 +155,7 @@
     m_lastPlayStatusSec(0),
     m_initialDarkBackground(false),
     m_defaultFfwdRwdStep(2, 0),
+    m_audioRecordMode(RecordCreateAdditionalModel),
     m_statusLabel(0),
     m_menuShortcutMapper(0)
 {
@@ -611,7 +612,7 @@
     emit canMeasureLayer(haveCurrentLayer);
     emit canSelect(haveMainModel && haveCurrentPane);
     emit canPlay(haveMainModel && havePlayTarget);
-    emit canRecord(m_soundOptions & WithAudioInput); // always possible then
+    emit canRecord(m_recordTarget != 0);
     emit canFfwd(haveMainModel);
     emit canRewind(haveMainModel);
     emit canPaste(haveClipboardContents);
@@ -2683,6 +2684,10 @@
         return;
     }
 
+    if (m_audioRecordMode == RecordReplaceSession) {
+        if (!checkSaveModified()) return;
+    }
+    
     WritableWaveFileModel *model = m_recordTarget->startRecording();
     if (!model) {
         cerr << "ERROR: MainWindowBase::record: Recording failed" << endl;
@@ -2698,8 +2703,8 @@
     }
 
     PlayParameterRepository::getInstance()->addPlayable(model);
-    
-    if (!getMainModel()) {
+
+    if (m_audioRecordMode == RecordReplaceSession || !getMainModel()) {
 
         //!!! duplication with openAudio here
         
@@ -3613,4 +3618,30 @@
 #endif
 }
 
-    
+void
+MainWindowBase::openLocalFolder(QString path)
+{
+    QDir d(path);
+    if (d.exists()) {
+        QStringList args;
+        QString path = d.canonicalPath();
+#if defined Q_OS_WIN32
+        // Although the Win32 API is quite happy to have
+        // forward slashes as directory separators, Windows
+        // Explorer is not
+        path = path.replace('/', '\\');
+        args << path;
+        QProcess::execute("c:/windows/explorer.exe", args);
+#else
+        args << path;
+        QProcess::execute(
+#if defined Q_OS_MAC
+            "/usr/bin/open",
+#else
+            "/usr/bin/xdg-open",
+#endif
+            args);
+#endif
+    }
+}
+
--- a/framework/MainWindowBase.h	Thu Aug 20 14:54:21 2015 +0100
+++ b/framework/MainWindowBase.h	Tue Sep 15 16:38:09 2015 +0100
@@ -108,6 +108,11 @@
         FileOpenWrongMode // attempted to open layer when no main model present
     };
 
+    enum AudioRecordMode {
+        RecordReplaceSession,
+        RecordCreateAdditionalModel
+    };
+    
     virtual FileOpenStatus open(FileSource source, AudioFileOpenMode = AskUser);
     virtual FileOpenStatus openPath(QString fileOrUrl, AudioFileOpenMode = AskUser);
     virtual FileOpenStatus openAudio(FileSource source, AudioFileOpenMode = AskUser, QString templateName = "");
@@ -130,6 +135,10 @@
         m_defaultFfwdRwdStep = step;
     }
 
+    void setAudioRecordMode(AudioRecordMode mode) {
+        m_audioRecordMode = mode;
+    }
+    
 signals:
     // Used to toggle the availability of menu actions
     void canAddPane(bool);
@@ -360,6 +369,8 @@
 
     RealTime                 m_defaultFfwdRwdStep;
 
+    AudioRecordMode          m_audioRecordMode;
+
     mutable QLabel *m_statusLabel;
     QLabel *getStatusLabel() const;
 
@@ -441,6 +452,7 @@
 
     virtual void createAudioIO();
     virtual void openHelpUrl(QString url);
+    virtual void openLocalFolder(QString path);
 
     virtual void setupMenus() = 0;
     virtual void updateVisibleRangeDisplay(Pane *p) const = 0;