Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion mingus/midi/fluidsynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,3 @@ def main_volume(channel, value):

def set_instrument(channel, instr, bank=0):
return midi.set_instrument(channel, instr, bank)

14 changes: 11 additions & 3 deletions mingus/midi/sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
"""

from mingus.containers.instrument import MidiInstrument
from mingus.containers.instrument import MidiPercussionInstrument

class Sequencer(object):

"""A general purpose sequencer for the objects in mingus.containers.

You can use the Sequencer object either by creating a subclass and
implementing some of the events (init, play_event, stop_event, cc_event,
instr_event) or by attaching observer objects via 'attach' and catching
instr_event) or by attaching observer objects via 'attach' and catching
the messages in the notify(msg_type, param_dict) function of your object.

See SequencerObserver for a pre made, easy to extend base class that can
Expand Down Expand Up @@ -65,6 +66,7 @@ class Sequencer(object):

def __init__(self):
self.listeners = []
self.is_general_midi = False
self.init()

# Events Implement some of these functions when subclassing
Expand Down Expand Up @@ -106,8 +108,13 @@ def notify_listeners(self, msg_type, params):
for c in self.listeners:
c.notify(msg_type, params)

def set_instrument(self, channel, instr, bank=0):
def set_instrument(self, channel, instr, bank=None):
"""Set the channel to the instrument _instr_."""
if bank is None:
if self.is_general_midi:
bank = 0 if channel != 9 else 128
else:
bank=0
self.instr_event(channel, instr, bank)
self.notify_listeners(self.MSG_INSTR, {'channel': int(channel),
'instr': int(instr), 'bank': int(bank)})
Expand Down Expand Up @@ -323,6 +330,8 @@ def play_Tracks(self, tracks, channels, bpm=120):
except:
i = 1
self.set_instrument(channels[x], i)
elif isinstance(instr, MidiPercussionInstrument):
self.set_instrument(channels[x], 0)
else:
self.set_instrument(channels[x], 1)
current_bar = 0
Expand Down Expand Up @@ -360,4 +369,3 @@ def main_volume(self, channel, value):
def pan(self, channel, value):
"""Set the panning."""
return self.control_change(channel, 10, value)