1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +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);
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,
// but the choice of t0 does not depend on that.
// starting with t0
}
// 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.
// when append recording.
if (endTime <= 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());
pending->CreateClip(t0);
}
transportTracks.captureTracks.push_back(pending);
}

View File

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

View File

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