Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 489:111e976f9ed4 3.0-integration
Merge from branch "recording"
author | Chris Cannam |
---|---|
date | Thu, 17 Sep 2015 13:46:07 +0100 |
parents | 52c0aff69478 66b92c188cbd |
children | b3568eca53ba a4d90cf2bb79 |
comparison
equal
deleted
inserted
replaced
481:52c0aff69478 | 489:111e976f9ed4 |
---|---|
153 m_abandoning(false), | 153 m_abandoning(false), |
154 m_labeller(0), | 154 m_labeller(0), |
155 m_lastPlayStatusSec(0), | 155 m_lastPlayStatusSec(0), |
156 m_initialDarkBackground(false), | 156 m_initialDarkBackground(false), |
157 m_defaultFfwdRwdStep(2, 0), | 157 m_defaultFfwdRwdStep(2, 0), |
158 m_audioRecordMode(RecordCreateAdditionalModel), | |
158 m_statusLabel(0), | 159 m_statusLabel(0), |
159 m_menuShortcutMapper(0) | 160 m_menuShortcutMapper(0) |
160 { | 161 { |
161 Profiler profiler("MainWindowBase::MainWindowBase"); | 162 Profiler profiler("MainWindowBase::MainWindowBase"); |
162 | 163 |
228 m_playSource = new AudioCallbackPlaySource(m_viewManager, | 229 m_playSource = new AudioCallbackPlaySource(m_viewManager, |
229 QApplication::applicationName()); | 230 QApplication::applicationName()); |
230 if (m_soundOptions & WithAudioInput) { | 231 if (m_soundOptions & WithAudioInput) { |
231 m_recordTarget = new AudioRecordTarget(m_viewManager, | 232 m_recordTarget = new AudioRecordTarget(m_viewManager, |
232 QApplication::applicationName()); | 233 QApplication::applicationName()); |
234 connect(m_recordTarget, SIGNAL(recordDurationChanged(sv_frame_t, sv_samplerate_t)), | |
235 this, SLOT(recordDurationChanged(sv_frame_t, sv_samplerate_t))); | |
233 } | 236 } |
234 | 237 |
235 connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)), | 238 connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)), |
236 this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool))); | 239 this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool))); |
237 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), | 240 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), |
609 emit canEditLayer(haveCurrentEditableLayer); | 612 emit canEditLayer(haveCurrentEditableLayer); |
610 emit canEditLayerTabular(haveCurrentEditableLayer || haveTabularLayer); | 613 emit canEditLayerTabular(haveCurrentEditableLayer || haveTabularLayer); |
611 emit canMeasureLayer(haveCurrentLayer); | 614 emit canMeasureLayer(haveCurrentLayer); |
612 emit canSelect(haveMainModel && haveCurrentPane); | 615 emit canSelect(haveMainModel && haveCurrentPane); |
613 emit canPlay(haveMainModel && havePlayTarget); | 616 emit canPlay(haveMainModel && havePlayTarget); |
614 emit canRecord(m_soundOptions & WithAudioInput); // always possible then | 617 emit canRecord(m_recordTarget != 0); |
615 emit canFfwd(haveMainModel); | 618 emit canFfwd(haveMainModel); |
616 emit canRewind(haveMainModel); | 619 emit canRewind(haveMainModel); |
617 emit canPaste(haveClipboardContents); | 620 emit canPaste(haveClipboardContents); |
618 emit canInsertInstant(haveCurrentPane); | 621 emit canInsertInstant(haveCurrentPane); |
619 emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection); | 622 emit canInsertInstantsAtBoundaries(haveCurrentPane && haveSelection); |
2193 */ | 2196 */ |
2194 | 2197 |
2195 if (m_soundOptions & WithAudioInput) { | 2198 if (m_soundOptions & WithAudioInput) { |
2196 m_audioIO = breakfastquay::AudioFactory:: | 2199 m_audioIO = breakfastquay::AudioFactory:: |
2197 createCallbackIO(m_recordTarget, m_playSource); | 2200 createCallbackIO(m_recordTarget, m_playSource); |
2201 m_audioIO->suspend(); // start in suspended state | |
2198 m_playSource->setSystemPlaybackTarget(m_audioIO); | 2202 m_playSource->setSystemPlaybackTarget(m_audioIO); |
2199 } else { | 2203 } else { |
2200 m_playTarget = breakfastquay::AudioFactory:: | 2204 m_playTarget = breakfastquay::AudioFactory:: |
2201 createCallbackPlayTarget(m_playSource); | 2205 createCallbackPlayTarget(m_playSource); |
2202 m_playSource->setSystemPlaybackTarget(m_playTarget); | 2206 m_playSource->setSystemPlaybackTarget(m_playTarget); |
2654 if (m_recordTarget->isRecording() || m_playSource->isPlaying()) { | 2658 if (m_recordTarget->isRecording() || m_playSource->isPlaying()) { |
2655 stop(); | 2659 stop(); |
2656 QAction *action = qobject_cast<QAction *>(sender()); | 2660 QAction *action = qobject_cast<QAction *>(sender()); |
2657 if (action) action->setChecked(false); | 2661 if (action) action->setChecked(false); |
2658 } else { | 2662 } else { |
2663 if (m_audioIO) m_audioIO->resume(); | |
2659 playbackFrameChanged(m_viewManager->getPlaybackFrame()); | 2664 playbackFrameChanged(m_viewManager->getPlaybackFrame()); |
2660 m_playSource->play(m_viewManager->getPlaybackFrame()); | 2665 m_playSource->play(m_viewManager->getPlaybackFrame()); |
2661 } | 2666 } |
2662 } | 2667 } |
2663 | 2668 |
2681 m_recordTarget->stopRecording(); | 2686 m_recordTarget->stopRecording(); |
2682 emit audioFileLoaded(); | 2687 emit audioFileLoaded(); |
2683 return; | 2688 return; |
2684 } | 2689 } |
2685 | 2690 |
2691 if (m_audioRecordMode == RecordReplaceSession) { | |
2692 if (!checkSaveModified()) return; | |
2693 } | |
2694 | |
2695 if (m_audioIO) m_audioIO->resume(); | |
2696 | |
2686 WritableWaveFileModel *model = m_recordTarget->startRecording(); | 2697 WritableWaveFileModel *model = m_recordTarget->startRecording(); |
2687 if (!model) { | 2698 if (!model) { |
2688 cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; | 2699 cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; |
2689 //!!! report | 2700 //!!! report |
2690 return; | 2701 return; |
2694 m_recordTarget->stopRecording(); | 2705 m_recordTarget->stopRecording(); |
2695 delete model; | 2706 delete model; |
2696 //!!! ??? | 2707 //!!! ??? |
2697 return; | 2708 return; |
2698 } | 2709 } |
2699 | 2710 |
2700 PlayParameterRepository::getInstance()->addPlayable(model); | 2711 PlayParameterRepository::getInstance()->addPlayable(model); |
2701 | 2712 |
2702 if (!getMainModel()) { | 2713 if (m_audioRecordMode == RecordReplaceSession || !getMainModel()) { |
2703 | 2714 |
2704 //!!! duplication with openAudio here | 2715 //!!! duplication with openAudio here |
2705 | 2716 |
2706 QString templateName = getDefaultSessionTemplate(); | 2717 QString templateName = getDefaultSessionTemplate(); |
2707 bool loadedTemplate = false; | 2718 bool loadedTemplate = false; |
3012 emit audioFileLoaded(); | 3023 emit audioFileLoaded(); |
3013 } | 3024 } |
3014 | 3025 |
3015 m_playSource->stop(); | 3026 m_playSource->stop(); |
3016 | 3027 |
3028 if (m_audioIO) m_audioIO->suspend(); | |
3029 | |
3017 if (m_paneStack && m_paneStack->getCurrentPane()) { | 3030 if (m_paneStack && m_paneStack->getCurrentPane()) { |
3018 updateVisibleRangeDisplay(m_paneStack->getCurrentPane()); | 3031 updateVisibleRangeDisplay(m_paneStack->getCurrentPane()); |
3019 } else { | 3032 } else { |
3020 m_myStatusMessage = ""; | 3033 m_myStatusMessage = ""; |
3021 getStatusLabel()->setText(""); | 3034 getStatusLabel()->setText(""); |
3345 remainingStr = (then - now).toText(true).c_str(); | 3358 remainingStr = (then - now).toText(true).c_str(); |
3346 } | 3359 } |
3347 | 3360 |
3348 m_myStatusMessage = tr("Playing: %1 of %2 (%3 remaining)") | 3361 m_myStatusMessage = tr("Playing: %1 of %2 (%3 remaining)") |
3349 .arg(nowStr).arg(thenStr).arg(remainingStr); | 3362 .arg(nowStr).arg(thenStr).arg(remainingStr); |
3363 | |
3364 getStatusLabel()->setText(m_myStatusMessage); | |
3365 } | |
3366 | |
3367 void | |
3368 MainWindowBase::recordDurationChanged(sv_frame_t frame, sv_samplerate_t rate) | |
3369 { | |
3370 RealTime duration = RealTime::frame2RealTime(frame, rate); | |
3371 QString durStr = duration.toSecText().c_str(); | |
3372 | |
3373 m_myStatusMessage = tr("Recording: %1").arg(durStr); | |
3350 | 3374 |
3351 getStatusLabel()->setText(m_myStatusMessage); | 3375 getStatusLabel()->setText(m_myStatusMessage); |
3352 } | 3376 } |
3353 | 3377 |
3354 void | 3378 void |
3611 } | 3635 } |
3612 #endif | 3636 #endif |
3613 #endif | 3637 #endif |
3614 } | 3638 } |
3615 | 3639 |
3616 | 3640 void |
3641 MainWindowBase::openLocalFolder(QString path) | |
3642 { | |
3643 QDir d(path); | |
3644 if (d.exists()) { | |
3645 QStringList args; | |
3646 QString path = d.canonicalPath(); | |
3647 #if defined Q_OS_WIN32 | |
3648 // Although the Win32 API is quite happy to have | |
3649 // forward slashes as directory separators, Windows | |
3650 // Explorer is not | |
3651 path = path.replace('/', '\\'); | |
3652 args << path; | |
3653 QProcess::execute("c:/windows/explorer.exe", args); | |
3654 #else | |
3655 args << path; | |
3656 QProcess::execute( | |
3657 #if defined Q_OS_MAC | |
3658 "/usr/bin/open", | |
3659 #else | |
3660 "/usr/bin/xdg-open", | |
3661 #endif | |
3662 args); | |
3663 #endif | |
3664 } | |
3665 } | |
3666 |