MCPcopy Create free account
hub / github.com/bspaans/python-mingus / play_Tracks

Method play_Tracks

mingus/midi/sequencer.py:327–362  ·  view source on GitHub ↗

Play a list of Tracks. If an instance of MidiInstrument is used then the instrument will be set automatically.

(self, tracks, channels, bpm=120)

Source from the content-addressed store, hash-verified

325 return {"bpm": bpm}
326
327 def play_Tracks(self, tracks, channels, bpm=120):
328 """Play a list of Tracks.
329
330 If an instance of MidiInstrument is used then the instrument will be
331 set automatically.
332 """
333 self.notify_listeners(
334 self.MSG_PLAY_TRACKS, {"tracks": tracks, "channels": channels, "bpm": bpm}
335 )
336
337 # Set the right instruments
338 for x in range(len(tracks)):
339 instr = tracks[x].instrument
340 if isinstance(instr, MidiInstrument):
341 try:
342 i = instr.names.index(instr.name)
343 except:
344 i = 1
345 self.set_instrument(channels[x], i)
346 else:
347 self.set_instrument(channels[x], 1)
348 current_bar = 0
349 max_bar = len(tracks[0])
350
351 # Play the bars
352 while current_bar < max_bar:
353 playbars = []
354 for tr in tracks:
355 playbars.append(tr[current_bar])
356 res = self.play_Bars(playbars, channels, bpm)
357 if res != {}:
358 bpm = res["bpm"]
359 else:
360 return {}
361 current_bar += 1
362 return {"bpm": bpm}
363
364 def play_Composition(self, composition, channels=None, bpm=120):
365 """Play a Composition object."""

Callers 3

play_CompositionMethod · 0.95
play_TracksFunction · 0.45
test_tracksMethod · 0.45

Calls 3

notify_listenersMethod · 0.95
set_instrumentMethod · 0.95
play_BarsMethod · 0.95

Tested by 1

test_tracksMethod · 0.36