mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-14 07:37:43 +02:00
Move members from ControlToolBar into class ProjectAudioManager...
... and ControlToolBar is included in fewer places
This commit is contained in:
parent
977b46cda2
commit
13c2e4de0f
@ -785,9 +785,7 @@ private:
|
|||||||
auto &scrubber = Scrubber::Get( *pProject );
|
auto &scrubber = Scrubber::Get( *pProject );
|
||||||
scrubber.Cancel();
|
scrubber.Cancel();
|
||||||
|
|
||||||
auto &ctb = ControlToolBar::Get( *pProject );
|
ProjectAudioManager::Get( *pProject ).Stop();
|
||||||
wxCommandEvent evt;
|
|
||||||
ctb.OnStop(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -1588,8 +1586,8 @@ void AdornedRulerPanel::StartQPPlay(bool looped, bool cutPreview)
|
|||||||
bool startPlaying = (playRegion.GetStart() >= 0);
|
bool startPlaying = (playRegion.GetStart() >= 0);
|
||||||
|
|
||||||
if (startPlaying) {
|
if (startPlaying) {
|
||||||
auto &ctb = ControlToolBar::Get( *mProject );
|
auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
|
||||||
ctb.StopPlaying();
|
projectAudioManager.Stop();
|
||||||
|
|
||||||
bool loopEnabled = true;
|
bool loopEnabled = true;
|
||||||
double start, end;
|
double start, end;
|
||||||
@ -1630,7 +1628,7 @@ void AdornedRulerPanel::StartQPPlay(bool looped, bool cutPreview)
|
|||||||
playRegion.SetTimes( start, end );
|
playRegion.SetTimes( start, end );
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
||||||
ctb.PlayPlayRegion((SelectedRegion(start, end)),
|
projectAudioManager.PlayPlayRegion((SelectedRegion(start, end)),
|
||||||
options, mode,
|
options, mode,
|
||||||
false,
|
false,
|
||||||
true);
|
true);
|
||||||
@ -2111,8 +2109,7 @@ void AdornedRulerPanel::SetPlayRegion(double playRegionStart,
|
|||||||
|
|
||||||
void AdornedRulerPanel::ClearPlayRegion()
|
void AdornedRulerPanel::ClearPlayRegion()
|
||||||
{
|
{
|
||||||
auto &ctb = ControlToolBar::Get( *mProject );
|
ProjectAudioManager::Get( *mProject ).Stop();
|
||||||
ctb.StopPlaying();
|
|
||||||
|
|
||||||
auto &viewInfo = ViewInfo::Get( *GetProject() );
|
auto &viewInfo = ViewInfo::Get( *GetProject() );
|
||||||
auto &playRegion = viewInfo.playRegion;
|
auto &playRegion = viewInfo.playRegion;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "Prefs.h" // for RTL_WORKAROUND
|
#include "Prefs.h" // for RTL_WORKAROUND
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
#include "ProjectAudioIO.h"
|
#include "ProjectAudioIO.h"
|
||||||
|
#include "ProjectAudioManager.h"
|
||||||
#include "ProjectHistory.h"
|
#include "ProjectHistory.h"
|
||||||
#include "ProjectSettings.h"
|
#include "ProjectSettings.h"
|
||||||
#include "ProjectWindow.h"
|
#include "ProjectWindow.h"
|
||||||
@ -58,7 +59,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "commands/CommandManager.h"
|
#include "commands/CommandManager.h"
|
||||||
#include "toolbars/ControlToolBar.h"
|
|
||||||
|
|
||||||
// class MixerTrackSlider
|
// class MixerTrackSlider
|
||||||
|
|
||||||
@ -1353,7 +1353,7 @@ void MixerBoard::OnTimer(wxCommandEvent &event)
|
|||||||
auto gAudioIO = AudioIOBase::Get();
|
auto gAudioIO = AudioIOBase::Get();
|
||||||
UpdateMeters(
|
UpdateMeters(
|
||||||
gAudioIO->GetStreamTime(),
|
gAudioIO->GetStreamTime(),
|
||||||
(ControlToolBar::Get( *mProject ).GetLastPlayMode()
|
(ProjectAudioManager::Get( *mProject ).GetLastPlayMode()
|
||||||
== PlayMode::loopedPlay)
|
== PlayMode::loopedPlay)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -192,8 +192,7 @@ void ProjectAudioManager::OnSoundActivationThreshold()
|
|||||||
auto &project = mProject;
|
auto &project = mProject;
|
||||||
auto gAudioIO = AudioIO::Get();
|
auto gAudioIO = AudioIO::Get();
|
||||||
if ( gAudioIO && &project == gAudioIO->GetOwningProject() ) {
|
if ( gAudioIO && &project == gAudioIO->GetOwningProject() ) {
|
||||||
auto &bar = ControlToolBar::Get( project );
|
wxTheApp->CallAfter( [this]{ Pause(); } );
|
||||||
bar.CallAfter(&ControlToolBar::Pause);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,39 +345,31 @@ bool DoPlayStopSelect
|
|||||||
// "OnStopSelect" merged.
|
// "OnStopSelect" merged.
|
||||||
void DoPlayStopSelect(AudacityProject &project)
|
void DoPlayStopSelect(AudacityProject &project)
|
||||||
{
|
{
|
||||||
auto &toolbar = ControlToolBar::Get( project );
|
auto &projectAudioManager = ProjectAudioManager::Get( project );
|
||||||
wxCommandEvent evt;
|
|
||||||
auto gAudioIO = AudioIO::Get();
|
auto gAudioIO = AudioIO::Get();
|
||||||
if (DoPlayStopSelect(project, false, false))
|
if (DoPlayStopSelect(project, false, false))
|
||||||
toolbar.OnStop(evt);
|
projectAudioManager.Stop();
|
||||||
else if (!gAudioIO->IsBusy()) {
|
else if (!gAudioIO->IsBusy()) {
|
||||||
//Otherwise, start playing (assuming audio I/O isn't busy)
|
//Otherwise, start playing (assuming audio I/O isn't busy)
|
||||||
|
|
||||||
// Will automatically set mLastPlayMode
|
// Will automatically set mLastPlayMode
|
||||||
toolbar.PlayCurrentRegion(false);
|
projectAudioManager.PlayCurrentRegion(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoPause( AudacityProject &project )
|
void DoPause( AudacityProject &project )
|
||||||
{
|
{
|
||||||
wxCommandEvent evt;
|
ProjectAudioManager::Get( project ).OnPause();
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
|
||||||
controlToolBar.OnPause(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoRecord( AudacityProject &project )
|
void DoRecord( AudacityProject &project )
|
||||||
{
|
{
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
ProjectAudioManager::Get( project ).OnRecord(false);
|
||||||
controlToolBar.OnRecord(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoStop( AudacityProject &project )
|
void DoStop( AudacityProject &project )
|
||||||
{
|
{
|
||||||
wxCommandEvent evt;
|
ProjectAudioManager::Get( project ).Stop();
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
|
||||||
controlToolBar.OnStop(evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,28 @@ Paul Licameli split from ProjectManager.h
|
|||||||
#ifndef __AUDACITY_PROJECT_AUDIO_MANAGER__
|
#ifndef __AUDACITY_PROJECT_AUDIO_MANAGER__
|
||||||
#define __AUDACITY_PROJECT_AUDIO_MANAGER__
|
#define __AUDACITY_PROJECT_AUDIO_MANAGER__
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "AudioIOListener.h" // to inherit
|
#include "AudioIOListener.h" // to inherit
|
||||||
#include "ClientData.h" // to inherit
|
#include "ClientData.h" // to inherit
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
struct AudioIOStartStreamOptions;
|
struct AudioIOStartStreamOptions;
|
||||||
|
class TrackList;
|
||||||
|
class SelectedRegion;
|
||||||
|
|
||||||
|
class WaveTrack;
|
||||||
|
using WaveTrackArray = std::vector < std::shared_ptr < WaveTrack > >;
|
||||||
|
|
||||||
|
enum class PlayMode : int {
|
||||||
|
normalPlay,
|
||||||
|
oneSecondPlay, // Disables auto-scrolling
|
||||||
|
loopedPlay, // Disables auto-scrolling
|
||||||
|
cutPreviewPlay
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TransportTracks;
|
||||||
|
|
||||||
enum StatusBarField : int;
|
enum StatusBarField : int;
|
||||||
|
|
||||||
@ -28,6 +45,15 @@ public:
|
|||||||
static ProjectAudioManager &Get( AudacityProject &project );
|
static ProjectAudioManager &Get( AudacityProject &project );
|
||||||
static const ProjectAudioManager &Get( const AudacityProject &project );
|
static const ProjectAudioManager &Get( const AudacityProject &project );
|
||||||
|
|
||||||
|
// Find suitable tracks to record into, or return an empty array.
|
||||||
|
static WaveTrackArray ChooseExistingRecordingTracks(
|
||||||
|
AudacityProject &proj, bool selectedOnly);
|
||||||
|
|
||||||
|
static bool UseDuplex();
|
||||||
|
|
||||||
|
static TransportTracks GetAllPlaybackTracks(
|
||||||
|
TrackList &trackList, bool selectedOnly, bool useMidi = false);
|
||||||
|
|
||||||
explicit ProjectAudioManager( AudacityProject &project );
|
explicit ProjectAudioManager( AudacityProject &project );
|
||||||
ProjectAudioManager( const ProjectAudioManager & ) PROHIBITED;
|
ProjectAudioManager( const ProjectAudioManager & ) PROHIBITED;
|
||||||
ProjectAudioManager &operator=( const ProjectAudioManager & ) PROHIBITED;
|
ProjectAudioManager &operator=( const ProjectAudioManager & ) PROHIBITED;
|
||||||
@ -52,16 +78,52 @@ public:
|
|||||||
bool Looping() const { return mLooping; }
|
bool Looping() const { return mLooping; }
|
||||||
bool Cutting() const { return mCutting; }
|
bool Cutting() const { return mCutting; }
|
||||||
|
|
||||||
|
// A project is only allowed to stop an audio stream that it owns.
|
||||||
|
bool CanStopAudioStream () const;
|
||||||
|
|
||||||
|
void OnRecord(bool altAppearance);
|
||||||
|
|
||||||
|
bool DoRecord(AudacityProject &project,
|
||||||
|
const TransportTracks &transportTracks, // If captureTracks is empty, then tracks are created
|
||||||
|
double t0, double t1,
|
||||||
|
bool altAppearance,
|
||||||
|
const AudioIOStartStreamOptions &options);
|
||||||
|
|
||||||
|
int PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||||
|
const AudioIOStartStreamOptions &options,
|
||||||
|
PlayMode playMode,
|
||||||
|
bool backwards = false,
|
||||||
|
// Allow t0 and t1 to be beyond end of tracks
|
||||||
|
bool playWhiteSpace = false);
|
||||||
|
|
||||||
|
// Play currently selected region, or if nothing selected,
|
||||||
|
// play from current cursor.
|
||||||
|
void PlayCurrentRegion(bool looped = false, bool cutpreview = false);
|
||||||
|
|
||||||
|
void OnPause();
|
||||||
|
|
||||||
|
// Pause - used by AudioIO to pause sound activate recording
|
||||||
|
void Pause();
|
||||||
|
|
||||||
|
// Stop playing or recording
|
||||||
|
void Stop(bool stopStream = true);
|
||||||
|
|
||||||
|
PlayMode GetLastPlayMode() const { return mLastPlayMode; }
|
||||||
|
|
||||||
|
private:
|
||||||
void SetPaused( bool value ) { mPaused = value; }
|
void SetPaused( bool value ) { mPaused = value; }
|
||||||
void SetAppending( bool value ) { mAppending = value; }
|
void SetAppending( bool value ) { mAppending = value; }
|
||||||
void SetLooping( bool value ) { mLooping = value; }
|
void SetLooping( bool value ) { mLooping = value; }
|
||||||
void SetCutting( bool value ) { mCutting = value; }
|
void SetCutting( bool value ) { mCutting = value; }
|
||||||
void SetStopping( bool value ) { mStopping = value; }
|
void SetStopping( bool value ) { mStopping = value; }
|
||||||
|
|
||||||
// A project is only allowed to stop an audio stream that it owns.
|
void SetupCutPreviewTracks(double playStart, double cutStart,
|
||||||
bool CanStopAudioStream () const;
|
double cutEnd, double playEnd);
|
||||||
|
void ClearCutPreviewTracks();
|
||||||
|
|
||||||
|
// Cancel the addition of temporary recording tracks into the project
|
||||||
|
void CancelRecording();
|
||||||
|
|
||||||
private:
|
|
||||||
// Audio IO callback methods
|
// Audio IO callback methods
|
||||||
void OnAudioIORate(int rate) override;
|
void OnAudioIORate(int rate) override;
|
||||||
void OnAudioIOStartRecording() override;
|
void OnAudioIOStartRecording() override;
|
||||||
@ -72,6 +134,10 @@ private:
|
|||||||
|
|
||||||
AudacityProject &mProject;
|
AudacityProject &mProject;
|
||||||
|
|
||||||
|
std::shared_ptr<TrackList> mCutPreviewTracks;
|
||||||
|
|
||||||
|
PlayMode mLastPlayMode{ PlayMode::normalPlay };
|
||||||
|
|
||||||
//flag for cancellation of timer record.
|
//flag for cancellation of timer record.
|
||||||
bool mTimerRecordCanceled{ false };
|
bool mTimerRecordCanceled{ false };
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ Paul Licameli split from AudacityProject.cpp
|
|||||||
#include "import/ImportMIDI.h"
|
#include "import/ImportMIDI.h"
|
||||||
#include "ondemand/ODManager.h"
|
#include "ondemand/ODManager.h"
|
||||||
#include "prefs/QualityPrefs.h"
|
#include "prefs/QualityPrefs.h"
|
||||||
#include "toolbars/ControlToolBar.h"
|
|
||||||
#include "toolbars/MixerToolBar.h"
|
#include "toolbars/MixerToolBar.h"
|
||||||
#include "toolbars/SelectionBar.h"
|
#include "toolbars/SelectionBar.h"
|
||||||
#include "toolbars/SpectralSelectionBar.h"
|
#include "toolbars/SpectralSelectionBar.h"
|
||||||
@ -636,8 +635,7 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
|
|||||||
gAudioIO->IsStreamActive(projectAudioIO.GetAudioIOToken())) {
|
gAudioIO->IsStreamActive(projectAudioIO.GetAudioIOToken())) {
|
||||||
|
|
||||||
// We were playing or recording audio, but we've stopped the stream.
|
// We were playing or recording audio, but we've stopped the stream.
|
||||||
wxCommandEvent dummyEvent;
|
ProjectAudioManager::Get( project ).Stop();
|
||||||
ControlToolBar::Get( project ).OnStop(dummyEvent);
|
|
||||||
|
|
||||||
projectAudioIO.SetAudioIOToken(0);
|
projectAudioIO.SetAudioIOToken(0);
|
||||||
window.RedrawProject();
|
window.RedrawProject();
|
||||||
|
@ -54,6 +54,7 @@ is time to refresh some aspect of the screen.
|
|||||||
#include "KeyboardCapture.h"
|
#include "KeyboardCapture.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
#include "ProjectAudioIO.h"
|
#include "ProjectAudioIO.h"
|
||||||
|
#include "ProjectAudioManager.h"
|
||||||
#include "ProjectHistory.h"
|
#include "ProjectHistory.h"
|
||||||
#include "ProjectSettings.h"
|
#include "ProjectSettings.h"
|
||||||
#include "ProjectStatus.h"
|
#include "ProjectStatus.h"
|
||||||
@ -80,8 +81,6 @@ is time to refresh some aspect of the screen.
|
|||||||
#include "ondemand/ODManager.h"
|
#include "ondemand/ODManager.h"
|
||||||
#include "ondemand/ODTask.h"
|
#include "ondemand/ODTask.h"
|
||||||
|
|
||||||
#include "toolbars/ControlToolBar.h"
|
|
||||||
|
|
||||||
#include "tracks/ui/TrackControls.h"
|
#include "tracks/ui/TrackControls.h"
|
||||||
#include "tracks/ui/TrackView.h"
|
#include "tracks/ui/TrackView.h"
|
||||||
#include "tracks/ui/TrackVRulerControls.h"
|
#include "tracks/ui/TrackVRulerControls.h"
|
||||||
@ -422,8 +421,8 @@ void TrackPanel::OnTimer(wxTimerEvent& )
|
|||||||
{
|
{
|
||||||
//the stream may have been started up after this one finished (by some other project)
|
//the stream may have been started up after this one finished (by some other project)
|
||||||
//in that case reset the buttons don't stop the stream
|
//in that case reset the buttons don't stop the stream
|
||||||
auto &bar = ControlToolBar::Get( *p );
|
auto &projectAudioManager = ProjectAudioManager::Get( *p );
|
||||||
bar.StopPlaying(!gAudioIO->IsStreamActive());
|
projectAudioManager.Stop(!gAudioIO->IsStreamActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, check to see if we were playing or recording
|
// Next, check to see if we were playing or recording
|
||||||
|
@ -64,7 +64,6 @@ greater use in future.
|
|||||||
#include "../ViewInfo.h"
|
#include "../ViewInfo.h"
|
||||||
#include "../WaveTrack.h"
|
#include "../WaveTrack.h"
|
||||||
#include "../commands/Command.h"
|
#include "../commands/Command.h"
|
||||||
#include "../toolbars/ControlToolBar.h"
|
|
||||||
#include "../widgets/AButton.h"
|
#include "../widgets/AButton.h"
|
||||||
#include "../widgets/ProgressDialog.h"
|
#include "../widgets/ProgressDialog.h"
|
||||||
#include "../ondemand/ODManager.h"
|
#include "../ondemand/ODManager.h"
|
||||||
@ -2409,7 +2408,7 @@ void Effect::Preview(bool dryOnly)
|
|||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
auto tracks = GetAllPlaybackTracks(*mTracks, true);
|
auto tracks = ProjectAudioManager::GetAllPlaybackTracks(*mTracks, true);
|
||||||
|
|
||||||
// Some effects (Paulstretch) may need to generate more
|
// Some effects (Paulstretch) may need to generate more
|
||||||
// than previewLen, so take the min.
|
// than previewLen, so take the min.
|
||||||
@ -3296,8 +3295,8 @@ void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt))
|
|||||||
{
|
{
|
||||||
auto gAudioIO = AudioIO::Get();
|
auto gAudioIO = AudioIO::Get();
|
||||||
mPlayPos = gAudioIO->GetStreamTime();
|
mPlayPos = gAudioIO->GetStreamTime();
|
||||||
auto &bar = ControlToolBar::Get( *mProject );
|
auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
|
||||||
bar.StopPlaying();
|
projectAudioManager.Stop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3321,8 +3320,8 @@ void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt))
|
|||||||
mPlayPos = mRegion.t1();
|
mPlayPos = mRegion.t1();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &bar = ControlToolBar::Get( *mProject );
|
auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
|
||||||
bar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(mPlayPos, mRegion.t1()),
|
SelectedRegion(mPlayPos, mRegion.t1()),
|
||||||
DefaultPlayOptions( *mProject ),
|
DefaultPlayOptions( *mProject ),
|
||||||
PlayMode::normalPlay );
|
PlayMode::normalPlay );
|
||||||
|
@ -84,6 +84,7 @@ enum {
|
|||||||
void DoPlayStop(const CommandContext &context)
|
void DoPlayStop(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
|
auto &projectAudioManager = ProjectAudioManager::Get( project );
|
||||||
auto &toolbar = ControlToolBar::Get( project );
|
auto &toolbar = ControlToolBar::Get( project );
|
||||||
auto &window = ProjectWindow::Get( project );
|
auto &window = ProjectWindow::Get( project );
|
||||||
auto token = ProjectAudioIO::Get( project ).GetAudioIOToken();
|
auto token = ProjectAudioIO::Get( project ).GetAudioIOToken();
|
||||||
@ -92,7 +93,7 @@ void DoPlayStop(const CommandContext &context)
|
|||||||
auto gAudioIO = AudioIOBase::Get();
|
auto gAudioIO = AudioIOBase::Get();
|
||||||
if (gAudioIO->IsStreamActive(token)) {
|
if (gAudioIO->IsStreamActive(token)) {
|
||||||
toolbar.SetStop(); //Pushes stop down
|
toolbar.SetStop(); //Pushes stop down
|
||||||
toolbar.StopPlaying();
|
projectAudioManager.Stop();
|
||||||
}
|
}
|
||||||
else if (gAudioIO->IsStreamActive()) {
|
else if (gAudioIO->IsStreamActive()) {
|
||||||
// If this project isn't playing, but another one is, stop playing the
|
// If this project isn't playing, but another one is, stop playing the
|
||||||
@ -109,8 +110,10 @@ void DoPlayStop(const CommandContext &context)
|
|||||||
if(iter != finish) {
|
if(iter != finish) {
|
||||||
auto otherProject = *iter;
|
auto otherProject = *iter;
|
||||||
auto &otherToolbar = ControlToolBar::Get( *otherProject );
|
auto &otherToolbar = ControlToolBar::Get( *otherProject );
|
||||||
|
auto &otherProjectAudioManager =
|
||||||
|
ProjectAudioManager::Get( *otherProject );
|
||||||
otherToolbar.SetStop(); //Pushes stop down
|
otherToolbar.SetStop(); //Pushes stop down
|
||||||
otherToolbar.StopPlaying();
|
otherProjectAudioManager.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//play the front project
|
//play the front project
|
||||||
@ -120,14 +123,14 @@ void DoPlayStop(const CommandContext &context)
|
|||||||
//Otherwise, start playing (assuming audio I/O isn't busy)
|
//Otherwise, start playing (assuming audio I/O isn't busy)
|
||||||
|
|
||||||
// Will automatically set mLastPlayMode
|
// Will automatically set mLastPlayMode
|
||||||
toolbar.PlayCurrentRegion(false);
|
projectAudioManager.PlayCurrentRegion(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!gAudioIO->IsBusy()) {
|
else if (!gAudioIO->IsBusy()) {
|
||||||
//Otherwise, start playing (assuming audio I/O isn't busy)
|
//Otherwise, start playing (assuming audio I/O isn't busy)
|
||||||
|
|
||||||
// Will automatically set mLastPlayMode
|
// Will automatically set mLastPlayMode
|
||||||
toolbar.PlayCurrentRegion(false);
|
projectAudioManager.PlayCurrentRegion(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +219,7 @@ void OnPlayLooped(const CommandContext &context)
|
|||||||
|
|
||||||
// Now play in a loop
|
// Now play in a loop
|
||||||
// Will automatically set mLastPlayMode
|
// Will automatically set mLastPlayMode
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
ProjectAudioManager::Get( project ).PlayCurrentRegion(true);
|
||||||
controlToolBar.PlayCurrentRegion(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPause(const CommandContext &context)
|
void OnPause(const CommandContext &context)
|
||||||
@ -235,8 +237,7 @@ void OnRecord(const CommandContext &context)
|
|||||||
void OnRecord2ndChoice(const CommandContext &context)
|
void OnRecord2ndChoice(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
ProjectAudioManager::Get( project ).OnRecord(true);
|
||||||
controlToolBar.OnRecord(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTimerRecord(const CommandContext &context)
|
void OnTimerRecord(const CommandContext &context)
|
||||||
@ -353,8 +354,8 @@ void OnPunchAndRoll(const CommandContext &context)
|
|||||||
double t1 = std::max(0.0, viewInfo.selectedRegion.t1());
|
double t1 = std::max(0.0, viewInfo.selectedRegion.t1());
|
||||||
|
|
||||||
// Decide which tracks to record in.
|
// Decide which tracks to record in.
|
||||||
auto &bar = ControlToolBar::Get( project );
|
auto tracks =
|
||||||
auto tracks = bar.ChooseExistingRecordingTracks(project, true);
|
ProjectAudioManager::ChooseExistingRecordingTracks(project, true);
|
||||||
if (tracks.empty()) {
|
if (tracks.empty()) {
|
||||||
int recordingChannels =
|
int recordingChannels =
|
||||||
std::max(0L, gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2));
|
std::max(0L, gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2));
|
||||||
@ -433,11 +434,12 @@ void OnPunchAndRoll(const CommandContext &context)
|
|||||||
|
|
||||||
// Choose the tracks for playback.
|
// Choose the tracks for playback.
|
||||||
TransportTracks transportTracks;
|
TransportTracks transportTracks;
|
||||||
const auto duplex = ControlToolBar::UseDuplex();
|
const auto duplex = ProjectAudioManager::UseDuplex();
|
||||||
if (duplex)
|
if (duplex)
|
||||||
// play all
|
// play all
|
||||||
transportTracks =
|
transportTracks =
|
||||||
GetAllPlaybackTracks( TrackList::Get( project ), false, true);
|
ProjectAudioManager::GetAllPlaybackTracks(
|
||||||
|
TrackList::Get( project ), false, true);
|
||||||
else
|
else
|
||||||
// play recording tracks only
|
// play recording tracks only
|
||||||
std::copy(tracks.begin(), tracks.end(),
|
std::copy(tracks.begin(), tracks.end(),
|
||||||
@ -452,7 +454,7 @@ void OnPunchAndRoll(const CommandContext &context)
|
|||||||
options.preRoll = std::max(0L,
|
options.preRoll = std::max(0L,
|
||||||
gPrefs->Read(AUDIO_PRE_ROLL_KEY, DEFAULT_PRE_ROLL_SECONDS));
|
gPrefs->Read(AUDIO_PRE_ROLL_KEY, DEFAULT_PRE_ROLL_SECONDS));
|
||||||
options.pCrossfadeData = &crossfadeData;
|
options.pCrossfadeData = &crossfadeData;
|
||||||
bool success = ControlToolBar::Get( project ).DoRecord(project,
|
bool success = ProjectAudioManager::Get( project ).DoRecord(project,
|
||||||
transportTracks,
|
transportTracks,
|
||||||
t1, DBL_MAX,
|
t1, DBL_MAX,
|
||||||
false, // altAppearance
|
false, // altAppearance
|
||||||
@ -551,11 +553,10 @@ void OnPlayOneSecond(const CommandContext &context)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
auto &trackPanel = TrackPanel::Get( project );
|
auto &trackPanel = TrackPanel::Get( project );
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
|
||||||
auto options = DefaultPlayOptions( project );
|
auto options = DefaultPlayOptions( project );
|
||||||
|
|
||||||
double pos = trackPanel.GetMostRecentXPos();
|
double pos = trackPanel.GetMostRecentXPos();
|
||||||
controlToolBar.PlayPlayRegion(
|
ProjectAudioManager::Get( project ).PlayPlayRegion(
|
||||||
SelectedRegion(pos - 0.5, pos + 0.5), options,
|
SelectedRegion(pos - 0.5, pos + 0.5), options,
|
||||||
PlayMode::oneSecondPlay);
|
PlayMode::oneSecondPlay);
|
||||||
}
|
}
|
||||||
@ -604,10 +605,9 @@ void OnPlayToSelection(const CommandContext &context)
|
|||||||
// only when playing a short region, less than or equal to a second.
|
// only when playing a short region, less than or equal to a second.
|
||||||
// mLastPlayMode = ((t1-t0) > 1.0) ? normalPlay : oneSecondPlay;
|
// mLastPlayMode = ((t1-t0) > 1.0) ? normalPlay : oneSecondPlay;
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
|
||||||
auto playOptions = DefaultPlayOptions( project );
|
auto playOptions = DefaultPlayOptions( project );
|
||||||
|
|
||||||
controlToolBar.PlayPlayRegion(
|
ProjectAudioManager::Get( project ).PlayPlayRegion(
|
||||||
SelectedRegion(t0, t1), playOptions, PlayMode::oneSecondPlay);
|
SelectedRegion(t0, t1), playOptions, PlayMode::oneSecondPlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,10 +628,9 @@ void OnPlayBeforeSelectionStart(const CommandContext &context)
|
|||||||
double beforeLen;
|
double beforeLen;
|
||||||
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
|
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
|
||||||
auto playOptions = DefaultPlayOptions( project );
|
auto playOptions = DefaultPlayOptions( project );
|
||||||
|
|
||||||
controlToolBar.PlayPlayRegion(
|
ProjectAudioManager::Get( project ).PlayPlayRegion(
|
||||||
SelectedRegion(t0 - beforeLen, t0), playOptions, PlayMode::oneSecondPlay);
|
SelectedRegion(t0 - beforeLen, t0), playOptions, PlayMode::oneSecondPlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,14 +649,14 @@ void OnPlayAfterSelectionStart(const CommandContext &context)
|
|||||||
double afterLen;
|
double afterLen;
|
||||||
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
auto &projectAudioManager = ProjectAudioManager::Get( project );
|
||||||
auto playOptions = DefaultPlayOptions( project );
|
auto playOptions = DefaultPlayOptions( project );
|
||||||
|
|
||||||
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
|
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
|
||||||
controlToolBar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(t0, t1), playOptions, PlayMode::oneSecondPlay);
|
SelectedRegion(t0, t1), playOptions, PlayMode::oneSecondPlay);
|
||||||
else
|
else
|
||||||
controlToolBar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(t0, t0 + afterLen), playOptions,
|
SelectedRegion(t0, t0 + afterLen), playOptions,
|
||||||
PlayMode::oneSecondPlay);
|
PlayMode::oneSecondPlay);
|
||||||
}
|
}
|
||||||
@ -677,14 +676,14 @@ void OnPlayBeforeSelectionEnd(const CommandContext &context)
|
|||||||
double beforeLen;
|
double beforeLen;
|
||||||
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
|
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
auto &projectAudioManager = ProjectAudioManager::Get( project );
|
||||||
auto playOptions = DefaultPlayOptions( project );
|
auto playOptions = DefaultPlayOptions( project );
|
||||||
|
|
||||||
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
|
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
|
||||||
controlToolBar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(t0, t1), playOptions, PlayMode::oneSecondPlay);
|
SelectedRegion(t0, t1), playOptions, PlayMode::oneSecondPlay);
|
||||||
else
|
else
|
||||||
controlToolBar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(t1 - beforeLen, t1), playOptions,
|
SelectedRegion(t1 - beforeLen, t1), playOptions,
|
||||||
PlayMode::oneSecondPlay);
|
PlayMode::oneSecondPlay);
|
||||||
}
|
}
|
||||||
@ -704,10 +703,9 @@ void OnPlayAfterSelectionEnd(const CommandContext &context)
|
|||||||
double afterLen;
|
double afterLen;
|
||||||
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
|
||||||
auto playOptions = DefaultPlayOptions( project );
|
auto playOptions = DefaultPlayOptions( project );
|
||||||
|
|
||||||
controlToolBar.PlayPlayRegion(
|
ProjectAudioManager::Get( project ).PlayPlayRegion(
|
||||||
SelectedRegion(t1, t1 + afterLen), playOptions, PlayMode::oneSecondPlay);
|
SelectedRegion(t1, t1 + afterLen), playOptions, PlayMode::oneSecondPlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,15 +727,15 @@ void OnPlayBeforeAndAfterSelectionStart
|
|||||||
double afterLen;
|
double afterLen;
|
||||||
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
auto &projectAudioManager = ProjectAudioManager::Get( project );
|
||||||
auto playOptions = DefaultPlayOptions( project );
|
auto playOptions = DefaultPlayOptions( project );
|
||||||
|
|
||||||
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
|
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
|
||||||
controlToolBar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(t0 - beforeLen, t1), playOptions,
|
SelectedRegion(t0 - beforeLen, t1), playOptions,
|
||||||
PlayMode::oneSecondPlay);
|
PlayMode::oneSecondPlay);
|
||||||
else
|
else
|
||||||
controlToolBar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(t0 - beforeLen, t0 + afterLen), playOptions,
|
SelectedRegion(t0 - beforeLen, t0 + afterLen), playOptions,
|
||||||
PlayMode::oneSecondPlay);
|
PlayMode::oneSecondPlay);
|
||||||
}
|
}
|
||||||
@ -760,15 +758,15 @@ void OnPlayBeforeAndAfterSelectionEnd
|
|||||||
double afterLen;
|
double afterLen;
|
||||||
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
|
||||||
|
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
auto &projectAudioManager = ProjectAudioManager::Get( project );
|
||||||
auto playOptions = DefaultPlayOptions( project );
|
auto playOptions = DefaultPlayOptions( project );
|
||||||
|
|
||||||
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
|
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
|
||||||
controlToolBar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(t0, t1 + afterLen), playOptions,
|
SelectedRegion(t0, t1 + afterLen), playOptions,
|
||||||
PlayMode::oneSecondPlay);
|
PlayMode::oneSecondPlay);
|
||||||
else
|
else
|
||||||
controlToolBar.PlayPlayRegion(
|
projectAudioManager.PlayPlayRegion(
|
||||||
SelectedRegion(t1 - beforeLen, t1 + afterLen), playOptions,
|
SelectedRegion(t1 - beforeLen, t1 + afterLen), playOptions,
|
||||||
PlayMode::oneSecondPlay);
|
PlayMode::oneSecondPlay);
|
||||||
}
|
}
|
||||||
@ -782,8 +780,9 @@ void OnPlayCutPreview(const CommandContext &context)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Play with cut preview
|
// Play with cut preview
|
||||||
auto &controlToolBar = ControlToolBar::Get( project );
|
ProjectAudioManager::Get( project ).PlayCurrentRegion(
|
||||||
controlToolBar.PlayCurrentRegion(false, true);
|
false, true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPlayAtSpeed(const CommandContext &context)
|
void OnPlayAtSpeed(const CommandContext &context)
|
||||||
@ -866,13 +865,11 @@ void OnStopSelect(const CommandContext &context)
|
|||||||
auto &history = ProjectHistory::Get( project );
|
auto &history = ProjectHistory::Get( project );
|
||||||
auto &viewInfo = project.GetViewInfo();
|
auto &viewInfo = project.GetViewInfo();
|
||||||
auto &selectedRegion = viewInfo.selectedRegion;
|
auto &selectedRegion = viewInfo.selectedRegion;
|
||||||
wxCommandEvent evt;
|
|
||||||
|
|
||||||
auto gAudioIO = AudioIOBase::Get();
|
auto gAudioIO = AudioIOBase::Get();
|
||||||
if (gAudioIO->IsStreamActive()) {
|
if (gAudioIO->IsStreamActive()) {
|
||||||
auto &controlToolbar = ControlToolBar::Get( project );
|
|
||||||
selectedRegion.setT0(gAudioIO->GetStreamTime(), false);
|
selectedRegion.setT0(gAudioIO->GetStreamTime(), false);
|
||||||
controlToolBar.OnStop(evt);
|
ProjectAudioManager::Get( project ).Stop();
|
||||||
history.ModifyState(false); // without bWantsAutoSave
|
history.ModifyState(false); // without bWantsAutoSave
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,9 +85,6 @@
|
|||||||
|
|
||||||
IMPLEMENT_CLASS(ControlToolBar, ToolBar);
|
IMPLEMENT_CLASS(ControlToolBar, ToolBar);
|
||||||
|
|
||||||
//static
|
|
||||||
AudacityProject *ControlToolBar::mBusyProject = NULL;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Methods for ControlToolBar
|
/// Methods for ControlToolBar
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -528,14 +525,14 @@ void ControlToolBar::SetStop()
|
|||||||
EnableDisableButtons();
|
EnableDisableButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
int ProjectAudioManager::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||||
const AudioIOStartStreamOptions &options,
|
const AudioIOStartStreamOptions &options,
|
||||||
PlayMode mode,
|
PlayMode mode,
|
||||||
bool backwards, /* = false */
|
bool backwards, /* = false */
|
||||||
bool playWhiteSpace /* = false */)
|
bool playWhiteSpace /* = false */)
|
||||||
// STRONG-GUARANTEE (for state of mCutPreviewTracks)
|
// STRONG-GUARANTEE (for state of mCutPreviewTracks)
|
||||||
{
|
{
|
||||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
auto &projectAudioManager = *this;
|
||||||
bool canStop = projectAudioManager.CanStopAudioStream();
|
bool canStop = projectAudioManager.CanStopAudioStream();
|
||||||
|
|
||||||
if ( !canStop )
|
if ( !canStop )
|
||||||
@ -674,7 +671,6 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
|||||||
if (token != 0) {
|
if (token != 0) {
|
||||||
success = true;
|
success = true;
|
||||||
ProjectAudioIO::Get( *p ).SetAudioIOToken(token);
|
ProjectAudioIO::Get( *p ).SetAudioIOToken(token);
|
||||||
mBusyProject = p;
|
|
||||||
#if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
|
#if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
|
||||||
//AC: If init_seek was set, now's the time to make it happen.
|
//AC: If init_seek was set, now's the time to make it happen.
|
||||||
gAudioIO->SeekStream(init_seek);
|
gAudioIO->SeekStream(init_seek);
|
||||||
@ -686,9 +682,10 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
|||||||
// Problem was that the error dialog yields to events,
|
// Problem was that the error dialog yields to events,
|
||||||
// causing recursion to this function in the scrub timer
|
// causing recursion to this function in the scrub timer
|
||||||
// handler! Easy fix, just delay the user alert instead.
|
// handler! Easy fix, just delay the user alert instead.
|
||||||
CallAfter( [=]{
|
auto &window = GetProjectFrame( mProject );
|
||||||
|
window.CallAfter( [&]{
|
||||||
// Show error message if stream could not be opened
|
// Show error message if stream could not be opened
|
||||||
ShowErrorDialog(this, _("Error"),
|
ShowErrorDialog(&window, _("Error"),
|
||||||
_("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
|
_("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
|
||||||
wxT("Error_opening_sound_device"));
|
wxT("Error_opening_sound_device"));
|
||||||
});
|
});
|
||||||
@ -701,10 +698,10 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
|||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
|
void ProjectAudioManager::PlayCurrentRegion(bool looped /* = false */,
|
||||||
bool cutpreview /* = false */)
|
bool cutpreview /* = false */)
|
||||||
{
|
{
|
||||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
auto &projectAudioManager = *this;
|
||||||
bool canStop = projectAudioManager.CanStopAudioStream();
|
bool canStop = projectAudioManager.CanStopAudioStream();
|
||||||
|
|
||||||
if ( !canStop )
|
if ( !canStop )
|
||||||
@ -751,10 +748,10 @@ void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
|
|||||||
if (event.GetKeyCode() == WXK_SPACE) {
|
if (event.GetKeyCode() == WXK_SPACE) {
|
||||||
if ( projectAudioManager.Playing() || projectAudioManager.Recording() ) {
|
if ( projectAudioManager.Playing() || projectAudioManager.Recording() ) {
|
||||||
SetStop();
|
SetStop();
|
||||||
StopPlaying();
|
projectAudioManager.Stop();
|
||||||
}
|
}
|
||||||
else if (!gAudioIO->IsBusy()) {
|
else if (!gAudioIO->IsBusy()) {
|
||||||
PlayCurrentRegion();
|
projectAudioManager.PlayCurrentRegion();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -770,7 +767,7 @@ void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
|
|||||||
if ( !canStop )
|
if ( !canStop )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StopPlaying();
|
projectAudioManager.Stop();
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
ProjectWindow::Get( *p ).TP_DisplaySelection();
|
ProjectWindow::Get( *p ).TP_DisplaySelection();
|
||||||
@ -784,7 +781,7 @@ void ControlToolBar::OnStop(wxCommandEvent & WXUNUSED(evt))
|
|||||||
bool canStop = projectAudioManager.CanStopAudioStream();
|
bool canStop = projectAudioManager.CanStopAudioStream();
|
||||||
|
|
||||||
if ( canStop ) {
|
if ( canStop ) {
|
||||||
StopPlaying();
|
projectAudioManager.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,24 +791,24 @@ void ControlToolBar::PlayDefault()
|
|||||||
const bool cutPreview = mPlay->WasControlDown();
|
const bool cutPreview = mPlay->WasControlDown();
|
||||||
const bool looped = !cutPreview &&
|
const bool looped = !cutPreview &&
|
||||||
mPlay->WasShiftDown();
|
mPlay->WasShiftDown();
|
||||||
PlayCurrentRegion(looped, cutPreview);
|
ProjectAudioManager::Get( mProject ).PlayCurrentRegion(looped, cutPreview);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
void ProjectAudioManager::Stop(bool stopStream /* = true*/)
|
||||||
{
|
{
|
||||||
AudacityProject *project = &mProject;
|
AudacityProject *project = &mProject;
|
||||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
auto &projectAudioManager = *this;
|
||||||
bool canStop = projectAudioManager.CanStopAudioStream();
|
bool canStop = projectAudioManager.CanStopAudioStream();
|
||||||
|
|
||||||
|
if ( !canStop )
|
||||||
|
return;
|
||||||
|
|
||||||
if(project) {
|
if(project) {
|
||||||
// Let scrubbing code do some appearance change
|
// Let scrubbing code do some appearance change
|
||||||
auto &scrubber = Scrubber::Get( *project );
|
auto &scrubber = Scrubber::Get( *project );
|
||||||
scrubber.StopScrubbing();
|
scrubber.StopScrubbing();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !canStop )
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto gAudioIO = AudioIO::Get();
|
auto gAudioIO = AudioIO::Get();
|
||||||
|
|
||||||
auto cleanup = finally( [&]{
|
auto cleanup = finally( [&]{
|
||||||
@ -842,7 +839,6 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
|||||||
|
|
||||||
ClearCutPreviewTracks();
|
ClearCutPreviewTracks();
|
||||||
|
|
||||||
mBusyProject = NULL;
|
|
||||||
// So that we continue monitoring after playing or recording.
|
// So that we continue monitoring after playing or recording.
|
||||||
// also clean the MeterQueues
|
// also clean the MeterQueues
|
||||||
if( project ) {
|
if( project ) {
|
||||||
@ -862,9 +858,9 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
|||||||
toolbar->EnableDisableButtons();
|
toolbar->EnableDisableButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::Pause()
|
void ProjectAudioManager::Pause()
|
||||||
{
|
{
|
||||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
auto &projectAudioManager = *this;
|
||||||
bool canStop = projectAudioManager.CanStopAudioStream();
|
bool canStop = projectAudioManager.CanStopAudioStream();
|
||||||
|
|
||||||
if ( !canStop ) {
|
if ( !canStop ) {
|
||||||
@ -872,12 +868,11 @@ void ControlToolBar::Pause()
|
|||||||
gAudioIO->SetPaused(!gAudioIO->IsPaused());
|
gAudioIO->SetPaused(!gAudioIO->IsPaused());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wxCommandEvent dummy;
|
OnPause();
|
||||||
OnPause(dummy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveTrackArray ControlToolBar::ChooseExistingRecordingTracks(
|
WaveTrackArray ProjectAudioManager::ChooseExistingRecordingTracks(
|
||||||
AudacityProject &proj, bool selectedOnly)
|
AudacityProject &proj, bool selectedOnly)
|
||||||
{
|
{
|
||||||
auto p = &proj;
|
auto p = &proj;
|
||||||
@ -958,10 +953,10 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
// normally used for buttons.
|
// normally used for buttons.
|
||||||
|
|
||||||
bool altAppearance = mRecord->WasShiftDown();
|
bool altAppearance = mRecord->WasShiftDown();
|
||||||
OnRecord( altAppearance );
|
ProjectAudioManager::Get( mProject ).OnRecord( altAppearance );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::OnRecord(bool altAppearance)
|
void ProjectAudioManager::OnRecord(bool altAppearance)
|
||||||
// STRONG-GUARANTEE (for state of current project's tracks)
|
// STRONG-GUARANTEE (for state of current project's tracks)
|
||||||
{
|
{
|
||||||
bool bPreferNewTrack;
|
bool bPreferNewTrack;
|
||||||
@ -1027,7 +1022,7 @@ void ControlToolBar::OnRecord(bool altAppearance)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ControlToolBar::UseDuplex()
|
bool ProjectAudioManager::UseDuplex()
|
||||||
{
|
{
|
||||||
bool duplex;
|
bool duplex;
|
||||||
gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex,
|
gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex,
|
||||||
@ -1040,13 +1035,13 @@ bool ControlToolBar::UseDuplex()
|
|||||||
return duplex;
|
return duplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ControlToolBar::DoRecord(AudacityProject &project,
|
bool ProjectAudioManager::DoRecord(AudacityProject &project,
|
||||||
const TransportTracks &tracks,
|
const TransportTracks &tracks,
|
||||||
double t0, double t1,
|
double t0, double t1,
|
||||||
bool altAppearance,
|
bool altAppearance,
|
||||||
const AudioIOStartStreamOptions &options)
|
const AudioIOStartStreamOptions &options)
|
||||||
{
|
{
|
||||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
auto &projectAudioManager = *this;
|
||||||
|
|
||||||
CommandFlag flags = AlwaysEnabledFlag; // 0 means recalc flags.
|
CommandFlag flags = AlwaysEnabledFlag; // 0 means recalc flags.
|
||||||
|
|
||||||
@ -1216,14 +1211,14 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
ProjectAudioIO::Get( *p ).SetAudioIOToken(token);
|
ProjectAudioIO::Get( *p ).SetAudioIOToken(token);
|
||||||
mBusyProject = p;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CancelRecording();
|
CancelRecording();
|
||||||
|
|
||||||
// Show error message if stream could not be opened
|
// Show error message if stream could not be opened
|
||||||
wxString msg = wxString::Format(_("Error opening recording device.\nError code: %s"), gAudioIO->LastPaErrorString());
|
wxString msg = wxString::Format(_("Error opening recording device.\nError code: %s"), gAudioIO->LastPaErrorString());
|
||||||
ShowErrorDialog(this, _("Error"), msg, wxT("Error_opening_sound_device"));
|
ShowErrorDialog(&GetProjectFrame( mProject ),
|
||||||
|
_("Error"), msg, wxT("Error_opening_sound_device"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,7 +1228,13 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
|||||||
|
|
||||||
void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
ProjectAudioManager::Get( mProject ).OnPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProjectAudioManager::OnPause()
|
||||||
|
{
|
||||||
|
auto &projectAudioManager = *this;
|
||||||
bool canStop = projectAudioManager.CanStopAudioStream();
|
bool canStop = projectAudioManager.CanStopAudioStream();
|
||||||
|
|
||||||
if ( !canStop ) {
|
if ( !canStop ) {
|
||||||
@ -1257,8 +1258,7 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
|||||||
!scrubber.IsSpeedPlaying();
|
!scrubber.IsSpeedPlaying();
|
||||||
|
|
||||||
if (bStopInstead) {
|
if (bStopInstead) {
|
||||||
wxCommandEvent dummy;
|
Stop();
|
||||||
OnStop(dummy);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1353,7 +1353,7 @@ void ControlToolBar::OnFF(wxCommandEvent & WXUNUSED(evt))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::SetupCutPreviewTracks(double WXUNUSED(playStart), double cutStart,
|
void ProjectAudioManager::SetupCutPreviewTracks(double WXUNUSED(playStart), double cutStart,
|
||||||
double cutEnd, double WXUNUSED(playEnd))
|
double cutEnd, double WXUNUSED(playEnd))
|
||||||
|
|
||||||
// STRONG-GUARANTEE (for state of mCutPreviewTracks)
|
// STRONG-GUARANTEE (for state of mCutPreviewTracks)
|
||||||
@ -1378,7 +1378,7 @@ void ControlToolBar::SetupCutPreviewTracks(double WXUNUSED(playStart), double cu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::ClearCutPreviewTracks()
|
void ProjectAudioManager::ClearCutPreviewTracks()
|
||||||
{
|
{
|
||||||
if (mCutPreviewTracks)
|
if (mCutPreviewTracks)
|
||||||
mCutPreviewTracks->Clear();
|
mCutPreviewTracks->Clear();
|
||||||
@ -1521,7 +1521,7 @@ void ControlToolBar::StopScrolling()
|
|||||||
(ProjectWindow::PlaybackScroller::Mode::Off);
|
(ProjectWindow::PlaybackScroller::Mode::Off);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlToolBar::CancelRecording()
|
void ProjectAudioManager::CancelRecording()
|
||||||
{
|
{
|
||||||
const auto project = &mProject;
|
const auto project = &mProject;
|
||||||
TrackList::Get( *project ).ClearPendingTracks();
|
TrackList::Get( *project ).ClearPendingTracks();
|
||||||
@ -1531,7 +1531,8 @@ void ControlToolBar::CancelRecording()
|
|||||||
#include "../NoteTrack.h"
|
#include "../NoteTrack.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bool useMidi)
|
TransportTracks ProjectAudioManager::GetAllPlaybackTracks(
|
||||||
|
TrackList &trackList, bool selectedOnly, bool useMidi)
|
||||||
{
|
{
|
||||||
TransportTracks result;
|
TransportTracks result;
|
||||||
{
|
{
|
||||||
|
@ -27,24 +27,6 @@ class wxStatusBar;
|
|||||||
|
|
||||||
class AButton;
|
class AButton;
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
class TrackList;
|
|
||||||
|
|
||||||
struct AudioIOStartStreamOptions;
|
|
||||||
class SelectedRegion;
|
|
||||||
|
|
||||||
enum class PlayMode : int {
|
|
||||||
normalPlay,
|
|
||||||
oneSecondPlay, // Disables auto-scrolling
|
|
||||||
loopedPlay, // Disables auto-scrolling
|
|
||||||
cutPreviewPlay
|
|
||||||
};
|
|
||||||
|
|
||||||
class WaveTrack;
|
|
||||||
using WaveTrackArray = std::vector < std::shared_ptr < WaveTrack > >;
|
|
||||||
|
|
||||||
struct TransportTracks;
|
|
||||||
TransportTracks GetAllPlaybackTracks(
|
|
||||||
TrackList &trackList, bool selectedOnly, bool useMidi = false);
|
|
||||||
|
|
||||||
// In the GUI, ControlToolBar appears as the "Transport Toolbar". "Control Toolbar" is historic.
|
// In the GUI, ControlToolBar appears as the "Transport Toolbar". "Control Toolbar" is historic.
|
||||||
class ControlToolBar final : public ToolBar {
|
class ControlToolBar final : public ToolBar {
|
||||||
@ -65,24 +47,12 @@ class ControlToolBar final : public ToolBar {
|
|||||||
void UpdatePrefs() override;
|
void UpdatePrefs() override;
|
||||||
void OnKeyEvent(wxKeyEvent & event);
|
void OnKeyEvent(wxKeyEvent & event);
|
||||||
|
|
||||||
// Find suitable tracks to record into, or return an empty array.
|
|
||||||
static WaveTrackArray ChooseExistingRecordingTracks(AudacityProject &proj, bool selectedOnly);
|
|
||||||
|
|
||||||
static bool UseDuplex();
|
|
||||||
|
|
||||||
// msmeyer: These are public, but it's far better to
|
// msmeyer: These are public, but it's far better to
|
||||||
// call the "real" interface functions like PlayCurrentRegion() and
|
// call the "real" interface functions below.
|
||||||
// StopPlaying() which are defined below.
|
|
||||||
void OnRewind(wxCommandEvent & evt);
|
void OnRewind(wxCommandEvent & evt);
|
||||||
void OnPlay(wxCommandEvent & evt);
|
void OnPlay(wxCommandEvent & evt);
|
||||||
void OnStop(wxCommandEvent & evt);
|
void OnStop(wxCommandEvent & evt);
|
||||||
void OnRecord(wxCommandEvent & evt);
|
void OnRecord(wxCommandEvent & evt);
|
||||||
void OnRecord(bool altAppearance);
|
|
||||||
bool DoRecord(AudacityProject &project,
|
|
||||||
const TransportTracks &transportTracks, // If captureTracks is empty, then tracks are created
|
|
||||||
double t0, double t1,
|
|
||||||
bool altAppearance,
|
|
||||||
const AudioIOStartStreamOptions &options);
|
|
||||||
void OnFF(wxCommandEvent & evt);
|
void OnFF(wxCommandEvent & evt);
|
||||||
void OnPause(wxCommandEvent & evt);
|
void OnPause(wxCommandEvent & evt);
|
||||||
void OnIdle(wxIdleEvent & event);
|
void OnIdle(wxIdleEvent & event);
|
||||||
@ -96,25 +66,10 @@ class ControlToolBar final : public ToolBar {
|
|||||||
void SetPlay(bool down, PlayAppearance appearance = PlayAppearance::Straight);
|
void SetPlay(bool down, PlayAppearance appearance = PlayAppearance::Straight);
|
||||||
void SetStop();
|
void SetStop();
|
||||||
|
|
||||||
// Play currently selected region, or if nothing selected,
|
|
||||||
// play from current cursor.
|
|
||||||
void PlayCurrentRegion(bool looped = false, bool cutpreview = false);
|
|
||||||
// Play the region [t0,t1]
|
// Play the region [t0,t1]
|
||||||
// Return the Audio IO token or -1 for failure
|
// Return the Audio IO token or -1 for failure
|
||||||
int PlayPlayRegion(const SelectedRegion &selectedRegion,
|
|
||||||
const AudioIOStartStreamOptions &options,
|
|
||||||
PlayMode playMode,
|
|
||||||
bool backwards = false,
|
|
||||||
// Allow t0 and t1 to be beyond end of tracks
|
|
||||||
bool playWhiteSpace = false);
|
|
||||||
void PlayDefault();
|
void PlayDefault();
|
||||||
|
|
||||||
// Stop playing
|
|
||||||
void StopPlaying(bool stopStream = true);
|
|
||||||
|
|
||||||
// Pause - used by AudioIO to pause sound activate recording
|
|
||||||
void Pause();
|
|
||||||
|
|
||||||
void Populate() override;
|
void Populate() override;
|
||||||
void Repaint(wxDC *dc) override;
|
void Repaint(wxDC *dc) override;
|
||||||
void EnableDisableButtons() override;
|
void EnableDisableButtons() override;
|
||||||
@ -127,11 +82,6 @@ class ControlToolBar final : public ToolBar {
|
|||||||
void StartScrolling();
|
void StartScrolling();
|
||||||
void StopScrolling();
|
void StopScrolling();
|
||||||
|
|
||||||
// Cancel the addition of temporary recording tracks into the project
|
|
||||||
void CancelRecording();
|
|
||||||
|
|
||||||
PlayMode GetLastPlayMode() const { return mLastPlayMode; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateStatusBar();
|
void UpdateStatusBar();
|
||||||
|
|
||||||
@ -149,9 +99,6 @@ class ControlToolBar final : public ToolBar {
|
|||||||
teBmps eDisabled);
|
teBmps eDisabled);
|
||||||
|
|
||||||
void ArrangeButtons();
|
void ArrangeButtons();
|
||||||
void SetupCutPreviewTracks(double playStart, double cutStart,
|
|
||||||
double cutEnd, double playEnd);
|
|
||||||
void ClearCutPreviewTracks();
|
|
||||||
wxString StateForStatusBar();
|
wxString StateForStatusBar();
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -172,8 +119,6 @@ class ControlToolBar final : public ToolBar {
|
|||||||
AButton *mStop;
|
AButton *mStop;
|
||||||
AButton *mFF;
|
AButton *mFF;
|
||||||
|
|
||||||
static AudacityProject *mBusyProject;
|
|
||||||
|
|
||||||
// Activate ergonomic order for transport buttons
|
// Activate ergonomic order for transport buttons
|
||||||
bool mErgonomicTransportButtons;
|
bool mErgonomicTransportButtons;
|
||||||
|
|
||||||
@ -181,10 +126,6 @@ class ControlToolBar final : public ToolBar {
|
|||||||
|
|
||||||
wxBoxSizer *mSizer;
|
wxBoxSizer *mSizer;
|
||||||
|
|
||||||
std::shared_ptr<TrackList> mCutPreviewTracks;
|
|
||||||
|
|
||||||
PlayMode mLastPlayMode{ PlayMode::normalPlay };
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DECLARE_CLASS(ControlToolBar)
|
DECLARE_CLASS(ControlToolBar)
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include "../Envelope.h"
|
#include "../Envelope.h"
|
||||||
|
|
||||||
#include "ControlToolBar.h"
|
|
||||||
#include "../AllThemeResources.h"
|
#include "../AllThemeResources.h"
|
||||||
#include "../AudioIO.h"
|
#include "../AudioIO.h"
|
||||||
#include "../ImageManipulation.h"
|
#include "../ImageManipulation.h"
|
||||||
@ -479,6 +478,8 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||||
|
|
||||||
// Fixed speed play is the old method, that uses a time track.
|
// Fixed speed play is the old method, that uses a time track.
|
||||||
// VariSpeed play reuses Scrubbing.
|
// VariSpeed play reuses Scrubbing.
|
||||||
bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
|
bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
|
||||||
@ -511,10 +512,8 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
|
|||||||
|
|
||||||
// If IO is busy, abort immediately
|
// If IO is busy, abort immediately
|
||||||
auto gAudioIO = AudioIOBase::Get();
|
auto gAudioIO = AudioIOBase::Get();
|
||||||
if (gAudioIO->IsBusy()) {
|
if (gAudioIO->IsBusy())
|
||||||
auto &bar = ControlToolBar::Get( *p );
|
projectAudioManager.Stop();
|
||||||
bar.StopPlaying();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the current play region
|
// Get the current play region
|
||||||
const auto &viewInfo = ViewInfo::Get( *p );
|
const auto &viewInfo = ViewInfo::Get( *p );
|
||||||
@ -533,8 +532,7 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
|
|||||||
cutPreview ? PlayMode::cutPreviewPlay
|
cutPreview ? PlayMode::cutPreviewPlay
|
||||||
: options.playLooped ? PlayMode::loopedPlay
|
: options.playLooped ? PlayMode::loopedPlay
|
||||||
: PlayMode::normalPlay;
|
: PlayMode::normalPlay;
|
||||||
auto &bar = ControlToolBar::Get( *p );
|
projectAudioManager.PlayPlayRegion(
|
||||||
bar.PlayPlayRegion(
|
|
||||||
SelectedRegion(playRegion.GetStart(), playRegion.GetEnd()),
|
SelectedRegion(playRegion.GetStart(), playRegion.GetEnd()),
|
||||||
options,
|
options,
|
||||||
mode);
|
mode);
|
||||||
|
@ -16,12 +16,12 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../AudioIO.h"
|
#include "../../AudioIO.h"
|
||||||
#include "../../Project.h"
|
#include "../../Project.h"
|
||||||
#include "../../ProjectAudioIO.h"
|
#include "../../ProjectAudioIO.h"
|
||||||
|
#include "../../ProjectAudioManager.h"
|
||||||
#include "../../ProjectWindow.h"
|
#include "../../ProjectWindow.h"
|
||||||
#include "../../Track.h"
|
#include "../../Track.h"
|
||||||
#include "../../TrackPanel.h"
|
#include "../../TrackPanel.h"
|
||||||
#include "../../ViewInfo.h"
|
#include "../../ViewInfo.h"
|
||||||
#include "Scrubbing.h"
|
#include "Scrubbing.h"
|
||||||
#include "../../toolbars/ControlToolBar.h"
|
|
||||||
#include "TrackView.h"
|
#include "TrackView.h"
|
||||||
|
|
||||||
#include <wx/dc.h>
|
#include <wx/dc.h>
|
||||||
@ -191,7 +191,7 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
|
|||||||
playPos >= 0 && !onScreen ) {
|
playPos >= 0 && !onScreen ) {
|
||||||
// msmeyer: But only if not playing looped or in one-second mode
|
// msmeyer: But only if not playing looped or in one-second mode
|
||||||
// PRL: and not scrolling with play/record head fixed
|
// PRL: and not scrolling with play/record head fixed
|
||||||
auto mode = ControlToolBar::Get( *mProject ).GetLastPlayMode();
|
auto mode = ProjectAudioManager::Get( *mProject ).GetLastPlayMode();
|
||||||
if (!pinned &&
|
if (!pinned &&
|
||||||
mode != PlayMode::loopedPlay &&
|
mode != PlayMode::loopedPlay &&
|
||||||
mode != PlayMode::oneSecondPlay &&
|
mode != PlayMode::oneSecondPlay &&
|
||||||
|
@ -29,7 +29,6 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../WaveTrack.h"
|
#include "../../WaveTrack.h"
|
||||||
#include "../../prefs/PlaybackPrefs.h"
|
#include "../../prefs/PlaybackPrefs.h"
|
||||||
#include "../../prefs/TracksPrefs.h"
|
#include "../../prefs/TracksPrefs.h"
|
||||||
#include "../../toolbars/ControlToolBar.h"
|
|
||||||
#include "../../toolbars/ToolManager.h"
|
#include "../../toolbars/ToolManager.h"
|
||||||
|
|
||||||
#undef USE_TRANSCRIPTION_TOOLBAR
|
#undef USE_TRANSCRIPTION_TOOLBAR
|
||||||
@ -314,12 +313,12 @@ void Scrubber::MarkScrubStart(
|
|||||||
// drag events.
|
// drag events.
|
||||||
mSmoothScrollingScrub = smoothScrolling;
|
mSmoothScrollingScrub = smoothScrolling;
|
||||||
|
|
||||||
auto &ctb = ControlToolBar::Get( *mProject );
|
auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
|
||||||
|
|
||||||
// Stop any play in progress
|
// Stop any play in progress
|
||||||
// Bug 1492: mCancelled to stop us collapsing the selected region.
|
// Bug 1492: mCancelled to stop us collapsing the selected region.
|
||||||
mCancelled = true;
|
mCancelled = true;
|
||||||
ctb.StopPlaying();
|
projectAudioManager.Stop();
|
||||||
mCancelled = false;
|
mCancelled = false;
|
||||||
|
|
||||||
// Usually the timer handler of TrackPanel does this, but we do this now,
|
// Usually the timer handler of TrackPanel does this, but we do this now,
|
||||||
@ -363,7 +362,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
wxCoord position = xx;
|
wxCoord position = xx;
|
||||||
if (abs(mScrubStartPosition - position) >= SCRUBBING_PIXEL_TOLERANCE) {
|
if (abs(mScrubStartPosition - position) >= SCRUBBING_PIXEL_TOLERANCE) {
|
||||||
auto &viewInfo = ViewInfo::Get( *mProject );
|
auto &viewInfo = ViewInfo::Get( *mProject );
|
||||||
auto &ctb = ControlToolBar::Get( *mProject );
|
auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
|
||||||
double maxTime = TrackList::Get( *mProject ).GetEndTime();
|
double maxTime = TrackList::Get( *mProject ).GetEndTime();
|
||||||
const int leftOffset = viewInfo.GetLeftOffset();
|
const int leftOffset = viewInfo.GetLeftOffset();
|
||||||
double time0 = std::min(maxTime,
|
double time0 = std::min(maxTime,
|
||||||
@ -375,7 +374,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
if (time1 != time0) {
|
if (time1 != time0) {
|
||||||
if (busy) {
|
if (busy) {
|
||||||
position = mScrubStartPosition;
|
position = mScrubStartPosition;
|
||||||
ctb.StopPlaying();
|
projectAudioManager.Stop();
|
||||||
mScrubStartPosition = position;
|
mScrubStartPosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,8 +452,9 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
});
|
});
|
||||||
|
|
||||||
mScrubToken =
|
mScrubToken =
|
||||||
ctb.PlayPlayRegion(SelectedRegion(time0, time1), options,
|
projectAudioManager.PlayPlayRegion(
|
||||||
PlayMode::normalPlay, backwards);
|
SelectedRegion(time0, time1), options,
|
||||||
|
PlayMode::normalPlay, backwards);
|
||||||
if (mScrubToken <= 0) {
|
if (mScrubToken <= 0) {
|
||||||
// Bug1627 (part of it):
|
// Bug1627 (part of it):
|
||||||
// infinite error spew when trying to start scrub:
|
// infinite error spew when trying to start scrub:
|
||||||
@ -494,9 +494,9 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &ctb = ControlToolBar::Get( *mProject );
|
auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
|
||||||
if (busy) {
|
if (busy) {
|
||||||
ctb.StopPlaying();
|
projectAudioManager.Stop();
|
||||||
}
|
}
|
||||||
mScrubStartPosition = 0;
|
mScrubStartPosition = 0;
|
||||||
mSpeedPlaying = true;
|
mSpeedPlaying = true;
|
||||||
@ -552,7 +552,8 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
|
|||||||
double stopTolerance = 20.0 / options.rate;
|
double stopTolerance = 20.0 / options.rate;
|
||||||
mScrubToken =
|
mScrubToken =
|
||||||
// Reduce time by 'stopTolerance' fudge factor, so that the Play will stop.
|
// Reduce time by 'stopTolerance' fudge factor, so that the Play will stop.
|
||||||
ctb.PlayPlayRegion(SelectedRegion(time0, time1-stopTolerance), options,
|
projectAudioManager.PlayPlayRegion(
|
||||||
|
SelectedRegion(time0, time1-stopTolerance), options,
|
||||||
PlayMode::normalPlay, backwards);
|
PlayMode::normalPlay, backwards);
|
||||||
|
|
||||||
if (mScrubToken >= 0) {
|
if (mScrubToken >= 0) {
|
||||||
@ -661,8 +662,7 @@ void Scrubber::ContinueScrubbingUI()
|
|||||||
// Stop and set cursor
|
// Stop and set cursor
|
||||||
bool bShift = state.ShiftDown();
|
bool bShift = state.ShiftDown();
|
||||||
TransportActions::DoPlayStopSelect(*mProject, true, bShift);
|
TransportActions::DoPlayStopSelect(*mProject, true, bShift);
|
||||||
wxCommandEvent evt;
|
ProjectAudioManager::Get( *mProject ).Stop();
|
||||||
ControlToolBar::Get( *mProject ).OnStop(evt);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1076,8 +1076,8 @@ void Scrubber::DoScrub(bool seek)
|
|||||||
// just switching mode
|
// just switching mode
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto &ctb = ControlToolBar::Get( *mProject );
|
auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
|
||||||
ctb.StopPlaying();
|
projectAudioManager.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
void ContinueScrubbingUI();
|
void ContinueScrubbingUI();
|
||||||
void ContinueScrubbingPoll();
|
void ContinueScrubbingPoll();
|
||||||
|
|
||||||
// This is meant to be called only from ControlToolBar
|
// This is meant to be called only from ProjectAudioManager
|
||||||
void StopScrubbing();
|
void StopScrubbing();
|
||||||
|
|
||||||
wxCoord GetScrubStartPosition() const
|
wxCoord GetScrubStartPosition() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user