mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-05 15:09:08 +02:00
Stop button works during punch and roll recording
This commit is contained in:
parent
ed660bdca2
commit
3051e9ce7e
@ -8589,7 +8589,9 @@ void AudacityProject::OnPunchAndRoll(const CommandContext &WXUNUSED(context))
|
|||||||
options.pCrossfadeData = &crossfadeData;
|
options.pCrossfadeData = &crossfadeData;
|
||||||
bool success = GetControlToolBar()->DoRecord(*this,
|
bool success = GetControlToolBar()->DoRecord(*this,
|
||||||
transportTracks,
|
transportTracks,
|
||||||
t1, DBL_MAX, options);
|
t1, DBL_MAX,
|
||||||
|
false, // altAppearance
|
||||||
|
options);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
// Undo state will get pushed elsewhere, when record finishes
|
// Undo state will get pushed elsewhere, when record finishes
|
||||||
|
@ -1000,50 +1000,15 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
if (!p)
|
if (!p)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CommandFlag flags = AlwaysEnabledFlag; // 0 means recalc flags.
|
|
||||||
|
|
||||||
// NB: The call may have the side effect of changing flags.
|
|
||||||
bool allowed = p->TryToMakeActionAllowed(
|
|
||||||
flags,
|
|
||||||
AudioIONotBusyFlag | CanStopAudioStreamFlag,
|
|
||||||
AudioIONotBusyFlag | CanStopAudioStreamFlag);
|
|
||||||
|
|
||||||
if (!allowed)
|
|
||||||
return;
|
|
||||||
// ...end of code from CommandHandler.
|
|
||||||
|
|
||||||
if (gAudioIO->IsBusy()) {
|
|
||||||
if (!CanStopAudioStream() || 0 == gAudioIO->GetNumCaptureChannels())
|
|
||||||
mRecord->PopUp();
|
|
||||||
else
|
|
||||||
mRecord->PushDown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (evt.GetInt() == 1) // used when called by keyboard shortcut. Default (0) ignored.
|
|
||||||
mRecord->SetShift(true);
|
|
||||||
if (evt.GetInt() == 2)
|
|
||||||
mRecord->SetShift(false);
|
|
||||||
|
|
||||||
bool altAppearance = mRecord->WasShiftDown();
|
bool altAppearance = mRecord->WasShiftDown();
|
||||||
SetRecord(true, altAppearance);
|
if (evt.GetInt() == 1) // used when called by keyboard shortcut. Default (0) ignored.
|
||||||
|
altAppearance = true;
|
||||||
bool success = false;
|
if (evt.GetInt() == 2)
|
||||||
|
altAppearance = false;
|
||||||
|
|
||||||
bool bPreferNewTrack;
|
bool bPreferNewTrack;
|
||||||
gPrefs->Read("/GUI/PreferNewTrackRecord", &bPreferNewTrack, false);
|
gPrefs->Read("/GUI/PreferNewTrackRecord", &bPreferNewTrack, false);
|
||||||
bool appendRecord = (altAppearance == bPreferNewTrack);
|
const bool appendRecord = (altAppearance == bPreferNewTrack);
|
||||||
|
|
||||||
auto cleanup = finally([&] {
|
|
||||||
if (!success) {
|
|
||||||
SetPlay(false);
|
|
||||||
SetStop(false);
|
|
||||||
SetRecord(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Success or not:
|
|
||||||
UpdateStatusBar(GetActiveProject());
|
|
||||||
});
|
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
double t0 = p->GetSel0();
|
double t0 = p->GetSel0();
|
||||||
@ -1081,7 +1046,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
existingTracks = ChooseExistingRecordingTracks(*p, false);
|
existingTracks = ChooseExistingRecordingTracks(*p, false);
|
||||||
if (existingTracks.empty())
|
if (existingTracks.empty())
|
||||||
// Can't find enough suitable tracks, so record into new ones.
|
// Can't find enough suitable tracks, so record into new ones.
|
||||||
appendRecord = false;
|
;
|
||||||
else
|
else
|
||||||
// t0 is now: max(selection-start, end-of-selected-wavetracks)
|
// t0 is now: max(selection-start, end-of-selected-wavetracks)
|
||||||
// allt0 is: max(selection-start, end-of-all-tracks)
|
// allt0 is: max(selection-start, end-of-all-tracks)
|
||||||
@ -1107,7 +1072,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||||||
|
|
||||||
transportTracks.captureTracks = existingTracks;
|
transportTracks.captureTracks = existingTracks;
|
||||||
AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
|
AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
|
||||||
success = DoRecord(*p, transportTracks, t0, t1, options);
|
DoRecord(*p, transportTracks, t0, t1, altAppearance, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1127,15 +1092,49 @@ bool ControlToolBar::UseDuplex()
|
|||||||
bool ControlToolBar::DoRecord(AudacityProject &project,
|
bool ControlToolBar::DoRecord(AudacityProject &project,
|
||||||
const TransportTracks &tracks,
|
const TransportTracks &tracks,
|
||||||
double t0, double t1,
|
double t0, double t1,
|
||||||
|
bool altAppearance,
|
||||||
const AudioIOStartStreamOptions &options)
|
const AudioIOStartStreamOptions &options)
|
||||||
{
|
{
|
||||||
|
CommandFlag flags = AlwaysEnabledFlag; // 0 means recalc flags.
|
||||||
|
|
||||||
|
// NB: The call may have the side effect of changing flags.
|
||||||
|
bool allowed = project.TryToMakeActionAllowed(
|
||||||
|
flags,
|
||||||
|
AudioIONotBusyFlag | CanStopAudioStreamFlag,
|
||||||
|
AudioIONotBusyFlag | CanStopAudioStreamFlag);
|
||||||
|
|
||||||
|
if (!allowed)
|
||||||
|
return false;
|
||||||
|
// ...end of code from CommandHandler.
|
||||||
|
|
||||||
|
if (gAudioIO->IsBusy()) {
|
||||||
|
if (!CanStopAudioStream() || 0 == gAudioIO->GetNumCaptureChannels())
|
||||||
|
mRecord->PopUp();
|
||||||
|
else
|
||||||
|
mRecord->PushDown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetRecord(true, altAppearance);
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
auto cleanup = finally([&] {
|
||||||
|
if (!success) {
|
||||||
|
SetPlay(false);
|
||||||
|
SetStop(false);
|
||||||
|
SetRecord(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Success or not:
|
||||||
|
UpdateStatusBar(GetActiveProject());
|
||||||
|
});
|
||||||
|
|
||||||
auto transportTracks = tracks;
|
auto transportTracks = tracks;
|
||||||
|
|
||||||
// Will replace any given capture tracks with temporaries
|
// Will replace any given capture tracks with temporaries
|
||||||
transportTracks.captureTracks.clear();
|
transportTracks.captureTracks.clear();
|
||||||
|
|
||||||
const auto p = &project;
|
const auto p = &project;
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
bool appendRecord = !tracks.captureTracks.empty();
|
bool appendRecord = !tracks.captureTracks.empty();
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ class ControlToolBar final : public ToolBar {
|
|||||||
bool DoRecord(AudacityProject &project,
|
bool DoRecord(AudacityProject &project,
|
||||||
const TransportTracks &transportTracks, // If captureTracks is empty, then tracks are created
|
const TransportTracks &transportTracks, // If captureTracks is empty, then tracks are created
|
||||||
double t0, double t1,
|
double t0, double t1,
|
||||||
|
bool altAppearance,
|
||||||
const AudioIOStartStreamOptions &options);
|
const AudioIOStartStreamOptions &options);
|
||||||
void OnFF(wxCommandEvent & evt);
|
void OnFF(wxCommandEvent & evt);
|
||||||
void OnPause(wxCommandEvent & evt);
|
void OnPause(wxCommandEvent & evt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user