Package midi :: Class SysExEvent
[hide private]
[frames] | no frames]

Class SysExEvent

source code

object --+    
         |    
     Event --+
             |
            SysExEvent

System exclusive MIDI event. Generic event type for sending data to a system in a format that it recognizes, but which may not be recognized by any other device.

Some standards are defined for sub-event types of sysex. Tuning messages are one example. This class implements encoding/decoding for tuning messages.

Other sysex events are treated just as raw data, between the initial F0 and the final F7.


To Do: we should possibly terminate the sysex data on finding any 1-initial byte. Sysex messages are supposed to end with a 0xF7, but the data can only contain 0-initial bytes (7-bit values).

Nested Classes [hide private]

Inherited from Event: __metaclass__

Instance Methods [hide private]
 
decode(self, tick, statusmsg, track, runningstatus='')
Reads MIDI data from the track stream, from which the tick and status message have already been read.
source code
 
encode(self, last_tick=0, running=False)
Produces an encoding of this event for writing to a MIDI stream.
source code
 
decode_data(self)
Takes the data that's been read into data instance variable and sets instance attributes from the values in it.
source code
 
encode_data(self)
Produces byte data to represent this event on the basis of instance variables.
source code
 
init_subtype(self, subtype) source code
 
__str__(self)
str(x)
source code

Inherited from Event: __cmp__, __init__, adjust_msdelay, copy, encode_delta_tick

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]
 
is_event(cls, statusmsg)
Checks whether this is of an event identified by the given status message.
source code
Class Variables [hide private]
  statusmsg = 240
  name = 'SysEx'
  subtype = 0
  allow_running = False
  SUBTYPE_NONE = 0
  SUBTYPE_SINGLE_NOTE_TUNING_CHANGE = 1
  data = ''
Data stored in the SysEx.

Inherited from Event: length

Instance Variables [hide private]

Inherited from Event: channel, msdelay, order, tick, track, type

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

is_event(cls, statusmsg)
Class Method

source code 

Checks whether this is of an event identified by the given status message.

Overrides: Event.is_event
(inherited documentation)

decode(self, tick, statusmsg, track, runningstatus='')

source code 

Reads MIDI data from the track stream, from which the tick and status message have already been read. Removes as many bytes from the track as this event type needs. Sets instance variables according to data read from the stream.

Parameters:
  • tick - tick time of the event (already read from the stream)
  • statusmsg - the status message that was read from the stream for this event. This is expected to be of the correct type for this event type.
  • track - data stream from which to continue reading as much data as is needed for this event.
  • runningstatus - if this event had a running status in the input stream, the byte that was read off the stream to try to get a status for this event (which turned out not to be a status message) goes in here and gets treated as the first byte of the data.
Overrides: Event.decode
(inherited documentation)

encode(self, last_tick=0, running=False)

source code 

Produces an encoding of this event for writing to a MIDI stream. Includes the delta and status message.

Parameters:
  • last_tick - tick value of the previous event that was encoded in the stream. The timing of this event will be stored as a delta, so we need to know when the last thing happened.
  • running - omits the status message if true, since it is assumed that the status is carried over from the previous event.
Overrides: Event.encode
(inherited documentation)

decode_data(self)

source code 

Takes the data that's been read into data instance variable and sets instance attributes from the values in it. What this does is specific to the event type.

At the simplest, it could do nothing, just leaving the raw data in data, but more likely it will decode values from the data.

Overrides: Event.decode_data
(inherited documentation)

encode_data(self)

source code 

Produces byte data to represent this event on the basis of instance variables. This is the data that will be written to a MIDI stream (not including the tick and status message).

Returns:
byte data as a string
Overrides: Event.encode_data
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Class Variable Details [hide private]

data

Data stored in the SysEx. This can be any data in a format that the device will recognise.

Value:
''