The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MIDI::XML::Track - MIDI Tracks.

SYNOPSIS

  use MIDI::XML::Track;
  use MIDI::XML::TrackName;

  $Track = MIDI::XML::Track->new();
  $Track->number(0);

  $Track_Name = MIDI::XML::TrackName->new();
  $Track_Name->delta(0);
  $Track_Name->text('Silent Night');
  $Track->append($Track_Name);
  $Track->append(MIDI::XML::TimeSignature->new(['time_signature',0,4,2,96,8]));


  @xml = $Track->as_MidiXML();
  print join("\n",@xml);

DESCRIPTION

MIDI::XML::Track is an object oriented class for representing tracks in Standard MIDI Files.

EXPORT

None.

METHODS AND ATTRIBUTES

$xml_track = MIDI::XML::Track->new();

This creates a new MIDI::XML::Track object.

$xml_track = MIDI::XML::NoteOn->new({'from_track' => $midi_track});

Creates a new Track object initialized with the events in a MIDI::Track object.

MIDI::XML::Track->register_subclass($event_name, $sub_class)

Registers a subclass the for MIDI::XML::Track objects to use to represent the named event. To work properly with the array methods the subclass name should be the same as the orignal name. For example:

$Track->register_subclass('sequencer_specific', 'MIDI::Huh::SequencerSpecific');

will allow the sequencer_specifics method to identify the subclass but

$Track->register_subclass('sequencer_specific', 'MIDI::Huh::SequinsAreSpecific');

will not.

$number = $Track->number() or $Track->number($number)

Returns or optionally sets the track number for the Track object.

$events = $Track->events()

Returns a reference to the array containing all the events associated with the track.

$Track->append($Event)

Appends an event to the event array in this MIDI::Xml:Track object.

$Track->append_from_track($track)

Appends the events in a MIDI::Track object to the event array in this MIDI::Xml:Track object.

$Track->make_times_absolute()

Converts the event times from delta values to absolute values.

$Track->make_times_delta()

Converts the event times from absolute values to delta values.

$array_ref = $Track->note_ons() or $Track->note_ons('refresh');

Returns a reference to an array of all NoteOn objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->note_offs() or $Track->note_offs('refresh');

Returns a reference to an array of all NoteOff objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->control_changes() or $Track->control_changes('refresh');

Returns a reference to an array of all ControlChange objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->program_changes() or $Track->program_changes('refresh');

Returns a reference to an array of all ProgramChange objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->key_aftertouches() or $Track->key_aftertouches('refresh');

Returns a reference to an array of all KeyAftertouch objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->channel_aftertouches() or $Track->channel_aftertouches('refresh');

Returns a reference to an array of all ChannelAftertouch objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->pitch_bend() or $Track->pitch_bend('refresh');

Returns a reference to an array of all PitchBend objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->sequence_numbers() or $Track->sequence_numbers('refresh');

Returns a reference to an array of all SequenceNumber objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->text_events() or $Track->text_events('refresh');

Returns a reference to an array of all TextEvent objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->copyrights() or $Track->copyrights('refresh');

Returns a reference to an array of all CopyrightNotice objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->track_names() or $Track->track_names('refresh');

Returns a reference to an array of all TrackName objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->instrument_names() or $Track->instrument_names('refresh');

Returns a reference to an array of all InstrumentName objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->lyrics() or $Track->lyrics('refresh');

Returns a reference to an array of all Lyric objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->markers() or $Track->markers('refresh');

Returns a reference to an array of all Marker objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->cue_points() or $Track->cue_points('refresh');

Returns a reference to an array of all CuePoint objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->program_names() or $Track->program_names('refresh');

Returns a reference to an array of all ProgramName objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->device_names() or $Track->device_names('refresh');

Returns a reference to an array of all DeviceName objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->ports() or $Track->ports('refresh');

Returns a reference to an array of all Port objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->channel_prefixes() or $Track->channel_prefixes('refresh');

Returns a reference to an array of all MidiChannelPrefix objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->ends_of_tracks() or $Track->ends_of_tracks('refresh');

Returns a reference to an array of all EndOfTrack objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->set_tempi() or $Track->set_tempi('refresh');

Returns a reference to an array of all SetTempo objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->smpte_offsets() or $Track->smpte_offsets('refresh');

Returns a reference to an array of all SmpteOffset objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->time_signatures() or $Track->time_signatures('refresh');

Returns a reference to an array of all TimeSignature objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->key_signatures() or $Track->key_signatures('refresh');

Returns a reference to an array of all KeySignature objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->sequencer_specifics() or $Track->sequencer_specifics('refresh');

Returns a reference to an array of all SequencerSpecific objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->meta_events() or $Track->meta_events('refresh');

Returns a reference to an array of all Port objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->system_exclusives() or $Track->system_exclusives('refresh');

Returns a reference to an array of all SystemExclusive objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$array_ref = $Track->ends_of_exclusives() or $Track->ends_of_exclusives('refresh');

Returns a reference to an array of all EndOfExclusive objects within the track. If called with any parameter the array is refreshed before the reference is returned.

$end = $Track->end() or $Track->end('refresh');

Returns the absolute time for the end of the track. If called with any parameter the value is refreshed before it is returned.

$Midi_track = $Track->as_midi_track();

Returns a reference to an array of all objects within the track.

@xml = $Track->as_MidiXML();

Returns an array of elements formatted according to the MidiXML DTD. These elements may be assembled by track into entire documents with the following suggested DOCTYPE declaration:

        <!DOCTYPE MIDI PUBLIC
                "-//Recordare//DTD MusicXML 0.7 MIDI//EN"
                "http://www.musicxml.org/dtds/midixml.dtd">

AUTHOR

Brian M. Ames, <bmames@apk.net>

SEE ALSO

MIDI::Track, MIDI::Event.

COPYRIGHT and LICENSE

Copyright 2002 Brian M. Ames. This software may be used under the terms of the GPL and Artistic licenses, the same as Perl itself.