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

Class EventStream

source code

object --+
         |
        EventStream

Class used to describe a collection of MIDI events, organized into tracks.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__set_resolution(self, resolution) source code
 
__get_resolution(self) source code
 
add_track(self) source code
 
get_current_track_number(self) source code
 
get_track_by_number(self, tracknum) source code
 
get_current_track(self) source code
 
get_track_by_name(self, trackname) source code
 
replace_current_track(self, track) source code
 
replace_track_by_number(self, tracknum, track) source code
 
replace_track_by_name(self, trackname, track) source code
 
delete_current_track(self) source code
 
delete_track_by_number(self, tracknum) source code
 
delete_track_by_name(self, trackname, track) source code
 
add_event(self, event) source code
 
_add_event_without_timemap(self, event)
Like add_event, but doesn't update the timemap after adding the event.
source code
 
get_tempo(self, offset=0) source code
 
timesort(self) source code
 
textdump(self) source code
 
__iter__(self) source code
 
iterevents(self, mswindow=0) source code
 
__get_trackcount(self) source code
 
__len__(self) source code
 
__getitem__(self, intkey) source code
 
__refresh(self) source code
 
__refresh_tracknames(self) source code
 
__refresh_trackpool(self) source code
 
__refresh_tempomap(self) source code
 
__refresh_timemap(self) source code
 
_refresh_timemap(self) source code
 
__adjust_endoftrack(self, event, track=None)
Track defaults to the current track.
source code
 
__get_endoftrack(self) source code
 
__set_endoftrack(self, eot) source code
 
__get_track_num(self) source code
 
__set_track_num(self, num) source code
 
remove_event(self, ev, track=None)
Remove the first occurence of an event matching the given event from the event stream.
source code
 
remove_event_instance(self, ev, track=None)
Removes the event instance from a stream, if it exists.
source code
 
remove_event_instances(self, evs)
Has the same effect as calling remove_event_instance on each members of evs, but is a lot faster if removing many events in one go.
source code
 
slice(self, start, end=None) source code
 
clean_midi(self)
Unimplemented.
source code

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

Properties [hide private]
  resolution
Ticks per quarter note
  duration
The length of the stream in midi ticks.
  trackcount
  endoftrack
  curtrack
The track number of the current track
  track
The current track

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)

_add_event_without_timemap(self, event)

source code 

Like add_event, but doesn't update the timemap after adding the event. You shouldn't usually use this, since it leaves the timemap in an inconsistent state, but it's used internally when adding a lot of events in a row. If you use it, you should ensure that _refresh_timemap gets called afterwards.

__adjust_endoftrack(self, event, track=None)

source code 

Track defaults to the current track. The event itself is assumed to be in the track already.

remove_event(self, ev, track=None)

source code 

Remove the first occurence of an event matching the given event from the event stream. Raises a ValueError a match is not found in the stream.

Parameters:
  • track (int) - track number to look for the event in. If not given, all tracks are searched.

remove_event_instance(self, ev, track=None)

source code 

Removes the event instance from a stream, if it exists. Raises a ValueError a match is not found in the stream.

Note that this is different from remove_event, which looks for a match to the argument, whereas this requires identity.

Parameters:
  • track (int) - track number to look for the event in. If not given, all tracks are searched.

remove_event_instances(self, evs)

source code 

Has the same effect as calling remove_event_instance on each members of evs, but is a lot faster if removing many events in one go.

Note that this won't raise an exception if any of the events aren't found.

clean_midi(self)

source code 

Unimplemented. Will check for redundant messages and delete them, such as control changes that are followed by a "Reset Controllers" message before a note on.


Property Details [hide private]

resolution

Ticks per quarter note

Get Method:
__get_resolution(self)
Set Method:
__set_resolution(self, resolution)

duration

The length of the stream in midi ticks. Note that this is not the same as len(stream), which gives the number of tracks.

Get Method:
unreachable.duration(self) - The length of the stream in midi ticks.

trackcount

Get Method:
__get_trackcount(self)

endoftrack

Get Method:
__get_endoftrack(self)
Set Method:
__set_endoftrack(self, eot)

curtrack

The track number of the current track

Get Method:
__get_track_num(self)
Set Method:
__set_track_num(self, num)
Delete Method:
delete_current_track(self)

track

The current track

Get Method:
get_current_track(self)
Set Method:
replace_current_track(self, track)
Delete Method:
delete_current_track(self)