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::TimeSignature - MIDI Time Signature messages.

SYNOPSIS

  use MIDI::XML::TimeSignature;
  $Time_Sig = MIDI::XML::TimeSignature->new();
  $Time_Sig->delta(0);
  $Time_Sig->numerator(4);
  $Time_Sig->logDenominator(2);
  $Time_Sig->midiClocksPerMetronomeClick(96);
  $Time_Sig->thirtySecondsPer24Clocks(8);
  @event = $Time_Sig->as_event();
  $midi_track = MIDI::Track->new();
  push( @{$midi_track->events_r},\@event;
  @xml = $Time_Sig->as_MidiXML();
  print join("\n",@xml);

DESCRIPTION

MIDI::XML::TimeSignature is a class encapsulating MIDI Time Signature meta messages. A Time Signature message includes either a delta time or absolute time as implemented by MIDI::XML::Message and the MIDI Time Signature event encoded in 7 bytes as follows:

0xFF 0x58 0x04 0xnn 0xpp 0xmm 0xqq

nn = numerator

pp = log(2) denominator

mm = clock signals per metronome pulse

qq = thirty-second notes per MIDI quarter notes

EXPORT

None.

METHODS AND ATTRIBUTES

$Time_Sig = MIDI::XML::TimeSignature->new()

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

$Time_Sig = MIDI::XML::TimeSignature->new($event);

Creates a new TimeSignature object initialized with the values of a MIDI::Event set_sequence_number array.

$delta_time = $Time_Sig->delta() or $Time_Sig->delta($delta_time);

Returns the message time as a delta time or undef if it is an absolute time. Optionally sets the message time to the specified delta time. To avoid contradictory times, the absolute time is set to undef when a delta time is set.

This functionality is provided by the MIDI::XML::Message base class.

$absolute_time = $Time_Sig->absolute() or $Time_Sig->absolute($absolute_time);

Returns the message time as an absolute time or undef if it is a delta time. Optionally sets the message time to the specified absolute time. To avoid contradictory times, the delta time is set to undef when an absolute time is set. The absolute time should be zero according to the specification.

This functionality is provided by the MIDI::XML::Message base class.

$time = $Time_Sig->time();

Returns the message time, absolute or delta, whichever was last set.

This functionality is provided by the MIDI::XML::Message base class.

$numerator = $Time_Sig->numerator() or $Time_Sig->numerator($numerator);

Returns and optionally sets the numerator.

$log_denominator = $Time_Sig->logDenominator() or $Time_Sig->logDenominator($log_denominator);

Returns and optionally sets the log Denominator.

$clocks = $Time_Sig->midiClocksPerMetronomeClick() or $Time_Sig->midiClocksPerMetronomeClick($clocks);

Returns and optionally sets the number of MIDI clocks per metronome click.

$ts = $Time_Sig->thirtySecondsPer24Clocks() or $Time_Sig->thirtySecondsPer24Clocks($ts);

Returns and optionally sets the number of thirty-second note per 24 MIDI clocks.

$ordinal = $Time_Sig->ordinal();

Returns a value to be used to order events that occur at the same time.

sub ordinal { my $self = shift; return 0x0050 ; }

#==========================================================================

@event = $Time_Sig->as_event();

Returns a MIDI::Event time_signature array initialized with the values of the TimeSignature object. MIDI::Event does not expect absolute times and will interpret them as delta times. Calling this method when the time is absolute will not generate a warning or error but it is unlikely that the results will be satisfactory.

@xml = $Time_Sig->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::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.