Beatmup
Beatmup::Fragments::Sequence Class Referenceabstract

Fragmented signal in time domain. More...

#include <sequence.h>

Inheritance diagram for Beatmup::Fragments::Sequence:
Beatmup::Object Beatmup::Fragments::SequenceToolkit< Signal > Beatmup::Fragments::SequenceToolkit< T > Beatmup::Audio::Signal

Classes

class  AccessException
 
class  Pointer
 Points to a position within a sequence. More...
 

Public Member Functions

const dtime getDuration () const
 Returns sequence duration in number of samples. More...
 
bool isEmpty () const
 Returns true if sequence contains no samples. More...
 
void clear ()
 Removes the content of the sequence making it empty (of zero duration). More...
 
void shrink (dtime timeLeft, dtime timeRight)
 Shrinks the sequence to given time bounds. More...
 
Sequencecopy (dtime fromTime, dtime toTime) const
 Copies a given piece of the current sequence into new Sequence. More...
 
void insert (const Sequence &sequence, dtime time)
 Inserts a Sequence at a given position in time. More...
 
void remove (dtime fromTime, dtime toTime)
 Erases a part of the sequence between two given time moments. More...
 
void split (dtime time, Sequence *left, Sequence *right) const
 Splits the sequence in two at a specific time. More...
 
- Public Member Functions inherited from Beatmup::Object
virtual ~Object ()
 

Protected Member Functions

 Sequence ()
 
virtual ~Sequence ()
 
virtual SequencecreateEmpty () const =0
 Initializes an empty sequence, used to bootstrap copying operations. More...
 
void concatenate (Fragment &fragment, dtime offset, dtime length)
 Adds a new fragment at the end of the sequence. More...
 
void syncPointers ()
 Resets pointers once the sequence changes to keep them consistent. More...
 

Private Member Functions

int findFragment (dtime time) const
 Log search for a fragment containing given time moment. More...
 
void splitFragment (int index, dtime delta)
 Splits a given fragment in two. More...
 

Private Attributes

std::vector< FragmentPtrfragments
 the content More...
 
std::vector< dtimecumTimes
 cumulative sum of fragment lengths, starts from 0, of N+1 entries (N = num. of fragments) More...
 
std::vector< Pointer * > pointers
 pointers currently accessing the sequence More...
 

Static Private Attributes

static const int VOID_LEFT = -123
 returned by getFragment() when the entire sequence is on the right of the given time moment More...
 
static const int VOID_RIGHT = -456
 returned by getFragment() when the entire sequence is on the left of the given time moment More...
 

Detailed Description

Fragmented signal in time domain.

Implements basic editing operations (copy, paste, cut in two, shrink, etc.). Operations are performed on the set of fragments, but not directly to the signal content in memory.

Definition at line 33 of file sequence.h.

Constructor & Destructor Documentation

◆ Sequence()

Beatmup::Fragments::Sequence::Sequence ( )
protected

◆ ~Sequence()

virtual Beatmup::Fragments::Sequence::~Sequence ( )
protectedvirtual

Member Function Documentation

◆ findFragment()

int Beatmup::Fragments::Sequence::findFragment ( dtime  time) const
private

Log search for a fragment containing given time moment.

Returns
a valid fragment index if available, VOID_LEFT or VOID_RIGHT otherwise

◆ splitFragment()

void Beatmup::Fragments::Sequence::splitFragment ( int  index,
dtime  delta 
)
private

Splits a given fragment in two.

Does not recompute the cumulative time index.

Parameters
indexthe fragment index
deltaadditional offset w.r.t. fragment internal offset specifying where to split

◆ createEmpty()

virtual Sequence* Beatmup::Fragments::Sequence::createEmpty ( ) const
protectedpure virtual

Initializes an empty sequence, used to bootstrap copying operations.

Implemented in Beatmup::Audio::Signal.

◆ concatenate()

void Beatmup::Fragments::Sequence::concatenate ( Fragment fragment,
dtime  offset,
dtime  length 
)
protected

Adds a new fragment at the end of the sequence.

◆ syncPointers()

void Beatmup::Fragments::Sequence::syncPointers ( )
protected

Resets pointers once the sequence changes to keep them consistent.

◆ getDuration()

const dtime Beatmup::Fragments::Sequence::getDuration ( ) const
inline

Returns sequence duration in number of samples.

Definition at line 123 of file sequence.h.

123 { return cumTimes.back(); }
std::vector< dtime > cumTimes
cumulative sum of fragment lengths, starts from 0, of N+1 entries (N = num. of fragments)
Definition: sequence.h:80

◆ isEmpty()

bool Beatmup::Fragments::Sequence::isEmpty ( ) const
inline

Returns true if sequence contains no samples.

Definition at line 128 of file sequence.h.

128 { return getDuration() == 0; }
const dtime getDuration() const
Returns sequence duration in number of samples.
Definition: sequence.h:123

◆ clear()

void Beatmup::Fragments::Sequence::clear ( )

Removes the content of the sequence making it empty (of zero duration).

◆ shrink()

void Beatmup::Fragments::Sequence::shrink ( dtime  timeLeft,
dtime  timeRight 
)

Shrinks the sequence to given time bounds.

Parameters
timeLeftLeft limit to shrink to (included), i.e., the earliest time moment from which the new (shrinked) sequence will begin
timeRightRight limit to shrink to (excluded)

◆ copy()

Sequence* Beatmup::Fragments::Sequence::copy ( dtime  fromTime,
dtime  toTime 
) const

Copies a given piece of the current sequence into new Sequence.

Parameters
fromTimeThe beginning of the piece to copy (included in the resulting sequence)
toTimeThe end of the piece (excluded from the resulting sequence)

◆ insert()

void Beatmup::Fragments::Sequence::insert ( const Sequence sequence,
dtime  time 
)

Inserts a Sequence at a given position in time.

Parameters
sequenceThe sequence to insert
timeThe time to insert from

◆ remove()

void Beatmup::Fragments::Sequence::remove ( dtime  fromTime,
dtime  toTime 
)

Erases a part of the sequence between two given time moments.

Parameters
fromTimeThe beginning of the part to remove
toTimeThe end of the part to remove

◆ split()

void Beatmup::Fragments::Sequence::split ( dtime  time,
Sequence left,
Sequence right 
) const

Splits the sequence in two at a specific time.

Creates two new Sequence instances. The content of the current sequence remains unchanged.

Parameters
timeThe time moment to cut at
leftThe left part of the split
rightThe right part of the split

Member Data Documentation

◆ fragments

std::vector<FragmentPtr> Beatmup::Fragments::Sequence::fragments
private

the content

Definition at line 79 of file sequence.h.

◆ cumTimes

std::vector<dtime> Beatmup::Fragments::Sequence::cumTimes
private

cumulative sum of fragment lengths, starts from 0, of N+1 entries (N = num. of fragments)

Definition at line 80 of file sequence.h.

◆ pointers

std::vector<Pointer*> Beatmup::Fragments::Sequence::pointers
private

pointers currently accessing the sequence

Definition at line 81 of file sequence.h.

◆ VOID_LEFT

const int Beatmup::Fragments::Sequence::VOID_LEFT = -123
staticprivate

returned by getFragment() when the entire sequence is on the right of the given time moment

Definition at line 97 of file sequence.h.

◆ VOID_RIGHT

const int Beatmup::Fragments::Sequence::VOID_RIGHT = -456
staticprivate

returned by getFragment() when the entire sequence is on the left of the given time moment

Definition at line 98 of file sequence.h.


The documentation for this class was generated from the following file: