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