mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-10 16:43:33 +02:00
More pure virtuals in Track, supply Note and Time overrides
This commit is contained in:
@@ -534,6 +534,18 @@ bool NoteTrack::Paste(double t, const Track *src)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NoteTrack::Silence(double, double)
|
||||||
|
{
|
||||||
|
// to do
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NoteTrack::InsertSilence(double, double)
|
||||||
|
{
|
||||||
|
// to do
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Call this function to manipulate the underlying sequence data. This is
|
// Call this function to manipulate the underlying sequence data. This is
|
||||||
// NOT the function that handles horizontal dragging.
|
// NOT the function that handles horizontal dragging.
|
||||||
bool NoteTrack::Shift(double t) // t is always seconds
|
bool NoteTrack::Shift(double t) // t is always seconds
|
||||||
|
@@ -105,6 +105,8 @@ class AUDACITY_DLL_API NoteTrack final
|
|||||||
bool Trim (double t0, double t1) /* not override */;
|
bool Trim (double t0, double t1) /* not override */;
|
||||||
bool Clear(double t0, double t1) override;
|
bool Clear(double t0, double t1) override;
|
||||||
bool Paste(double t, const Track *src) override;
|
bool Paste(double t, const Track *src) override;
|
||||||
|
bool Silence(double t0, double t1) override;
|
||||||
|
bool InsertSilence(double t, double len) override;
|
||||||
bool Shift(double t) /* not override */;
|
bool Shift(double t) /* not override */;
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||||
|
@@ -63,20 +63,24 @@ TimeTrack::TimeTrack(const std::shared_ptr<DirManager> &projDirManager, const Zo
|
|||||||
blankPen.SetColour(214, 214, 214);
|
blankPen.SetColour(214, 214, 214);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeTrack::TimeTrack(const TimeTrack &orig):
|
TimeTrack::TimeTrack(const TimeTrack &orig, double *pT0, double *pT1)
|
||||||
Track(orig)
|
: Track(orig)
|
||||||
, mZoomInfo(orig.mZoomInfo)
|
, mZoomInfo(orig.mZoomInfo)
|
||||||
{
|
{
|
||||||
Init(orig); // this copies the TimeTrack metadata (name, range, etc)
|
Init(orig); // this copies the TimeTrack metadata (name, range, etc)
|
||||||
|
|
||||||
///@TODO: Give Envelope:: a copy-constructor instead of this?
|
///@TODO: Give Envelope:: a copy-constructor instead of this?
|
||||||
mEnvelope = std::make_unique<Envelope>();
|
mEnvelope = std::make_unique<Envelope>();
|
||||||
|
mEnvelope->Flatten(1.0);
|
||||||
mEnvelope->SetTrackLen(DBL_MAX);
|
mEnvelope->SetTrackLen(DBL_MAX);
|
||||||
SetInterpolateLog(orig.GetInterpolateLog()); // this calls Envelope::SetInterpolateDB
|
SetInterpolateLog(orig.GetInterpolateLog()); // this calls Envelope::SetInterpolateDB
|
||||||
mEnvelope->Flatten(1.0);
|
|
||||||
mEnvelope->SetOffset(0);
|
mEnvelope->SetOffset(0);
|
||||||
mEnvelope->SetRange(orig.mEnvelope->GetMinValue(), orig.mEnvelope->GetMaxValue());
|
mEnvelope->SetRange(orig.mEnvelope->GetMinValue(), orig.mEnvelope->GetMaxValue());
|
||||||
mEnvelope->Paste(0.0, orig.mEnvelope.get());
|
if ( pT0 && pT1 )
|
||||||
|
// restricted copy
|
||||||
|
mEnvelope->CopyFrom(orig.mEnvelope.get(), *pT0, *pT1);
|
||||||
|
else
|
||||||
|
mEnvelope->Paste(0.0, orig.mEnvelope.get());
|
||||||
|
|
||||||
///@TODO: Give Ruler:: a copy-constructor instead of this?
|
///@TODO: Give Ruler:: a copy-constructor instead of this?
|
||||||
mRuler = std::make_unique<Ruler>();
|
mRuler = std::make_unique<Ruler>();
|
||||||
@@ -103,6 +107,45 @@ TimeTrack::~TimeTrack()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Track::Holder TimeTrack::Cut( double t0, double t1 )
|
||||||
|
{
|
||||||
|
auto result = Copy( t0, t1, false );
|
||||||
|
Clear( t0, t1 );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Track::Holder TimeTrack::Copy( double t0, double t1, bool ) const
|
||||||
|
{
|
||||||
|
auto result = std::make_unique<TimeTrack>( *this, &t0, &t1 );
|
||||||
|
return Track::Holder{ std::move( result ) };
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TimeTrack::Clear(double t0, double t1)
|
||||||
|
{
|
||||||
|
mEnvelope->CollapseRegion(t0, t1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TimeTrack::Paste(double t, const Track * src)
|
||||||
|
{
|
||||||
|
if (src->GetKind() != Track::Time)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mEnvelope->Paste(t, static_cast<const TimeTrack*>(src)->mEnvelope.get());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TimeTrack::Silence(double t0, double t1)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TimeTrack::InsertSilence(double t, double len)
|
||||||
|
{
|
||||||
|
mEnvelope->InsertSpace(t, len);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Track::Holder TimeTrack::Duplicate() const
|
Track::Holder TimeTrack::Duplicate() const
|
||||||
{
|
{
|
||||||
return std::make_unique<TimeTrack>(*this);
|
return std::make_unique<TimeTrack>(*this);
|
||||||
|
@@ -34,11 +34,20 @@ class TimeTrack final : public Track {
|
|||||||
* Envelope:: and Ruler:: members in order to copy one to the other - unfortunately both lack a
|
* Envelope:: and Ruler:: members in order to copy one to the other - unfortunately both lack a
|
||||||
* copy-constructor to encapsulate this.
|
* copy-constructor to encapsulate this.
|
||||||
* @param orig The original track to copy from
|
* @param orig The original track to copy from
|
||||||
|
* @param pT0 if not null, then the start of the sub-range to copy
|
||||||
|
* @param pT1 if not null, then the end of the sub-range to copy
|
||||||
*/
|
*/
|
||||||
TimeTrack(const TimeTrack &orig);
|
TimeTrack(const TimeTrack &orig, double *pT0 = nullptr, double *pT1 = nullptr);
|
||||||
|
|
||||||
virtual ~TimeTrack();
|
virtual ~TimeTrack();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
// Identifying the type of track
|
// Identifying the type of track
|
||||||
int GetKind() const override { return Time; }
|
int GetKind() const override { return Time; }
|
||||||
|
|
||||||
|
19
src/Track.h
19
src/Track.h
@@ -206,28 +206,29 @@ class AUDACITY_DLL_API Track /* not final */ : public XMLTagHandler
|
|||||||
// separate from the Track.
|
// separate from the Track.
|
||||||
const std::shared_ptr<DirManager> &GetDirManager() const { return mDirManager; }
|
const std::shared_ptr<DirManager> &GetDirManager() const { return mDirManager; }
|
||||||
|
|
||||||
// Create a NEW track and modify this track (or return null for failure)
|
// Create a NEW track and modify this track
|
||||||
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1)) { return{}; }
|
// Return non-NULL or else throw
|
||||||
|
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
|
||||||
|
|
||||||
// Create a NEW track and don't modify this track (or return null for failure)
|
// Create a NEW track and don't modify this track
|
||||||
|
// Return non-NULL or else throw
|
||||||
// Note that subclasses may want to distinguish tracks stored in a clipboard
|
// Note that subclasses may want to distinguish tracks stored in a clipboard
|
||||||
// from those stored in a project
|
// from those stored in a project
|
||||||
virtual Holder Copy
|
virtual Holder Copy
|
||||||
(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard = true) const
|
(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard = true) const = 0;
|
||||||
{ return{}; }
|
|
||||||
|
|
||||||
// Return true for success
|
// Return true for success
|
||||||
virtual bool Clear(double WXUNUSED(t0), double WXUNUSED(t1)) {return false;}
|
virtual bool Clear(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
|
||||||
|
|
||||||
// Return true for success
|
// Return true for success
|
||||||
virtual bool Paste(double WXUNUSED(t), const Track * WXUNUSED(src)) {return false;}
|
virtual bool Paste(double WXUNUSED(t), const Track * WXUNUSED(src)) = 0;
|
||||||
|
|
||||||
// This can be used to adjust a sync-lock selected track when the selection
|
// This can be used to adjust a sync-lock selected track when the selection
|
||||||
// is replaced by one of a different length.
|
// is replaced by one of a different length.
|
||||||
virtual bool SyncLockAdjust(double oldT1, double newT1);
|
virtual bool SyncLockAdjust(double oldT1, double newT1);
|
||||||
|
|
||||||
virtual bool Silence(double WXUNUSED(t0), double WXUNUSED(t1)) {return false;}
|
virtual bool Silence(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
|
||||||
virtual bool InsertSilence(double WXUNUSED(t), double WXUNUSED(len)) {return false;}
|
virtual bool InsertSilence(double WXUNUSED(t), double WXUNUSED(len)) = 0;
|
||||||
|
|
||||||
virtual int GetKind() const { return None; }
|
virtual int GetKind() const { return None; }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user