def apply_control_translations(ev): try: _Engine._TheEngine().custom_translations except: _Engine._TheEngine().custom_translations = MidiTranslations() _Engine._TheEngine().custom_translations.control_hihat_openness(ev)
def apply_note_translations(ev): try: _Engine._TheEngine().custom_translations except: _Engine._TheEngine().custom_translations = MidiTranslations() ct = _Engine._TheEngine().custom_translations # Kick if ev.note == 36: ct.grow_switch_to_double_kick_counter() # Crash elif ev.note == 49: ct.grow_switch_to_hihat_counter() else: ct.reset_switch_counters() # Hihat pedal if ev.note == 44: ev = ct.hihat_to_kick(ev) # Hihat elif ev.note == 46: ev = ct.apply_hihat_openness(ev) # Ride elif ev.note == 51: ev = ct.hard_ride_hit(ev) return ev
def hit_tempo(note, speed): while context['hold_repeat']: engine._TheEngine().process(NoteOnEvent(engine.in_ports()[0], settings.MIDI_HAMMER_CHANNEL, note, 95) ) time.sleep(1.35-(speed*0.010))
def touch(self, path, args): name = args[0] if name == "head": print "got head" engine._TheEngine().process(AftertouchEvent(engine.in_ports()[0], settings.MIDI_HAMMER_CHANNEL, 127) )
def left_hand_pointing(self, path, args): note = args[0] if note == "": note = "c2" engine._TheEngine().process(NoteOffEvent(engine.in_ports()[0], settings.MIDI_REPEAT_CHANNEL, note, 127) )
def one_hand_gesture(self, path, args): name = args[0] if name == 'throwR': print "Got THROWR" engine._TheEngine().process(CtrlEvent(engine.in_ports()[0], settings.MIDI_HAMMER_CHANNEL, LOWER_OCTAVE, # modwheel int(args[2])+20, # value ) ) else: print "Got Unknown Gesture"
def two_hands_gesture(self, path, args): """ name, force, xyz_r, xyz_l """ name = args[0] if name == 'chord': # proba, force, position (R, L) print "Got Chord" engine._TheEngine().process(PitchbendEvent(engine.in_ports()[0], 1, 1) ) print "got two hands gesture", path, args
def sphere(self, path, args): """ 0 -> Main droite 1 -> Main Gauche """ note_name = args[0] hands = args[1] probability = args[2] force = args[3] print "got sphere : %s '%s', %d, %f, %f" % (path, note_name, hands, probability, force) bowls = {'c2': (0, 127), 'd2': (0, 127)} speed_min = 0 speed_max = 1 try: bowl_lower = bowls[note_name][0] bowl_upper = bowls[note_name][1] except KeyError: bowl_lower = 0 bowl_upper = 127 bowl_range = bowl_upper - bowl_lower step = float(speed_max) / bowl_range print step, bowl_range midi_vel = int(min(math.ceil(bowl_lower + (float(force*force + 0.1) / step) + 5), 127)) print midi_vel if hands == RIGHT_HAND: engine._TheEngine().process(NoteOnEvent(engine.in_ports()[0], settings.MIDI_HAMMER_CHANNEL, note_number(note_name), midi_vel) ) elif hands == LEFT_HAND: engine._TheEngine().process(NoteOnEvent(engine.in_ports()[0], settings.MIDI_REPEAT_CHANNEL, note_number(note_name), midi_vel) )
def play(): for i, record in enumerate(history): engine._TheEngine().process(NoteOnEvent(engine.in_ports()[0], settings.MIDI_HAMMER_CHANNEL, record[0], record[1]) ) # Wait until next note if i <= (len(history)-2): waiting = history[i+1][2] - record[2] time.sleep(waiting) context['history'] = [] context['history_is_running'] = False
def throw_glissando_note(note): for note in notes_to_play: try: engine._TheEngine().process(NoteOnEvent(engine.in_ports()[0], settings.MIDI_HAMMER_CHANNEL, note, 120) ) except Exception, e: print "Failure during glissando" sleep_min = 0.012 sleep_max = 0.216 sleep_time = max(sleep_max - (math.log10(max(velocity, 1)) / 20.), sleep_min) time.sleep(sleep_time)
def sphere_stop(self, path, args): sphere_name = args[0] print "stop sphere", sphere_name note = None for bowl in self.configs.current.bowls: if bowl.note.label == sphere_name: note = bowl.note.label break if note: engine._TheEngine().process(NoteOnEvent(engine.in_ports()[0], settings.MIDI_DAMPER_CHANNEL, note, 127) ) print "sent stop", args
def throw(self, path, args): hand = args[0] name = args[1] force = args[2] right_hand_evmap = {'dlur': RH_GLIS_UP, 'urdl': RH_GLIS_DOWN, 'rl': WHOLE_ALTERED, 'lr': INSCALE_UP, 'drul': RH_RAF_UP, 'uldr': RH_RAF_DOWN } left_hand_evmap = {'dlur': LH_GLIS_UP, 'urdl': LH_GLIS_DOWN, 'uldr': LH_RAF_DOWN, 'drul': LH_RAF_UP, 'lr': WHOLE_NORMAL, 'rl': INSCALE_DOWN, } if hand == LEFT_HAND: midi_event = left_hand_evmap[name] elif hand == RIGHT_HAND: midi_event = right_hand_evmap[name] else: midi_event = -1 print "PROBLEM !!" step = 1.0 / 127 midi_vel = int(min(math.floor(float(force*0.75 + 0.001) / step), 127)) print ">>>>> throwing", name, force, midi_vel engine._TheEngine().process(CtrlEvent(engine.in_ports()[0], settings.MIDI_HAMMER_CHANNEL, midi_event, # modwheel midi_vel, # value ) )
def throw_damper_release_note(note): engine._TheEngine().process(NoteOffEvent(engine.in_ports()[0], settings.MIDI_DAMPER_CHANNEL, note, 127) )
def stopall(self, path, args): engine._TheEngine().process(CtrlEvent(engine.in_ports()[0], settings.MIDI_DAMPER_CHANNEL, 123, 0) )
def localEvent(event=None, midi_event=None): #event is ignored res = mdEngineClass.process_event(mdEngine._TheEngine(), midi_event) for cmd in res: mdEngineClass.output_event(mdEngine._TheEngine(), cmd)
def trigger(self): engine._TheEngine().process(NoteOnEvent(engine.in_ports()[0], 1, note_number(self.note.label), 127))