Esempio n. 1
0
import sys
import midipy as midi

# TODO: take other midi arguments off sys.argv[]
midi.open(128, 0, sys.argv[0], 0)

note_vel = 127

class ChordSequencerClass(object):
    
    def __init__(self):
        # TODO: use chord save information etc. ?
        self.playing = []
        self._bend = 0
    
    def play_note(self, note):
        if self.is_playing_note(note):
            self.stop_note(note)
        self.playing.append(set([note]))
        midi.note_on(note, note_vel)
    
    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)
Esempio n. 2
0
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()