python-mingus
python-mingus copied to clipboard
Events
Hello,
How can i create my own event ?
for example i tried to control the volume of each tracks. So i've tried that to add this to midi.MidiTrack:
def set_volume(self, value, channel):
self.track_data += self.midi_event(MAIN_VOLUME, channel, value)
def play_Track(self, track):
"""Convert a Track object to MIDI events and write them to the
track_data."""
if hasattr(track, 'name'):
self.set_track_name(track.name)
self.set_volume(0, 1)
self.delay = 0
instr = track.instrument
if hasattr(instr, 'instrument_nr'):
self.change_instrument = True
self.instrument = instr.instrument_nr
for bar in track:
self.play_Bar(bar)
And each time a track is played i want his volume to be set So i've hard write this line
self.set_volume(0, 1)
Because i wanted to try to set my first channel to 1 and see if it works, but it had just added a note i didn't wanted in my midi file.
The old version of mingus us an Event class, it's seems you have removed it. How can i today manage this kind of event ?