1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Stop playback of pre-rolled tracks at the right time

This commit is contained in:
Paul Licameli 2018-06-01 02:25:51 -04:00
parent 35c60ac96d
commit f9cd5595d5
3 changed files with 25 additions and 7 deletions

View File

@ -2153,18 +2153,26 @@ int AudioIO::StartStream(const TransportTracks &tracks,
mPlaybackBuffers[i] = std::make_unique<RingBuffer>(floatSample, playbackBufferSize);
// MB: use normal time for the end time, not warped time!
WaveTrackConstArray tracks;
tracks.push_back(mPlaybackTracks[i]);
WaveTrackConstArray mixTracks;
mixTracks.push_back(mPlaybackTracks[i]);
double endTime;
if (make_iterator_range(tracks.prerollTracks).contains(mPlaybackTracks[i]))
// Stop playing this track after pre-roll
endTime = t0;
else
// Pass t1 -- not mT1 as may have been adjusted for latency
// -- so that overdub recording stops playing back samples
// at the right time, though transport may continue to record
endTime = t1;
mPlaybackMixers[i] = std::make_unique<Mixer>
(tracks,
(mixTracks,
// Don't throw for read errors, just play silence:
false,
warpOptions,
mT0,
// Pass t1 -- not mT1 as may have been adjusted for latency
// -- so that overdub recording stops playing back samples
// at the right time, though transport may continue to record
t1,
endTime,
1,
playbackMixBufferSize, false,
mRate, floatSample, false);

View File

@ -149,6 +149,9 @@ struct TransportTracks {
#ifdef EXPERIMENTAL_MIDI_OUT
NoteTrackConstArray midiTracks;
#endif
// This is a subset of playbackTracks
WaveTrackConstArray prerollTracks;
};
// This workaround makes pause and stop work when output is to GarageBand,

View File

@ -1125,6 +1125,13 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
{
t1 = wt->GetEndTime();
// If the track was chosen for recording and playback both,
// remember the original in preroll tracks, before making the
// pending replacement.
bool prerollTrack = make_iterator_range(transportTracks.playbackTracks).contains(wt);
if (prerollTrack)
transportTracks.prerollTracks.push_back(wt);
// A function that copies all the non-sample data between
// wave tracks; in case the track recorded to changes scale
// type (for instance), during the recording.