1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +02:00

fix recording starting position (refs #1183)

This commit is contained in:
Vitaly Sverchinsky 2021-07-16 17:49:11 +03:00 committed by Panagiotis Vasilopoulos
parent f93e9fcf94
commit 750e4943f5
No known key found for this signature in database
GPG Key ID: FD806FDB3B2C5270
3 changed files with 14 additions and 23 deletions

View File

@ -520,9 +520,10 @@ void ProjectAudioManager::OnRecord(bool altAppearance)
} }
existingTracks = ChooseExistingRecordingTracks(*p, false, options.rate); existingTracks = ChooseExistingRecordingTracks(*p, false, options.rate);
t0 = std::max( t0, trackRange.max( &Track::GetEndTime ) ); if(!existingTracks.empty())
t0 = std::max( t0, trackRange.max( &Track::GetEndTime ) );
// If suitable tracks still not found, will record into NEW ones, // If suitable tracks still not found, will record into NEW ones,
// but the choice of t0 does not depend on that. // starting with t0
} }
// Whether we decided on NEW tracks or not: // Whether we decided on NEW tracks or not:
@ -641,14 +642,7 @@ bool ProjectAudioManager::DoRecord(AudacityProject &project,
// Less than or equal, not just less than, to ensure a clip boundary. // Less than or equal, not just less than, to ensure a clip boundary.
// when append recording. // when append recording.
if (endTime <= t0) { if (endTime <= t0) {
pending->CreateClip(t0);
// Pad the recording track with silence, up to the
// maximum time.
auto newTrack = pending->EmptyCopy();
newTrack->InsertSilence(0.0, t0 - endTime);
newTrack->Flush();
pending->Clear(endTime, t0);
pending->Paste(endTime, newTrack.get());
} }
transportTracks.captureTracks.push_back(pending); transportTracks.captureTracks.push_back(pending);
} }

View File

@ -179,8 +179,6 @@ void WaveTrack::Reinit(const WaveTrack &orig)
else else
mpWaveformSettings.reset(); mpWaveformSettings.reset();
} }
this->SetOffset(orig.GetOffset());
} }
void WaveTrack::Merge(const Track &orig) void WaveTrack::Merge(const Track &orig)
@ -2143,18 +2141,18 @@ Sequence* WaveTrack::GetSequenceAtTime(double time)
return NULL; return NULL;
} }
WaveClip* WaveTrack::CreateClip() WaveClip* WaveTrack::CreateClip(double offset)
{ {
mClips.push_back(std::make_unique<WaveClip>(mpFactory, mFormat, mRate, GetWaveColorIndex())); mClips.emplace_back(std::make_shared<WaveClip>(mpFactory, mFormat, mRate, GetWaveColorIndex()));
return mClips.back().get(); auto clip = mClips.back().get();
clip->SetOffset(offset);
return clip;
} }
WaveClip* WaveTrack::NewestOrNewClip() WaveClip* WaveTrack::NewestOrNewClip()
{ {
if (mClips.empty()) { if (mClips.empty()) {
WaveClip *clip = CreateClip(); return CreateClip(mOffset);
clip->SetOffset(mOffset);
return clip;
} }
else else
return mClips.back().get(); return mClips.back().get();
@ -2164,9 +2162,7 @@ WaveClip* WaveTrack::NewestOrNewClip()
WaveClip* WaveTrack::RightmostOrNewClip() WaveClip* WaveTrack::RightmostOrNewClip()
{ {
if (mClips.empty()) { if (mClips.empty()) {
WaveClip *clip = CreateClip(); return CreateClip(mOffset);
clip->SetOffset(mOffset);
return clip;
} }
else else
{ {

View File

@ -455,8 +455,9 @@ private:
} }
// Create NEW clip and add it to this track. Returns a pointer // Create NEW clip and add it to this track. Returns a pointer
// to the newly created clip. // to the newly created clip. Optionally initial offset may be
WaveClip* CreateClip(); // provided
WaveClip* CreateClip(double offset = .0);
/** @brief Get access to the most recently added clip, or create a clip, /** @brief Get access to the most recently added clip, or create a clip,
* if there is not already one. THIS IS NOT NECESSARILY RIGHTMOST. * if there is not already one. THIS IS NOT NECESSARILY RIGHTMOST.