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

Method play_Bar

mingus/midi/sequencer.py:206–234  ·  view source on GitHub ↗

Play a Bar object. Return a dictionary with the bpm lemma set on success, an empty dict on some kind of failure. The tempo can be changed by setting the bpm attribute on a NoteContainer.

(self, bar, channel=1, bpm=120)

Source from the content-addressed store, hash-verified

204 return True
205
206 def play_Bar(self, bar, channel=1, bpm=120):
207 """Play a Bar object.
208
209 Return a dictionary with the bpm lemma set on success, an empty dict
210 on some kind of failure.
211
212 The tempo can be changed by setting the bpm attribute on a
213 NoteContainer.
214 """
215 self.notify_listeners(
216 self.MSG_PLAY_BAR, {"bar": bar, "channel": channel, "bpm": bpm}
217 )
218
219 # length of a quarter note
220 qn_length = 60.0 / bpm
221 for nc in bar:
222 if not self.play_NoteContainer(nc[2], channel, 100):
223 return {}
224
225 # Change the quarter note length if the NoteContainer has a bpm
226 # attribute
227 if hasattr(nc[2], "bpm"):
228 bpm = nc[2].bpm
229 qn_length = 60.0 / bpm
230 ms = qn_length * (4.0 / nc[1])
231 self.sleep(ms)
232 self.notify_listeners(self.MSG_SLEEP, {"s": ms})
233 self.stop_NoteContainer(nc[2], channel)
234 return {"bpm": bpm}
235
236 def play_Bars(self, bars, channels, bpm=120):
237 """Play several bars (a list of Bar objects) at the same time.

Callers 5

play_TrackMethod · 0.95
play_BarFunction · 0.45
test_bar_velocityMethod · 0.45
test_playbarMethod · 0.45
test_changing_bpm_barMethod · 0.45

Calls 4

notify_listenersMethod · 0.95
play_NoteContainerMethod · 0.95
sleepMethod · 0.95
stop_NoteContainerMethod · 0.95

Tested by 3

test_bar_velocityMethod · 0.36
test_playbarMethod · 0.36
test_changing_bpm_barMethod · 0.36