# HG changeset patch # User Chris Cannam # Date 1442331248 -3600 # Node ID 493f2af85497469f6682a80c172942493e5fb527 # Parent 1d4cb8befcfd5212006da0fd455dbd79d8dfdcd2 Add audio record mode (option to replace session) and support for browsing to record directory diff -r 1d4cb8befcfd -r 493f2af85497 audio/AudioRecordTarget.cpp --- a/audio/AudioRecordTarget.cpp Wed Aug 19 17:21:40 2015 +0100 +++ b/audio/AudioRecordTarget.cpp Tue Sep 15 16:34:08 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(); diff -r 1d4cb8befcfd -r 493f2af85497 audio/AudioRecordTarget.h --- a/audio/AudioRecordTarget.h Wed Aug 19 17:21:40 2015 +0100 +++ b/audio/AudioRecordTarget.h Tue Sep 15 16:34:08 2015 +0100 @@ -51,6 +51,8 @@ virtual void audioProcessingOverload() { } + QString getRecordFolder(); + bool isRecording() const { return m_recording; } WritableWaveFileModel *startRecording(); // caller takes ownership void stopRecording(); diff -r 1d4cb8befcfd -r 493f2af85497 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Wed Aug 19 17:21:40 2015 +0100 +++ b/framework/MainWindowBase.cpp Tue Sep 15 16:34:08 2015 +0100 @@ -157,6 +157,7 @@ m_lastPlayStatusSec(0), m_initialDarkBackground(false), m_defaultFfwdRwdStep(2, 0), + m_audioRecordMode(RecordCreateAdditionalModel), m_statusLabel(0), m_menuShortcutMapper(0) { @@ -613,7 +614,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); @@ -2685,6 +2686,10 @@ return; } + if (m_audioRecordMode == RecordReplaceSession) { + if (!checkSaveModified()) return; + } + WritableWaveFileModel *model = m_recordTarget->startRecording(); if (!model) { cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; @@ -2700,8 +2705,8 @@ } PlayParameterRepository::getInstance()->addPlayable(model); - - if (!getMainModel()) { + + if (m_audioRecordMode == RecordReplaceSession || !getMainModel()) { //!!! duplication with openAudio here @@ -3616,4 +3621,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 + } +} + diff -r 1d4cb8befcfd -r 493f2af85497 framework/MainWindowBase.h --- a/framework/MainWindowBase.h Wed Aug 19 17:21:40 2015 +0100 +++ b/framework/MainWindowBase.h Tue Sep 15 16:34:08 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;