void return, not boolean success, from some Track virtual functions...
... The return codes were mostly ignored anyway, and exceptions will be thrown instead. It seems there was also confusion whether the return values of Track::Paste and Track::SyncLockAdjust were to indicate success or indicate whether there was any change. No matter now.
This commit is contained in:
parent
a23d6e2368
commit
e1473dfe76
|
@ -2474,13 +2474,10 @@ void AudioIO::StopStream()
|
|||
}
|
||||
if( appendRecord )
|
||||
{ // append-recording
|
||||
bool bResult;
|
||||
if (recordingOffset < 0)
|
||||
bResult = track->Clear(mT0, mT0 - recordingOffset); // cut the latency out
|
||||
track->Clear(mT0, mT0 - recordingOffset); // cut the latency out
|
||||
else
|
||||
bResult = track->InsertSilence(mT0, recordingOffset); // put silence in
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
track->InsertSilence(mT0, recordingOffset); // put silence in
|
||||
}
|
||||
else
|
||||
{ // recording into a NEW track
|
||||
|
|
|
@ -449,8 +449,10 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
|
|||
if (mEditDetail)
|
||||
Printf(wxT("Paste: %d\n"), y0 * chunkSize);
|
||||
|
||||
if (!t->Paste((double)(y0 * chunkSize), tmp.get()))
|
||||
{
|
||||
try {
|
||||
t->Paste((double)(y0 * chunkSize), tmp.get());
|
||||
}
|
||||
catch (const AudacityException&) {
|
||||
Printf(wxT("Trial %d\nFailed on Paste.\n"), z);
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ void LabelTrack::SetOffset(double dOffset)
|
|||
labelStruct.selectedRegion.move(dOffset);
|
||||
}
|
||||
|
||||
bool LabelTrack::Clear(double b, double e)
|
||||
void LabelTrack::Clear(double b, double e)
|
||||
{
|
||||
// May DELETE labels, so use subscripts to iterate
|
||||
for (size_t i = 0; i < mLabels.size(); ++i) {
|
||||
|
@ -175,8 +175,6 @@ bool LabelTrack::Clear(double b, double e)
|
|||
else if (relation == LabelStruct::WITHIN_LABEL)
|
||||
labelStruct.selectedRegion.moveT1( - (e-b));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -2340,9 +2338,7 @@ Track::Holder LabelTrack::Cut(double t0, double t1)
|
|||
{
|
||||
auto tmp = Copy(t0, t1);
|
||||
|
||||
if (!Clear(t0, t1))
|
||||
//THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
Clear(t0, t1);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
@ -2416,6 +2412,7 @@ Track::Holder LabelTrack::Copy(double t0, double t1, bool) const
|
|||
bool LabelTrack::PasteOver(double t, const Track * src)
|
||||
{
|
||||
if (src->GetKind() != Track::Label)
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return false;
|
||||
|
||||
int len = mLabels.size();
|
||||
|
@ -2439,17 +2436,18 @@ bool LabelTrack::PasteOver(double t, const Track * src)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool LabelTrack::Paste(double t, const Track *src)
|
||||
void LabelTrack::Paste(double t, const Track *src)
|
||||
{
|
||||
if (src->GetKind() != Track::Label)
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return;
|
||||
|
||||
LabelTrack *lt = (LabelTrack *)src;
|
||||
|
||||
double shiftAmt = lt->mClipLen > 0.0 ? lt->mClipLen : lt->GetEndTime();
|
||||
|
||||
ShiftLabelsOnInsert(shiftAmt, t);
|
||||
return PasteOver(t, src);
|
||||
PasteOver(t, src);
|
||||
}
|
||||
|
||||
// This repeats the labels in a time interval a specified number of times.
|
||||
|
@ -2505,7 +2503,7 @@ bool LabelTrack::Repeat(double t0, double t1, int n)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool LabelTrack::Silence(double t0, double t1)
|
||||
void LabelTrack::Silence(double t0, double t1)
|
||||
{
|
||||
int len = mLabels.size();
|
||||
|
||||
|
@ -2549,11 +2547,9 @@ bool LabelTrack::Silence(double t0, double t1)
|
|||
}
|
||||
|
||||
SortLabels();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LabelTrack::InsertSilence(double t, double len)
|
||||
void LabelTrack::InsertSilence(double t, double len)
|
||||
{
|
||||
for (auto &labelStruct: mLabels) {
|
||||
double t0 = labelStruct.getT0();
|
||||
|
@ -2565,8 +2561,6 @@ bool LabelTrack::InsertSilence(double t, double len)
|
|||
t1 += len;
|
||||
labelStruct.selectedRegion.setTimes(t0, t1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int LabelTrack::GetNumLabels() const
|
||||
|
|
|
@ -156,12 +156,12 @@ class AUDACITY_DLL_API LabelTrack final : public Track
|
|||
|
||||
Track::Holder Cut (double t0, double t1) override;
|
||||
Track::Holder Copy (double t0, double t1, bool forClipboard = true) const override;
|
||||
bool Clear(double t0, double t1) override;
|
||||
bool Paste(double t, const Track * src) override;
|
||||
void Clear(double t0, double t1) override;
|
||||
void Paste(double t, const Track * src) override;
|
||||
bool Repeat(double t0, double t1, int n);
|
||||
|
||||
bool Silence(double t0, double t1) override;
|
||||
bool InsertSilence(double t, double len) override;
|
||||
void Silence(double t0, double t1) override;
|
||||
void InsertSilence(double t, double len) override;
|
||||
int OverGlyph(int x, int y);
|
||||
static wxBitmap & GetGlyph( int i);
|
||||
|
||||
|
|
|
@ -4384,7 +4384,11 @@ void AudacityProject::OnPaste()
|
|||
{
|
||||
// Must perform sync-lock adjustment before incrementing n
|
||||
if (n->IsSyncLockSelected()) {
|
||||
bPastedSomething |= n->SyncLockAdjust(t1, t0+(msClipT1 - msClipT0));
|
||||
auto newT1 = t0 + (msClipT1 - msClipT0);
|
||||
if (t1 != newT1 && t1 <= n->GetEndTime()) {
|
||||
n->SyncLockAdjust(t1, newT1);
|
||||
bPastedSomething = true;
|
||||
}
|
||||
}
|
||||
n = iter.Next();
|
||||
}
|
||||
|
@ -4441,8 +4445,9 @@ void AudacityProject::OnPaste()
|
|||
}
|
||||
else
|
||||
{
|
||||
bPastedSomething = true;
|
||||
n->Clear(t0, t1);
|
||||
bPastedSomething |= n->Paste(t0, c);
|
||||
n->Paste(t0, c);
|
||||
}
|
||||
|
||||
// When copying from mono to stereo track, paste the wave form
|
||||
|
@ -4457,7 +4462,8 @@ void AudacityProject::OnPaste()
|
|||
else
|
||||
{
|
||||
n->Clear(t0, t1);
|
||||
bPastedSomething |= n->Paste(t0, c);
|
||||
bPastedSomething = true;
|
||||
n->Paste(t0, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4468,7 +4474,11 @@ void AudacityProject::OnPaste()
|
|||
} // if (n->GetSelected())
|
||||
else if (n->IsSyncLockSelected())
|
||||
{
|
||||
bPastedSomething |= n->SyncLockAdjust(t1, t0 + msClipT1 - msClipT0);
|
||||
auto newT1 = t0 + (msClipT1 - msClipT0);
|
||||
if (t1 != newT1 && t1 <= n->GetEndTime()) {
|
||||
n->SyncLockAdjust(t1, newT1);
|
||||
bPastedSomething = true;
|
||||
}
|
||||
}
|
||||
|
||||
n = iter.Next();
|
||||
|
@ -4492,9 +4502,7 @@ void AudacityProject::OnPaste()
|
|||
}
|
||||
else {
|
||||
auto tmp = mTrackFactory->NewWaveTrack( ((WaveTrack*)n)->GetSampleFormat(), ((WaveTrack*)n)->GetRate());
|
||||
bool bResult = tmp->InsertSilence(0.0, msClipT1 - msClipT0); // MJS: Is this correct?
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
tmp->InsertSilence(0.0, msClipT1 - msClipT0); // MJS: Is this correct?
|
||||
tmp->Flush();
|
||||
|
||||
bPastedSomething |=
|
||||
|
@ -4637,9 +4645,7 @@ bool AudacityProject::HandlePasteNothingSelected()
|
|||
}
|
||||
wxASSERT(pClip);
|
||||
|
||||
bool bResult = pNewTrack->Paste(0.0, pClip);
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
pNewTrack->Paste(0.0, pClip);
|
||||
|
||||
if (!pFirstNewTrack)
|
||||
pFirstNewTrack = pNewTrack;
|
||||
|
@ -4941,7 +4947,7 @@ void AudacityProject::OnCutLabels()
|
|||
if( gPrefs->Read( wxT( "/GUI/EnableCutLines" ), ( long )0 ) )
|
||||
EditByLabel( &WaveTrack::ClearAndAddCutLine, true );
|
||||
else
|
||||
EditByLabel( &WaveTrack::Clear, true );
|
||||
EditByLabel( &WaveTrack::Clear1, true );
|
||||
|
||||
msClipProject = this;
|
||||
|
||||
|
@ -4995,7 +5001,7 @@ void AudacityProject::OnDeleteLabels()
|
|||
if( mViewInfo.selectedRegion.isPoint() )
|
||||
return;
|
||||
|
||||
EditByLabel( &WaveTrack::Clear, true );
|
||||
EditByLabel( &WaveTrack::Clear1, true );
|
||||
|
||||
mViewInfo.selectedRegion.collapseToT0();
|
||||
|
||||
|
@ -5029,7 +5035,7 @@ void AudacityProject::OnSilenceLabels()
|
|||
if( mViewInfo.selectedRegion.isPoint() )
|
||||
return;
|
||||
|
||||
EditByLabel( &WaveTrack::Silence, false );
|
||||
EditByLabel( &WaveTrack::Silence1, false );
|
||||
|
||||
PushState(
|
||||
/* i18n-hint: (verb)*/
|
||||
|
|
|
@ -492,20 +492,19 @@ bool NoteTrack::Trim(double t0, double t1)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool NoteTrack::Clear(double t0, double t1)
|
||||
void NoteTrack::Clear(double t0, double t1)
|
||||
{
|
||||
// If t1 = t0, should Clear return true?
|
||||
if (t1 <= t0)
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; ?
|
||||
return;
|
||||
double len = t1-t0;
|
||||
|
||||
if (mSeq)
|
||||
mSeq->clear(t0 - GetOffset(), len, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NoteTrack::Paste(double t, const Track *src)
|
||||
void NoteTrack::Paste(double t, const Track *src)
|
||||
{
|
||||
// Paste inserts src at time t. If src has a positive offset,
|
||||
// the offset is treated as silence which is also inserted. If
|
||||
|
@ -517,11 +516,13 @@ bool NoteTrack::Paste(double t, const Track *src)
|
|||
|
||||
//Check that src is a non-NULL NoteTrack
|
||||
if (src == NULL || src->GetKind() != Track::Note)
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return;
|
||||
|
||||
NoteTrack* other = (NoteTrack*)src;
|
||||
if (other->mSeq == NULL)
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return;
|
||||
|
||||
if(!mSeq)
|
||||
mSeq = std::make_unique<Alg_seq>();
|
||||
|
@ -532,20 +533,16 @@ bool NoteTrack::Paste(double t, const Track *src)
|
|||
t += other->GetOffset();
|
||||
}
|
||||
mSeq->paste(t - GetOffset(), other->mSeq.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NoteTrack::Silence(double, double)
|
||||
void NoteTrack::Silence(double, double)
|
||||
{
|
||||
// to do
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NoteTrack::InsertSilence(double, double)
|
||||
void NoteTrack::InsertSilence(double, double)
|
||||
{
|
||||
// to do
|
||||
return false;
|
||||
}
|
||||
|
||||
// Call this function to manipulate the underlying sequence data. This is
|
||||
|
|
|
@ -103,10 +103,10 @@ class AUDACITY_DLL_API NoteTrack final
|
|||
Track::Holder Cut (double t0, double t1) override;
|
||||
Track::Holder Copy (double t0, double t1, bool forClipboard = true) const override;
|
||||
bool Trim (double t0, double t1) /* not override */;
|
||||
bool Clear(double t0, double t1) override;
|
||||
bool Paste(double t, const Track *src) override;
|
||||
bool Silence(double t0, double t1) override;
|
||||
bool InsertSilence(double t, double len) override;
|
||||
void Clear(double t0, double t1) override;
|
||||
void Paste(double t, const Track *src) override;
|
||||
void Silence(double t0, double t1) override;
|
||||
void InsertSilence(double t, double len) override;
|
||||
bool Shift(double t) /* not override */;
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
|
|
|
@ -4993,9 +4993,7 @@ void AudacityProject::EditClipboardByLabel( EditDestFunction action )
|
|||
// right to left. Any placeholder already in merged is kept.
|
||||
// Only the rightmost placeholder is important in the final
|
||||
// result.
|
||||
bool bResult = merged->Paste( 0.0 , dest.get() );
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
merged->Paste( 0.0 , dest.get() );
|
||||
}
|
||||
}
|
||||
else // nothing copied but there is a 'region', so the 'region' must be a 'point label' so offset
|
||||
|
|
|
@ -120,30 +120,27 @@ Track::Holder TimeTrack::Copy( double t0, double t1, bool ) const
|
|||
return Track::Holder{ std::move( result ) };
|
||||
}
|
||||
|
||||
bool TimeTrack::Clear(double t0, double t1)
|
||||
void TimeTrack::Clear(double t0, double t1)
|
||||
{
|
||||
mEnvelope->CollapseRegion(t0, t1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TimeTrack::Paste(double t, const Track * src)
|
||||
void TimeTrack::Paste(double t, const Track * src)
|
||||
{
|
||||
if (src->GetKind() != Track::Time)
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return;
|
||||
|
||||
mEnvelope->Paste(t, static_cast<const TimeTrack*>(src)->mEnvelope.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TimeTrack::Silence(double t0, double t1)
|
||||
void TimeTrack::Silence(double t0, double t1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TimeTrack::InsertSilence(double t, double len)
|
||||
void TimeTrack::InsertSilence(double t, double len)
|
||||
{
|
||||
mEnvelope->InsertSpace(t, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
Track::Holder TimeTrack::Duplicate() const
|
||||
|
|
|
@ -43,10 +43,10 @@ class TimeTrack final : public Track {
|
|||
|
||||
Holder Cut( double t0, double t1 ) override;
|
||||
Holder Copy( double t0, double t1, bool forClipboard ) const override;
|
||||
bool Clear(double t0, double t1) override;
|
||||
bool Paste(double t, const Track * src) override;
|
||||
bool Silence(double t0, double t1) override;
|
||||
bool InsertSilence(double t, double len) override;
|
||||
void Clear(double t0, double t1) override;
|
||||
void Paste(double t, const Track * src) override;
|
||||
void Silence(double t0, double t1) override;
|
||||
void InsertSilence(double t, double len) override;
|
||||
|
||||
// Identifying the type of track
|
||||
int GetKind() const override { return Time; }
|
||||
|
|
|
@ -300,28 +300,22 @@ bool Track::IsSyncLockSelected() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Track::SyncLockAdjust(double oldT1, double newT1)
|
||||
void Track::SyncLockAdjust(double oldT1, double newT1)
|
||||
{
|
||||
if (newT1 > oldT1) {
|
||||
// Insert space within the track
|
||||
|
||||
if (oldT1 > GetEndTime())
|
||||
return true;
|
||||
return;
|
||||
|
||||
auto tmp = Cut(oldT1, GetEndTime());
|
||||
|
||||
bool ret = Paste(newT1, tmp.get());
|
||||
wxASSERT(ret); // TODO: handle this.
|
||||
|
||||
return ret;
|
||||
Paste(newT1, tmp.get());
|
||||
}
|
||||
else if (newT1 < oldT1) {
|
||||
// Remove from the track
|
||||
return Clear(newT1, oldT1);
|
||||
Clear(newT1, oldT1);
|
||||
}
|
||||
|
||||
// fall-through: no change
|
||||
return true;
|
||||
}
|
||||
|
||||
void PlayableTrack::Init( const PlayableTrack &orig )
|
||||
|
|
12
src/Track.h
12
src/Track.h
|
@ -217,18 +217,16 @@ class AUDACITY_DLL_API Track /* not final */ : public XMLTagHandler
|
|||
virtual Holder Copy
|
||||
(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard = true) const = 0;
|
||||
|
||||
// Return true for success
|
||||
virtual bool Clear(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
|
||||
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
|
||||
|
||||
// Return true for success
|
||||
virtual bool Paste(double WXUNUSED(t), const Track * WXUNUSED(src)) = 0;
|
||||
virtual void Paste(double WXUNUSED(t), const Track * WXUNUSED(src)) = 0;
|
||||
|
||||
// This can be used to adjust a sync-lock selected track when the selection
|
||||
// is replaced by one of a different length.
|
||||
virtual bool SyncLockAdjust(double oldT1, double newT1);
|
||||
virtual void SyncLockAdjust(double oldT1, double newT1);
|
||||
|
||||
virtual bool Silence(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
|
||||
virtual bool InsertSilence(double WXUNUSED(t), double WXUNUSED(len)) = 0;
|
||||
virtual void Silence(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
|
||||
virtual void InsertSilence(double WXUNUSED(t), double WXUNUSED(len)) = 0;
|
||||
|
||||
virtual int GetKind() const { return None; }
|
||||
|
||||
|
|
|
@ -537,9 +537,7 @@ Track::Holder WaveTrack::Cut(double t0, double t1)
|
|||
|
||||
auto tmp = Copy(t0, t1);
|
||||
|
||||
if (!Clear(t0, t1))
|
||||
// THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
Clear(t0, t1);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
@ -617,10 +615,7 @@ bool WaveTrack::Trim (double t0, double t1)
|
|||
//if inside0 is false, then the left selector was between
|
||||
//clips, so DELETE everything to its left.
|
||||
if(false == inside1)
|
||||
{
|
||||
if (!Clear(t1,GetEndTime()))
|
||||
return false;
|
||||
}
|
||||
Clear(t1,GetEndTime());
|
||||
|
||||
if(false == inside0)
|
||||
{
|
||||
|
@ -713,9 +708,9 @@ Track::Holder WaveTrack::CopyNonconst(double t0, double t1)
|
|||
return Copy(t0, t1);
|
||||
}
|
||||
|
||||
bool WaveTrack::Clear(double t0, double t1)
|
||||
void WaveTrack::Clear(double t0, double t1)
|
||||
{
|
||||
return HandleClear(t0, t1, false, false);
|
||||
HandleClear(t0, t1, false, false);
|
||||
}
|
||||
|
||||
bool WaveTrack::ClearAndAddCutLine(double t0, double t1)
|
||||
|
@ -812,7 +807,8 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear
|
|||
|
||||
// If duration is 0, then it's just a plain paste
|
||||
if (dur == 0.0) {
|
||||
return Paste(t0, src);
|
||||
Paste(t0, src);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If provided time warper was NULL, use a default one that does nothing
|
||||
|
@ -867,7 +863,8 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear
|
|||
if (HandleClear(t0, t1, false, false)) {
|
||||
|
||||
// And paste in the NEW data
|
||||
if (Paste(t0, src)) {
|
||||
Paste(t0, src);
|
||||
{
|
||||
// First, merge the NEW clip(s) in with the existing clips
|
||||
if (merge && splits.GetCount() > 0)
|
||||
{
|
||||
|
@ -1147,7 +1144,7 @@ bool WaveTrack::HandleClear(double t0, double t1,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WaveTrack::SyncLockAdjust(double oldT1, double newT1)
|
||||
void WaveTrack::SyncLockAdjust(double oldT1, double newT1)
|
||||
{
|
||||
if (newT1 > oldT1) {
|
||||
// Insert space within the track
|
||||
|
@ -1156,62 +1153,57 @@ bool WaveTrack::SyncLockAdjust(double oldT1, double newT1)
|
|||
// GetEndTime() looks through the clips and may give us EXACTLY the same
|
||||
// value as T1, when T1 was set to be at the end of one of those clips.
|
||||
if (oldT1 >= GetEndTime())
|
||||
return true;
|
||||
return;
|
||||
|
||||
// If track is empty at oldT1 insert whitespace; otherwise, silence
|
||||
if (IsEmpty(oldT1, oldT1))
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
// Check if clips can move
|
||||
bool clipsCanMove = true;
|
||||
gPrefs->Read(wxT("/GUI/EditClipCanMove"), &clipsCanMove);
|
||||
if (clipsCanMove) {
|
||||
auto tmp = Cut (oldT1, GetEndTime() + 1.0/GetRate());
|
||||
|
||||
ret = Paste(newT1, tmp.get());
|
||||
wxASSERT(ret);
|
||||
Paste(newT1, tmp.get());
|
||||
}
|
||||
|
||||
return ret;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// AWD: Could just use InsertSilence() on its own here, but it doesn't
|
||||
// follow EditClipCanMove rules (Paste() does it right)
|
||||
AudacityProject *p = GetActiveProject();
|
||||
if (!p) return false;
|
||||
if (!p)
|
||||
// THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
TrackFactory *f = p->GetTrackFactory();
|
||||
if (!f) return false;
|
||||
if (!f)
|
||||
// THROW_INCONSISTENCY_EXCEPTION
|
||||
;
|
||||
auto tmp = f->NewWaveTrack(GetSampleFormat(), GetRate());
|
||||
|
||||
bool bResult = tmp->InsertSilence(0.0, newT1 - oldT1);
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
tmp->InsertSilence(0.0, newT1 - oldT1);
|
||||
tmp->Flush();
|
||||
bResult = Paste(oldT1, tmp.get());
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
Paste(oldT1, tmp.get());
|
||||
}
|
||||
}
|
||||
else if (newT1 < oldT1) {
|
||||
return Clear(newT1, oldT1);
|
||||
Clear(newT1, oldT1);
|
||||
}
|
||||
|
||||
// fall-through: no change
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WaveTrack::Paste(double t0, const Track *src)
|
||||
void WaveTrack::Paste(double t0, const Track *src)
|
||||
// WEAK-GUARANTEE
|
||||
{
|
||||
bool editClipCanMove = true;
|
||||
gPrefs->Read(wxT("/GUI/EditClipCanMove"), &editClipCanMove);
|
||||
|
||||
if( src == NULL )
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return;
|
||||
|
||||
if (src->GetKind() != Track::Wave)
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return;
|
||||
|
||||
const WaveTrack* other = static_cast<const WaveTrack*>(src);
|
||||
|
||||
|
@ -1237,7 +1229,7 @@ bool WaveTrack::Paste(double t0, const Track *src)
|
|||
//
|
||||
|
||||
if (other->GetNumClips() == 0)
|
||||
return false;
|
||||
return;
|
||||
|
||||
//printf("paste: we have at least one clip\n");
|
||||
|
||||
|
@ -1254,9 +1246,7 @@ bool WaveTrack::Paste(double t0, const Track *src)
|
|||
// move everything to the right, then try to paste again
|
||||
if (!IsEmpty(t0, GetEndTime())) {
|
||||
auto tmp = Cut(t0, GetEndTime()+1.0/mRate);
|
||||
bool bResult = Paste(t0 + insertDuration, tmp.get());
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
Paste(t0 + insertDuration, tmp.get());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1351,13 +1341,13 @@ bool WaveTrack::Paste(double t0, const Track *src)
|
|||
mClips.push_back(std::move(newClip)); // transfer ownership
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WaveTrack::Silence(double t0, double t1)
|
||||
void WaveTrack::Silence(double t0, double t1)
|
||||
{
|
||||
if (t1 < t0)
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return;
|
||||
|
||||
auto start = (sampleCount)floor(t0 * mRate + 0.5);
|
||||
auto len = (sampleCount)floor(t1 * mRate + 0.5) - start;
|
||||
|
@ -1386,25 +1376,25 @@ bool WaveTrack::Silence(double t0, double t1)
|
|||
if (!clip->GetSequence()->SetSilence(inclipDelta, samplesToCopy))
|
||||
{
|
||||
wxASSERT(false); // should always work
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
clip->MarkChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool WaveTrack::InsertSilence(double t, double len)
|
||||
void WaveTrack::InsertSilence(double t, double len)
|
||||
{
|
||||
if (len <= 0)
|
||||
return false;
|
||||
// THROW_INCONSISTENCY_EXCEPTION; // ?
|
||||
return;
|
||||
|
||||
if (mClips.empty())
|
||||
{
|
||||
// Special case if there is no clip yet
|
||||
WaveClip* clip = CreateClip();
|
||||
return clip->InsertSilence(0, len);
|
||||
clip->InsertSilence(0, len);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &clip : mClips)
|
||||
|
@ -1414,12 +1404,10 @@ bool WaveTrack::InsertSilence(double t, double len)
|
|||
else if (clip->WithinClip(t))
|
||||
{
|
||||
if (!clip->InsertSilence(t, len)) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Performs the opposite of Join
|
||||
|
|
|
@ -175,16 +175,18 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
|
|||
Track::Holder Copy(double t0, double t1, bool forClipboard = true) const override;
|
||||
Track::Holder CopyNonconst(double t0, double t1) /* not override */;
|
||||
|
||||
bool Clear(double t0, double t1) override;
|
||||
bool Paste(double t0, const Track *src) override;
|
||||
void Clear(double t0, double t1) override;
|
||||
bool Clear1(double t0, double t1) { Clear(t0, t1); return true; }
|
||||
void Paste(double t0, const Track *src) override;
|
||||
bool ClearAndPaste(double t0, double t1,
|
||||
const Track *src,
|
||||
bool preserve = true,
|
||||
bool merge = true,
|
||||
const TimeWarper *effectWarper = NULL) /* not override */;
|
||||
|
||||
bool Silence(double t0, double t1) override;
|
||||
bool InsertSilence(double t, double len) override;
|
||||
void Silence(double t0, double t1) override;
|
||||
bool Silence1(double t0, double t1) { Silence(t0, t1); return true; }
|
||||
void InsertSilence(double t, double len) override;
|
||||
|
||||
bool SplitAt(double t) /* not override */;
|
||||
bool Split(double t0, double t1) /* not override */;
|
||||
|
@ -200,7 +202,7 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
|
|||
|
||||
bool HandleClear(double t0, double t1, bool addCutLines, bool split);
|
||||
|
||||
bool SyncLockAdjust(double oldT1, double newT1) override;
|
||||
void SyncLockAdjust(double oldT1, double newT1) override;
|
||||
|
||||
/** @brief Returns true if there are no WaveClips in the specified region
|
||||
*
|
||||
|
|
|
@ -1968,8 +1968,7 @@ void Effect::GetSamples(
|
|||
t1 = t0 + mDuration;
|
||||
if (mT0 == mT1) {
|
||||
// Not really part of the calculation, but convenient to put here
|
||||
bool bResult = track->InsertSilence(t0, t1);
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
track->InsertSilence(t0, t1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1174,9 +1174,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
|
|||
t->Clear(clipStartEndTimes[i].first,clipStartEndTimes[i].second);
|
||||
auto toClipOutput = output->Copy(clipStartEndTimes[i].first-startT+offsetT0,clipStartEndTimes[i].second-startT+offsetT0);
|
||||
//put the processed audio in
|
||||
bool bResult = t->Paste(clipStartEndTimes[i].first, toClipOutput.get());
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
t->Paste(clipStartEndTimes[i].first, toClipOutput.get());
|
||||
//if the clip was only partially selected, the Paste will have created a split line. Join is needed to take care of this
|
||||
//This is not true when the selection is fully contained within one clip (second half of conditional)
|
||||
if( (clipRealStartEndTimes[i].first != clipStartEndTimes[i].first ||
|
||||
|
|
|
@ -559,8 +559,7 @@ bool EffectEqualization48x::ProcessTail(WaveTrack * t, WaveTrack * output, sampl
|
|||
// output->Copy(clipStartEndTimes[i].first-startT+offsetT0,clipStartEndTimes[i].second-startT+offsetT0, &toClipOutput);
|
||||
auto toClipOutput = output->Copy(clipStartEndTimes[i].first-startT, clipStartEndTimes[i].second-startT);
|
||||
//put the processed audio in
|
||||
bool bResult = t->Paste(clipStartEndTimes[i].first, toClipOutput.get());
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
t->Paste(clipStartEndTimes[i].first, toClipOutput.get());
|
||||
//if the clip was only partially selected, the Paste will have created a split line. Join is needed to take care of this
|
||||
//This is not true when the selection is fully contained within one clip (second half of conditional)
|
||||
if( (clipRealStartEndTimes[i].first != clipStartEndTimes[i].first ||
|
||||
|
|
|
@ -378,11 +378,11 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
|
|||
}
|
||||
}
|
||||
|
||||
outputTrack->Flush();
|
||||
if (!cancelled){
|
||||
outputTrack->Flush();
|
||||
|
||||
track->Clear(t0,t1);
|
||||
bool success = track->Paste(t0, outputTrack.get());
|
||||
if (!cancelled && success){
|
||||
track->Clear(t0,t1);
|
||||
track->Paste(t0, outputTrack.get());
|
||||
m_t1 = mT0 + outputTrack->GetEndTime();
|
||||
}
|
||||
|
||||
|
|
|
@ -139,12 +139,12 @@ bool EffectRepeat::Process()
|
|||
auto dest = track->Copy(mT0, mT1);
|
||||
for(int j=0; j<repeatCount; j++)
|
||||
{
|
||||
if (!track->Paste(tc, dest.get()) ||
|
||||
TrackProgress(nTrack, j / repeatCount)) // TrackProgress returns true on Cancel.
|
||||
if (TrackProgress(nTrack, j / repeatCount)) // TrackProgress returns true on Cancel.
|
||||
{
|
||||
bGoodResult = false;
|
||||
break;
|
||||
}
|
||||
track->Paste(tc, dest.get());
|
||||
tc += tLen;
|
||||
}
|
||||
if (tc > maxDestLen)
|
||||
|
|
|
@ -97,7 +97,6 @@ bool EffectSilence::GenerateTrack(WaveTrack *tmp,
|
|||
const WaveTrack & WXUNUSED(track),
|
||||
int WXUNUSED(ntrack))
|
||||
{
|
||||
bool bResult = tmp->InsertSilence(0.0, GetDuration());
|
||||
wxASSERT(bResult);
|
||||
return bResult;
|
||||
tmp->InsertSilence(0.0, GetDuration());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -163,9 +163,9 @@ bool EffectStereoToMono::ProcessOne(int count)
|
|||
}
|
||||
|
||||
double minStart = wxMin(mLeftTrack->GetStartTime(), mRightTrack->GetStartTime());
|
||||
bResult &= mLeftTrack->Clear(mLeftTrack->GetStartTime(), mLeftTrack->GetEndTime());
|
||||
mLeftTrack->Clear(mLeftTrack->GetStartTime(), mLeftTrack->GetEndTime());
|
||||
bResult &= mOutTrack->Flush();
|
||||
bResult &= mLeftTrack->Paste(minStart, mOutTrack.get());
|
||||
mLeftTrack->Paste(minStart, mOutTrack.get());
|
||||
mLeftTrack->SetLinked(false);
|
||||
mRightTrack->SetLinked(false);
|
||||
mLeftTrack->SetChannel(Track::MonoChannel);
|
||||
|
|
|
@ -1003,9 +1003,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
|||
newTrack->InsertSilence(0.0, t0 - t1);
|
||||
newTrack->Flush();
|
||||
wt->Clear(t1, t0);
|
||||
bool bResult = wt->Paste(t1, newTrack.get());
|
||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||
wxUnusedVar(bResult);
|
||||
wt->Paste(t1, newTrack.get());
|
||||
}
|
||||
recordingTracks.push_back(wt);
|
||||
// Don't record more channels than configured recording pref.
|
||||
|
|
Loading…
Reference in New Issue