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

#include <allegro.h>

Inheritance diagram for Alg_seq:
Alg_track Alg_event_list Alg_events

Public Member Functions

void basic_initialization ()
 Alg_seq ()
 Alg_seq (Alg_track_ref track)
 Alg_seq (Alg_track_ptr track)
void seq_from_track (Alg_track_ref tr)
 Alg_seq (std::istream &file, bool smf, double *offset_ptr=nullptr)
 create from file:
 Alg_seq (const char *filename, bool smf, double *offset_ptr=nullptr)
 create from filename
 ~Alg_seq () override
int get_read_error ()
void serialize (void **buffer, long *bytes) override
void copy_time_sigs_to (Alg_seq *dest)
 a utility function
void set_time_map (Alg_time_map *map) override
void unserialize_seq ()
void write (std::ostream &file, bool in_secs, double offset=0.0)
 write an ascii representation to file
bool write (const char *filename, double offset=0.0)
 returns true on success
void smf_write (std::ostream &file)
bool smf_write (const char *filename)
int tracks ()
 Returns the number of tracks.
void add_track (int track_num)
 create a track
Alg_track_ptr track (int)
Alg_event_ptroperator[] (int i) override
void convert_to_seconds () override
void convert_to_beats () override
 Change units.
Alg_track_ptr cut_from_track (int track_num, double start, double dur, bool all)
Alg_seqcut (double t, double len, bool all) override
void insert_silence_in_track (int track_num, double t, double len)
void insert_silence (double t, double len) override
Alg_track_ptr copy_track (int track_num, double t, double len, bool all)
Alg_seqcopy (double start, double len, bool all) override
void paste (double start, Alg_seq *seq)
void clear (double t, double len, bool all) override
void merge (double t, Alg_event_list_ptr seq) override
void silence (double t, double len, bool all) override
void clear_track (int track_num, double start, double len, bool all)
void silence_track (int track_num, double start, double len, bool all)
Alg_event_list_ptr find_in_track (int track_num, double t, double len, bool all, long channel_mask, long event_type_mask)
long seek_time (double time, int track_num)
 find index of first score event after time
bool insert_beat (double time, double beat)
double nearest_beat_time (double time, double *beat)
bool insert_tempo (double bpm, double beat)
 warning: insert_tempo may change representation from seconds to beats
bool stretch_region (double b0, double b1, double dur)
void add_event (Alg_event_ptr event, int track_num)
void add (Alg_event_ptr) override
double get_tempo (double beat)
 get the tempo starting at beat
bool set_tempo (double bpm, double start_beat, double end_beat)
double get_bar_len (double beat)
 get the bar length in beats starting at beat
void set_time_sig (double beat, double num, double den)
void beat_to_measure (double beat, long *measure, double *m_beat, double *num, double *den)
void merge_tracks ()
 void set_events(Alg_event_ptr *events, long len, long max);
void set_in_use (bool flag) override
 set in_use flag on all tracks
Public Member Functions inherited from Alg_track
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
Alg_seq_ptr to_alg_seq ()
bool get_units_are_seconds ()
 Are we using beats or seconds?
void set_dur (double dur)
double get_dur ()
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)
void paste (double t, Alg_event_list *seq)
virtual Alg_event_listfind (double t, double len, bool all, long channel_mask, long event_type_mask)
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)

Public Attributes

int channel_offset_per_track
 used to encode track_num into channel
Alg_tracks track_list
 array of Alg_events
Alg_time_sigs time_sig
int beat_x
Public Attributes inherited from Alg_events
double last_note_off
bool in_use

Protected Member Functions

void serialize_seq ()
Alg_event_ptr write_track_name (std::ostream &file, int n, Alg_events &events)
 an internal function used for writing Allegro track names
Protected Member Functions inherited from Alg_track
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_iterator_ptr pending
 iterator used internally by Alg_seq methods
Alg_error error
Protected Attributes inherited from Alg_track
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

Additional Inherited Members

Static Public Member Functions inherited from Alg_track
static Alg_trackunserialize (void *buffer, long len)
Static Protected Attributes inherited from Alg_track
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

Detailed Description

An Alg_seq is an array of Alg_events, each a sequence of Alg_event, with a tempo map and a sequence of time signatures

see Alg_seq::Alg_seq() constructors that read from files the following are for internal library implementation and are moved to *_internal.h header files. Alg_seq_ptr alg_read(std::istream &file, Alg_seq_ptr new_seq); Alg_seq_ptr alg_smf_read(std::istream &file, Alg_seq_ptr new_seq);

Constructor & Destructor Documentation

◆ Alg_seq() [1/5]

Alg_seq::Alg_seq ( )
inline

◆ Alg_seq() [2/5]

Alg_seq::Alg_seq ( Alg_track_ref track)
inline

copy constructor – if track is an Alg_seq, make a copy; if track is just an Alg_track, the track becomes track 0

◆ Alg_seq() [3/5]

Alg_seq::Alg_seq ( Alg_track_ptr track)
inline

◆ Alg_seq() [4/5]

Alg_seq::Alg_seq ( std::istream & file,
bool smf,
double * offset_ptr = nullptr )

create from file:

◆ Alg_seq() [5/5]

Alg_seq::Alg_seq ( const char * filename,
bool smf,
double * offset_ptr = nullptr )

create from filename

◆ ~Alg_seq()

Alg_seq::~Alg_seq ( )
override

Member Function Documentation

◆ add()

void Alg_seq::add ( Alg_event_ptr )
inlineoverride

call add_event instead

◆ add_event()

void Alg_seq::add_event ( Alg_event_ptr event,
int track_num )

add_event takes a pointer to an event on the heap. The event is not copied, and this Alg_seq becomes the owner and freer of the event.

◆ add_track()

void Alg_seq::add_track ( int track_num)
inline

create a track

◆ basic_initialization()

void Alg_seq::basic_initialization ( )
inline

◆ beat_to_measure()

void Alg_seq::beat_to_measure ( double beat,
long * measure,
double * m_beat,
double * num,
double * den )

◆ clear()

void Alg_seq::clear ( double t,
double len,
bool all )
overridevirtual

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 from Alg_track.

◆ clear_track()

void Alg_seq::clear_track ( int track_num,
double start,
double len,
bool all )

◆ convert_to_beats()

void Alg_seq::convert_to_beats ( )
overridevirtual

Change units.

Reimplemented from Alg_track.

◆ convert_to_seconds()

void Alg_seq::convert_to_seconds ( )
overridevirtual

Reimplemented from Alg_track.

◆ copy()

Alg_seq * Alg_seq::copy ( double t,
double len,
bool all )
overridevirtual

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 from Alg_track.

◆ copy_time_sigs_to()

void Alg_seq::copy_time_sigs_to ( Alg_seq * dest)

a utility function

◆ copy_track()

Alg_track_ptr Alg_seq::copy_track ( int track_num,
double t,
double len,
bool all )

◆ cut()

Alg_seq_ptr Alg_seq::cut ( double t,
double len,
bool all )
overridevirtual

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 from Alg_track.

◆ cut_from_track()

Alg_track_ptr Alg_seq::cut_from_track ( int track_num,
double start,
double dur,
bool all )

◆ find_in_track()

Alg_event_list_ptr Alg_seq::find_in_track ( int track_num,
double t,
double len,
bool all,
long channel_mask,
long event_type_mask )

◆ get_bar_len()

double Alg_seq::get_bar_len ( double beat)

get the bar length in beats starting at beat

◆ get_read_error()

int Alg_seq::get_read_error ( )
inline

◆ get_tempo()

double Alg_seq::get_tempo ( double beat)

get the tempo starting at beat

◆ insert_beat()

bool Alg_seq::insert_beat ( double time,
double beat )

◆ insert_silence()

void Alg_seq::insert_silence ( double t,
double len )
overridevirtual

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 from Alg_track.

◆ insert_silence_in_track()

void Alg_seq::insert_silence_in_track ( int track_num,
double t,
double len )

◆ insert_tempo()

bool Alg_seq::insert_tempo ( double bpm,
double beat )

warning: insert_tempo may change representation from seconds to beats

◆ merge()

void Alg_seq::merge ( double t,
Alg_event_list_ptr seq )
overridevirtual

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 from Alg_track.

◆ merge_tracks()

void Alg_seq::merge_tracks ( )

void set_events(Alg_event_ptr *events, long len, long max);

move all track data into one track

◆ nearest_beat_time()

double Alg_seq::nearest_beat_time ( double time,
double * beat )

return the time of the beat nearest to time, also returns beat number through beat. This will correspond to an integer number of beats from the nearest previous time signature or 0.0, but since time signatures need not be on integer beat boundaries the beat location may not be on an integer beat (beat locations are measured from the beginning which is beat 0.

◆ operator[]()

Alg_event_ptr & Alg_seq::operator[] ( int i)
overridevirtual

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_seq::paste ( double start,
Alg_seq * seq )

◆ seek_time()

long Alg_seq::seek_time ( double time,
int track_num )

find index of first score event after time

◆ seq_from_track()

void Alg_seq::seq_from_track ( Alg_track_ref tr)

◆ serialize()

void Alg_seq::serialize ( void ** buffer,
long * bytes )
overridevirtual

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 from Alg_track.

◆ serialize_seq()

void Alg_seq::serialize_seq ( )
protected

◆ set_in_use()

void Alg_seq::set_in_use ( bool flag)
overridevirtual

set in_use flag on all tracks

Reimplemented from Alg_track.

◆ set_tempo()

bool Alg_seq::set_tempo ( double bpm,
double start_beat,
double end_beat )

◆ set_time_map()

void Alg_seq::set_time_map ( Alg_time_map * map)
overridevirtual

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 from Alg_track.

◆ set_time_sig()

void Alg_seq::set_time_sig ( double beat,
double num,
double den )

◆ silence()

void Alg_seq::silence ( double t,
double len,
bool all )
overridevirtual

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 from Alg_track.

◆ silence_track()

void Alg_seq::silence_track ( int track_num,
double start,
double len,
bool all )

◆ smf_write() [1/2]

bool Alg_seq::smf_write ( const char * filename)

◆ smf_write() [2/2]

void Alg_seq::smf_write ( std::ostream & file)

◆ stretch_region()

bool Alg_seq::stretch_region ( double b0,
double b1,
double dur )

change the duration from b0 to b1 (beats) to dur (seconds) by scaling the intervening tempos

◆ track()

Alg_track_ptr Alg_seq::track ( int i)

Return a particular track. This Alg_seq owns the track, so the caller must not delete the result.

◆ tracks()

int Alg_seq::tracks ( )

Returns the number of tracks.

◆ unserialize_seq()

void Alg_seq::unserialize_seq ( )

encode sequence structure into contiguous, moveable memory block address of newly allocated memory is assigned to *buffer, which must be freed by caller; the length of data is assigned to *len

◆ write() [1/2]

bool Alg_seq::write ( const char * filename,
double offset = 0.0 )

returns true on success

◆ write() [2/2]

void Alg_seq::write ( std::ostream & file,
bool in_secs,
double offset = 0.0 )

write an ascii representation to file

◆ write_track_name()

Alg_event_ptr Alg_seq::write_track_name ( std::ostream & file,
int n,
Alg_events & events )
protected

an internal function used for writing Allegro track names

Member Data Documentation

◆ beat_x

int Alg_seq::beat_x

◆ channel_offset_per_track

int Alg_seq::channel_offset_per_track

used to encode track_num into channel

◆ error

Alg_error Alg_seq::error
protected

error code set by file readers

◆ pending

Alg_iterator_ptr Alg_seq::pending
protected

iterator used internally by Alg_seq methods

◆ time_sig

Alg_time_sigs Alg_seq::time_sig

◆ track_list

Alg_tracks Alg_seq::track_list

array of Alg_events


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