Esempio n. 1
0
    def on_key_down(self, cid, key):
        index = lookup(key, 'q2w3er5t6y7ui', range(13))
        if index is not None:
            if self.cid == cid:
                self.gui.ps.select(index)
        if key == '[':
            if cid == self.cid:
                self.gui.ps.left_press()
        if key == ']':
            if cid == self.cid:
                self.gui.ps.right_press()

        d_bounces = lookup(key, ['right', 'left'], [1, -1])
        if d_bounces is not None:
            self.bounces[cid] += d_bounces
            if cid == self.cid:
                self.gui.bs.update_bounces(self.bounces[cid])

        timbre = lookup(key, 'asdf',
                        ['sine', 'square', 'triangle', 'sawtooth'])
        if timbre is not None:
            self.timbre[cid] = timbre
            if self.cid == cid:
                self.gui.ts.select(timbre)  # have the GUI update as well

        if key == 'g':  # toggle gravity
            if cid == self.cid:
                self.gravity[cid] = not self.gravity[cid]
                self.gui.gs.toggle()

        # other clients should update their state to reflect this client's new selection.
        if self.cid == cid:  # don't want every client updating server's state at the same time!
            self.update_server_state(post=False)
Esempio n. 2
0
    def on_key_down(self, keycode, modifiers):

        obj = lookup(keycode[1], 'mas', (self.metro, self.seq1, self.seq2))
        if obj is not None:
            obj.toggle()

        bpm_adj = lookup(keycode[1], ('up', 'down'), (10, -10))
        if bpm_adj:
            new_tempo = self.tempo_map.get_tempo() + bpm_adj
            self.tempo_map.set_tempo(new_tempo, self.sched.get_time())
Esempio n. 3
0
 def on_key_down(self, keycode, modifiers):
     obj = lookup(keycode[1], 'm', (self.metro))
     if obj is not None:
         obj.toggle()
     
     if keycode[1] == 'q':
         self.changeBaseLine()
Esempio n. 4
0
    def on_key_down(self, keycode, modifiers):
        if keycode[1] == 'm':
            self.metro.toggle()

        bpm_adj = lookup(keycode[1], ('up', 'down'), (10, -10))
        if bpm_adj:
            new_tempo = self.tempo_map.get_tempo() + bpm_adj
            self.tempo_map.set_tempo(new_tempo, self.sched.get_time())
Esempio n. 5
0
    def on_key_down(self, keycode, modifiers):
        if keycode[1] == 'm':
            self.metro.toggle()

        if keycode[1] == 'a':
            self.arpeg.start()

        pitches = lookup(keycode[1], 'qwe', ((60, 64, 67, 72), (55, 59, 62, 65, 67, 71), (60, 65, 69)))
        if pitches:
            self.arpeg.set_pitches(pitches)

        rhythm = lookup(keycode[1], 'uiop', ((120, 1), (160, 1), (240, 0.75), (480, 0.25)))
        if rhythm:
            self.arpeg.set_rhythm(*rhythm)

        direction = lookup(keycode[1], '123', ('up', 'down', 'updown'))
        if direction:
            self.arpeg.set_direction(direction)
Esempio n. 6
0
    def on_key_down(self, keycode, modifiers):
        t = lookup(keycode[1], ['up', 'down'], [.001, -.001])
        if t is not None:
            self.onset_detector.onset_thresh += t

        if keycode[1] == "w":
            self.init_recording()

        if keycode[1] == "s" and self.seq:
            self.play_recording()
Esempio n. 7
0
    def on_key_down(self, cid, key):
        index = lookup(key, 'q2w3er5t6y7ui', range(13))
        if index is not None:
            if self.cid == cid:
                self.gui.ps.select(index)
        if key == '[':
            if cid == self.cid:
                self.gui.ps.left_press()
        if key == ']':
            if cid == self.cid:
                self.gui.ps.right_press()

        if key == 'v' and cid == self.cid:
            self.delete_mode[cid] = not self.delete_mode[cid]
            self.update_server_state(post=True)

        if key == 'up':
            if not self.gui.is_drum:
                self.gui.switch_module()

        if key == 'down':
            if self.gui.is_drum:
                self.gui.switch_module()

        if self.gui.is_drum:
            drum = lookup(key, 'asdfg',
                          ['snare', 'crash', 'bass', 'hihat', 'triangle'])
            if drum is not None:
                self.drum[cid] = drum
                if self.cid == cid:
                    self.drum_channel = self.drum_list.index(drum) + len(
                        self.inst_list)
                    self.gui.ds.select(drum)
        else:
            instrument = lookup(
                key, 'asdfg',
                ['piano', 'violin', 'trumpet', 'ocarina', 'choir'])
            if instrument is not None:
                self.instrument[cid] = instrument
                if self.cid == cid:
                    self.channel = self.inst_list.index(instrument)
                    self.gui.ints.select(
                        instrument)  # have the GUI update as well
Esempio n. 8
0
    def on_key_down(self, keycode, modifiers):
        global client, client_id
        key = keycode[1]

        # switch module using keys (for now)
        module_name = lookup(key, 'zxc',
                             ['PhysicsBubble', 'SoundBlock', 'TempoCursor'])
        if module_name is not None:
            old_handler = self.module_handler
            new_handler = self.module_handlers[module_name]
            if old_handler.module_name != new_handler.module_name:
                self.sandbox.remove(old_handler.gui)
                self.sandbox.add(new_handler.gui)
                self.module = self.module_dict[module_name]
                self.module_handler = new_handler
        elif key == 'spacebar':
            print('boop')
            self.writer.toggle()
        else:
            data = {'cid': client_id, 'module': self.module.name, 'key': key}
            client.emit('key_down', data)
Esempio n. 9
0
    def on_key_up(self, keycode):
        self.modifier.on_key_up(keycode[1])

        pitch = lookup(keycode[1], kKeys, kPitches)
        if pitch:
            self.synth.noteoff(0, pitch)
Esempio n. 10
0
    def on_key_down(self, keycode, modifiers):
        self.modifier.on_key_down(keycode[1])

        pitch = lookup(keycode[1], kKeys, kPitches)
        if pitch:
            self.synth.noteon(0, pitch, 100)