def mute(self): muted = set() for chord in self.playing: for note in chord: if note not in muted: muted.add(note) midi.note_off(note, note_vel) self.playing = []
def stop_note(self, note): to_remove = [] for i in xrange(len(self.playing)): if note in self.playing[i]: self.playing[i].remove(note) # remove note from playing chord if len(self.playing[i]) == 0: # if chord's empty, remove it to_remove.append(i) for i in to_remove: del self.playing[i] midi.note_off(note, note_vel)
def stop_chord(self, chord): if self.is_playing_chord(chord): self.playing.remove(set(chord)) for note in chord: midi.note_off(note, note_vel)
import time import midipy as midi midi.open(128, 0, "midipy test", 0) for (note, t) in [(48,0.5),(48,0.5),(50,1.0),(48,1.0),(53,1.0),(52,1.0), (48,0.5),(48,0.5),(50,1.0),(48,1.0),(55,1.0),(53,1.0)]: midi.note_on(note,127) time.sleep(t/2) midi.note_off(note,127) midi.close()