diff --git a/src/ProjectAudioManager.cpp b/src/ProjectAudioManager.cpp index 69d9f1e2d..c21e5127c 100644 --- a/src/ProjectAudioManager.cpp +++ b/src/ProjectAudioManager.cpp @@ -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); } diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 6e1dfd851..dedf59332 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -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(mpFactory, mFormat, mRate, GetWaveColorIndex())); - return mClips.back().get(); + mClips.emplace_back(std::make_shared(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 { diff --git a/src/WaveTrack.h b/src/WaveTrack.h index 6e213e352..7b3561a65 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -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.