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

Class Event

source code

object --+
         |
        Event
Known Subclasses:

Base class for all MIDI events.

Nested Classes [hide private]
  __metaclass__
Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
copy(self) source code
 
__str__(self)
str(x)
source code
 
__cmp__(self, other) source code
 
adjust_msdelay(self, tempo) source code
 
encode(self, last_tick=0, running=False)
Produces an encoding of this event for writing to a MIDI stream.
source code
 
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_delta_tick(self, last_tick=0)
this function should be renamed "encode_delta_tick"; it doesn't encode the tick value of the event.
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

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]
  length = 0
  name = 'Generic MIDI Event'
  statusmsg = 0
  allow_running = True
Instance Variables [hide private]
  type
Event type derived from class name
  channel
Midi channel
  tick
Time of the event in midi ticks
  msdelay
Delay in ms
  data
Data after status message
  track
Track number (gets set when event is added to a stream)
  order
Sort order
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(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 (int/long) - 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 (bool) - omits the status message if true, since it is assumed that the status is carried over from the previous event.

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.

encode_delta_tick(self, last_tick=0)

source code 

this function should be renamed "encode_delta_tick"; it doesn't encode the tick value of the event. Returns the varlen data to use to represent the timing of this event relative to the last event.

Parameters:
  • last_tick - time of the previous event in the stream.

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.

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