LMMS
Loading...
Searching...
No Matches
Alg_track Class Reference

#include <allegro.h>

Inheritance diagram for Alg_track:
Alg_event_list Alg_events Alg_seq

Public Member Functions

void serialize_track ()
void unserialize_track ()
Alg_event_ptroperator[] (int i) override
 Alg_track ()
 Alg_track (Alg_time_map *map, bool seconds)
 initialize empty track with a time map
Alg_event_ptr copy_event (Alg_event_ptr event)
 make a complete copy
 Alg_track (Alg_track &track)
 Alg_track (Alg_event_list_ref event_list, Alg_time_map_ptr map, bool units_are_seconds)
 copy constructor: event_list is copied, map is installed and referenced
 ~Alg_track () override
virtual void serialize (void **buffer, long *bytes)
Alg_seq_ptr to_alg_seq ()
bool get_units_are_seconds ()
 Are we using beats or seconds?
virtual void convert_to_beats ()
 Change units.
virtual void convert_to_seconds ()
void set_dur (double dur)
double get_dur ()
virtual void set_time_map (Alg_time_map *map)
Alg_time_mapget_time_map ()
Alg_notecreate_note (double time, int channel, int identifier, float pitch, float loudness, double duration)
Alg_updatecreate_update (double time, int channel, int identifier)
virtual void add (Alg_event *event)
virtual Alg_trackcut (double t, double len, bool all)
virtual Alg_trackcopy (double t, double len, bool all)
void paste (double t, Alg_event_list *seq)
virtual void merge (double t, Alg_event_list_ptr seq)
virtual void clear (double t, double len, bool all)
virtual void silence (double t, double len, bool all)
virtual void insert_silence (double t, double len)
virtual Alg_event_listfind (double t, double len, bool all, long channel_mask, long event_type_mask)
virtual void set_in_use (bool flag)
Public Member Functions inherited from Alg_event_list
 Alg_event_list ()
 Alg_event_list (Alg_track *owner)
char get_type ()
Alg_trackget_owner ()
 ~Alg_event_list () override=default
double get_beat_dur ()
 Returns the duration of the sequence in beats or seconds.
void set_beat_dur (double d)
double get_real_dur ()
void set_real_dur (double d)
virtual void set_start_time (Alg_event *event, double)
const char * get_last_error_message ()
 get text description of run-time errors detected, clear error
Public Member Functions inherited from Alg_events
virtual int length ()
Alg_event_ptroperator[] (int i)
 Alg_events ()
virtual ~Alg_events ()
void set_events (Alg_event_ptr *e, long l, long m)
void insert (Alg_event_ptr event)
 for use by Alg_track and Alg_seq
void append (Alg_event_ptr event)
Alg_event_ptr uninsert (long index)

Static Public Member Functions

static Alg_trackunserialize (void *buffer, long len)

Protected Member Functions

char * get_string (char **p, long *b)
long get_int32 (char **p, long *b)
double get_double (char **p, long *b)
float get_float (char **p, long *b)
void serialize_parameter (Alg_parameter *parm)
void unserialize_parameter (Alg_parameter_ptr parm_ptr)

Protected Attributes

Alg_time_maptime_map
bool units_are_seconds
Protected Attributes inherited from Alg_event_list
char type
 'e' Alg_event_list, 't' Alg_track, 's' Alg_seq
Alg_trackevents_owner
 the events are owned by an Alg_track or an Alg_seq
int sequence_number
double beat_dur
double real_dur
Protected Attributes inherited from Alg_events
long len
Alg_event_ptrevents
 events is array of pointers

Static Protected Attributes

static Serial_read_buffer ser_read_buf
static Serial_write_buffer ser_write_buf
Static Protected Attributes inherited from Alg_event_list
static const char * last_error_message
static int sequences
 to keep track of sequence numbers

Additional Inherited Members

Public Attributes inherited from Alg_events
double last_note_off
bool in_use

Constructor & Destructor Documentation

◆ Alg_track() [1/4]

Alg_track::Alg_track ( )
inline

◆ Alg_track() [2/4]

Alg_track::Alg_track ( Alg_time_map * map,
bool seconds )

initialize empty track with a time map

◆ Alg_track() [3/4]

Alg_track::Alg_track ( Alg_track & track)

copy constructor, does not copy time_map

◆ Alg_track() [4/4]

Alg_track::Alg_track ( Alg_event_list_ref event_list,
Alg_time_map_ptr map,
bool units_are_seconds )

copy constructor: event_list is copied, map is installed and referenced

◆ ~Alg_track()

Alg_track::~Alg_track ( )
inlineoverride

note: do not call set_time_map(nullptr)!

Member Function Documentation

◆ add()

virtual void Alg_track::add ( Alg_event * event)
inlinevirtual

Adds a new event - it is automatically inserted into the correct order in the sequence based on its timestamp. The ownership passes from the caller to this Alg_seq. The event is not copied.

◆ clear()

void Alg_track::clear ( double t,
double len,
bool all )
virtual

Deletes and shifts notes to fill the gap. The tempo track is also modified accordingly. ONLY EVENTS THAT START WITHIN THE REGION ARE DELETED unless "all" is true, in which case all notes that intersect the region are cleared. NOTES THAT EXTEND FROM BEFORE THE REGION INTO THE REGION RETAIN THEIR DURATION IN EITHER BEATS OR SECONDS ACCORDING TO THE CURRENT UNITS OF this.

Reimplemented in Alg_seq.

◆ convert_to_beats()

void Alg_track::convert_to_beats ( )
virtual

Change units.

Reimplemented in Alg_seq.

◆ convert_to_seconds()

void Alg_track::convert_to_seconds ( )
virtual

Reimplemented in Alg_seq.

◆ copy()

Alg_track_ptr Alg_track::copy ( double t,
double len,
bool all )
virtual

Like cut() but doesn't remove the notes from the original sequence. The Alg_events are copied, not shared. ONLY EVENTS THAT START WITHIN THE REGION ARE COPIED unless "all" is true in which case all notes that intersect the region are copied. COPIED NOTES MAY EXTEND BEYOND THE DURATION OF THE RESULTING SEQ. The return type is the same as this (may be Alg_seq).

Reimplemented in Alg_seq.

◆ copy_event()

Alg_event_ptr Alg_track::copy_event ( Alg_event_ptr event)

make a complete copy

◆ create_note()

Alg_note * Alg_track::create_note ( double time,
int channel,
int identifier,
float pitch,
float loudness,
double duration )

Methods to create events. The returned event is owned by the caller. Use delete to get rid of it unless you call add() – see below.

◆ create_update()

Alg_update * Alg_track::create_update ( double time,
int channel,
int identifier )

Note: after create_update(), caller should use set_*_value() to initialize the attribute/value pair:

◆ cut()

Alg_track_ptr Alg_track::cut ( double t,
double len,
bool all )
virtual

Deletes the notes that start within the given region and returns them in a new sequence. The start times of the notes in the returned sequence are shifted by -t. The notes after the region get shifted over to fill the gap. In an Alg_seq, the tempo track is edited in a similar way and the cut tempo information is retained in the new seq. ONLY NOTES THAT START WITHIN THE REGION ARE CUT unless "all" is true in which case all notes that intersect the region are copied. CUT NOTES MAY EXTEND BEYOND THE DURATION OF THE RESULTING SEQ. The return type is the same as this (may be Alg_seq). All times including len are interpreted according to units_are_seconds in the track.

Reimplemented in Alg_seq.

◆ find()

Alg_event_list * Alg_track::find ( double t,
double len,
bool all,
long channel_mask,
long event_type_mask )
virtual

A useful generic function to retrieve only certain types of events. The masks should be bit-masks defined somewhere else. Part of the mask allows us to search for selected events. If this is an Alg_seq, search all tracks (otherwise, call track[i].find()) If channel_mask == 0, accept ALL channels

◆ get_double()

double Alg_track::get_double ( char ** p,
long * b )
protected

◆ get_dur()

double Alg_track::get_dur ( )
inline

◆ get_float()

float Alg_track::get_float ( char ** p,
long * b )
protected

◆ get_int32()

long Alg_track::get_int32 ( char ** p,
long * b )
protected

◆ get_string()

char * Alg_track::get_string ( char ** p,
long * b )
protected

◆ get_time_map()

Alg_time_map * Alg_track::get_time_map ( )
inline

◆ get_units_are_seconds()

bool Alg_track::get_units_are_seconds ( )
inline

Are we using beats or seconds?

◆ insert_silence()

void Alg_track::insert_silence ( double t,
double len )
virtual

Simply shifts notes past time t over by len, which is given in either beats or seconds according to the units of this. The resulting interveal (t, t+len) may in fact contain notes that begin before t. The durations of notes are not changed. If this is an Alg_seq, the tempo track is expanded at t also.

Reimplemented in Alg_seq.

◆ merge()

void Alg_track::merge ( double t,
Alg_event_list_ptr seq )
virtual

Merges two sequences with a certain offset. The offset is interpreted as either beats or seconds according to the current units of this, and seq is converted to the same units as this. Except for a possible conversion to beats or seconds, the tempo track of seq (if any) is ignored. (There is no way to merge tempo tracks.) THE SEQ PARAMETER IS NOT MODIFIED, AND Alg_event's ARE COPIED, NOT SHARED. The type of seq must be Alg_seq if seq is an Alg_seq, or Alg_track if seq is an Alg_track or an Alg_event_list.

Reimplemented in Alg_seq.

◆ operator[]()

Alg_event_ptr & Alg_track::operator[] ( int i)
inlineoverridevirtual

the client should not create one of these, but these are returned from various track and seq operations. An Alg_event_list "knows" the Alg_track or Alg_seq that "owns" the events. All events in an Alg_event_list must belong to the same Alg_track or Alg_seq structure. When applied to an Alg_seq, events are enumerated track by track with increasing indices. This operation is not particularly fast on an Alg_seq.

Reimplemented from Alg_event_list.

◆ paste()

void Alg_track::paste ( double t,
Alg_event_list * seq )

Inserts a sequence in the middle, shifting some notes over by the duration of the seq, which is first converted to the same units (seconds or beats) as this. (This makes a differece because the pasted data may change the tempo, and notes that overlap the borders will then experience a tempo change.) THE SEQ PARAMETER IS NOT MODIFIED, AND Alg_event's ARE COPIED, NOT SHARED. The type of seq must be Alg_seq if seq is an Alg_seq, or Alg_track if seq is an Alg_track or an Alg_event_list.

◆ serialize()

void Alg_track::serialize ( void ** buffer,
long * bytes )
virtual

Returns a buffer containing a serialization of the file. It will be an ASCII representation unless text is true. *buffer gets a newly allocated buffer pointer. The caller must free it. *len gets the length of the serialized track

Reimplemented in Alg_seq.

◆ serialize_parameter()

void Alg_track::serialize_parameter ( Alg_parameter * parm)
protected

◆ serialize_track()

void Alg_track::serialize_track ( )

◆ set_dur()

void Alg_track::set_dur ( double dur)

◆ set_in_use()

virtual void Alg_track::set_in_use ( bool flag)
inlinevirtual

Reimplemented in Alg_seq.

◆ set_time_map()

void Alg_track::set_time_map ( Alg_time_map * map)
virtual

Every Alg_track may have an associated time_map. If no map is specified, or if you set_time_map(nullptr), then the behavior should be as if there is a constant tempo of 100 beats/minute (this constant is determined by ALG_DEFAULT_BPM). Recommendation: create a static global tempo map object. When any operation that needs a tempo map gets nullptr, use the global tempo map. (Exception: any operation that would modify the tempo map should raise an error – you don't want to change the default tempo map.)

Reimplemented in Alg_seq.

◆ silence()

void Alg_track::silence ( double t,
double len,
bool all )
virtual

Deletes notes but doesn't shift. If the "all" argument is true, deletes all notes that intersect the range at all, not just those that start within it. The tempo track is not affected.

Reimplemented in Alg_seq.

◆ to_alg_seq()

Alg_seq_ptr Alg_track::to_alg_seq ( )
inline

If the track is really an Alg_seq and you need to access an Alg_seq method, coerce to an Alg_seq with this function:

◆ unserialize()

Alg_track * Alg_track::unserialize ( void * buffer,
long len )
static

Try to read from a memory buffer. Automatically guess whether it's MIDI or text.

◆ unserialize_parameter()

void Alg_track::unserialize_parameter ( Alg_parameter_ptr parm_ptr)
protected

*buffer_ptr points to binary data, bytes_ptr points to how many bytes have been used so far, len is length of binary data

◆ unserialize_track()

void Alg_track::unserialize_track ( )

Member Data Documentation

◆ ser_read_buf

Serial_read_buffer Alg_track::ser_read_buf
staticprotected

◆ ser_write_buf

Serial_write_buffer Alg_track::ser_write_buf
staticprotected

◆ time_map

Alg_time_map* Alg_track::time_map
protected

◆ units_are_seconds

bool Alg_track::units_are_seconds
protected

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