Exemple #1
0
class NoteView:
    '''
    TODO:
        Draw clefs
        Draw key signatures
        Draw accidentals
        Handle overlap of notes at same y-position
        Lines and clef (static imagery) as vertex buffers or arrays
        Time (in beats) - draw only notes near the current time
        Line color
        Note color
    '''

    def __init__(self, window, left_hand_track=None, right_hand_track=None):
        # Initialize position and sizing info
        self.window = window
        self.y = window.height / 2
        self.note_height = 20
        self.line_width = 3
        self.staff_height = 5 * self.note_height + self.line_width
        self.staves = [StaffView(x=0, y=self.y - self.staff_height * .8, width=self.window.width, clef='bass', track=left_hand_track),
                       StaffView(x=0, y=self.y + self.staff_height * .8, width=self.window.width, clef='treble', track=right_hand_track)]

        # Initialize MIDI input
        self.midi_in = MidiInput()

    def draw(self):
        for s in self.staves:
            s.draw()
        
        glColor4f(0.8, 0, 0.8, 0.5)
        notes = self.midi_in.get_pressed_notes()
        for n in notes:
            s = self.staves[0] if int(n) < 60 else self.staves[1]
            s.draw_note(n, s.width / 2)
Exemple #2
0
    def __init__(self, window, left_hand_track=None, right_hand_track=None):
        # Initialize position and sizing info
        self.window = window
        self.y = window.height / 2
        self.note_height = 20
        self.line_width = 3
        self.staff_height = 5 * self.note_height + self.line_width
        self.staves = [StaffView(x=0, y=self.y - self.staff_height * .8, width=self.window.width, clef='bass', track=left_hand_track),
                       StaffView(x=0, y=self.y + self.staff_height * .8, width=self.window.width, clef='treble', track=right_hand_track)]

        # Initialize MIDI input
        self.midi_in = MidiInput()
Exemple #3
0
def ampMoveDiscon(input):
  i = input * 2
  return i**3 * -1

class Printer:
  def start(self, topot):
    topot.registerOutput("print", self.printer)
  def printer(self, input, prefix = ""):
    def prnt():
      print prefix, input.value
    return OutputSignal(prnt, input)

t.add(Printer())
t.add(Ticker(20))
t.add(Joystick("/dev/input/js0"), "j0_")
t.add(MidiInput())
t.add(MidiOutput())

t.connect("note", 48, t.get("j0_button",0))
t.connect("print", "note 48", t.get("note", 48))
t.connect("print", "escape:", t.get("key", 9))
t.connect("click", 1, t.get("j0_button", 4))
t.connect("click", 2, t.get("j0_button", 5))
t.connect("click", 3, t.get("j0_button", 6))
t.connect("mousemove", pair(transform(t.get("j0_axis", 2), ampMove),
                            transform(t.get("j0_axis", 3), ampMove)))
t.connect("key", 98, t.get("j0_axis", 4))
t.connect("print", primitive(repeat(t.get("tick"), transform(t.get("j0_axis", 1), ampMoveDiscon)), 0, 0, 127))
t.connect("note", 50, primitive(repeat(t.get("tick"), transform(t.get("j0_axis", 1), ampMoveDiscon)), 0, 0, 127))

"""