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::SmpteOffset - MIDI SMPTE Offset messages.

SYNOPSIS

  use MIDI::XML::SmpteOffset;
  $Offset = MIDI::XML::SmpteOffset->new();
  $Offset->delta(0);
  $Offset->time_code_type(3);
  $Offset->hour(1);
  $Offset->minute(15);
  $Offset->second(6);
  $Offset->frame(2);
  $Offset->fractional_frame(9);
  @event = $Offset->as_event();
  $midi_track = MIDI::Track->new();
  push( @{$midi_track->events_r},\@event;
  @xml = $Offset->as_MidiXML();
  print join("\n",@xml);

DESCRIPTION

MIDI::XML::SmpteOffset is a class encapsulating MIDI SMPTE Offset meta messages. A SMPTE Offset message includes either a delta time or absolute time as implemented by MIDI::XML::Message and the MIDI SMPTE Offset event encoded in 8 bytes as follows:

0xFF 0x54 0x05 0xhh 0xmm 0xss 0xrr 0xpp

hh = frame rate + hours (0rrhhhhh)

mm = minutes

ss = seconds

rr = frames

pp =

EXPORT

None by default.

METHODS AND ATTRIBUTES

$Offset = MIDI::XML::SmpteOffset->new()

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

$Offset = MIDI::XML::SmpteOffset->new($event);

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

$delta_time = $Offset->delta() or $Offset->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 = $Offset->absolute() or $Offset->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 = $Offset->time();

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

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

$time_code_type = $Offset->time_code_type() or $Offset->time_code_type($time_code_type);
$hour = $Offset->hour() or $Offset->hour($hour);
$minute = $Offset->minute() or $Offset->minute($minute);
$second = $Offset->second() or $Offset->second($second);
$frame = $Offset->frame() or $Offset->frame($frame);
$fraction = $Offset->fractional_frame() or $Offset->fractional_frame($fraction);
$ordinal = $Offset->ordinal();

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

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

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

@event = $Offset->as_event();

Returns a MIDI::Event smpte_offset array initialized with the values of the SmpteOffset 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 = $Offset->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.