Пример #1
0
    def __init__(self, threshold_lower, threshold_upper,
                 hold_time, margin_lower, margin_upper):
        self.threshold_lower = _util.note_number(threshold_lower)
        self.threshold_upper = _util.note_number(threshold_upper)
        self.margin_lower = margin_lower
        self.margin_upper = margin_upper
        self.hold_time = hold_time

        self.notes_lower = {}
        self.notes_upper = {}
Пример #2
0
def generate_all_notes_on(anEvent):
    """
    Activate all bowls.
    Ding Generator.
    """
    for note in range(note_number(settings.BOWL_LOWER), 
                      note_number(settings.BOWL_UPPER)):
        yield NoteOnEvent(anEvent.port,
                          anEvent.channel,
                          note, 127)
Пример #3
0
    def __init__(self, threshold_lower, threshold_upper, hold_time,
                 margin_lower, margin_upper):
        self.threshold_lower = _util.note_number(threshold_lower)
        self.threshold_upper = _util.note_number(threshold_upper)
        self.margin_lower = margin_lower
        self.margin_upper = margin_upper
        self.hold_time = hold_time

        self.notes_lower = {}
        self.notes_upper = {}
Пример #4
0
    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)
                                        )
Пример #5
0
def schedule_glissando(ev):
    context_lock.acquire()
    is_running = context['glissando_is_running']
    context_lock.release()
    
    if is_running:
        print "glissando running, quit."
        return
    else: 
        context_lock.acquire()       
        context['glissando_is_running'] = True
        context_lock.release()

    # speed of glissando
    velocity = ev.value

    if ev.ctrl in (LH_RAF_UP, LH_RAF_DOWN, LH_GLIS_UP, LH_GLIS_DOWN):
        scale = HONG_MIN_SCALE
    else:
        scale = ORIENTAL2_SCALE

    tonic = context['latest_note']

    try:

        print "tonic is", tonic
        if tonic >= note_number('c3') and ev.ctrl in (LH_GLIS_UP, RH_GLIS_UP):
            tonic -= 12
        if tonic < note_number('c3') and ev.ctrl in (LH_GLIS_DOWN, RH_GLIS_DOWN):
            tonic += 12

        note_range = range(tonic, note_number('c5'))
        
        
        # Scaleless
        total_lower_octave = range(note_number('c2'), note_number('c3'))
        total_upper_octave = range(note_number('c3'), note_number('c4'))
        total_whole_octave = total_lower_octave + total_lower_octave

        # In-scale
        scale_lower_octave = [total_lower_octave[offset] for offset in scale]
        scale_upper_octave = [total_upper_octave[offset] for offset in scale]
        scale_whole_octave = scale_lower_octave + scale_upper_octave
        
        scale_whole_octave_reversed = copy.copy(scale_whole_octave)
        scale_whole_octave_reversed.reverse()

        # Normal mask
        normal_mask = [0, 2, 4, 5, 7, 9, 11]
        altered_mask = [1, 3, 6, 8, 10]

        # Scaleless, normal
        total_lower_normal = [total_lower_octave[offset] for offset in normal_mask]
        total_upper_normal = [total_upper_octave[offset] for offset in normal_mask]
        total_whole_normal = total_lower_normal + total_upper_normal
        
        # Scaleless, altered
        total_lower_altered = [total_lower_octave[offset] for offset in altered_mask]
        total_upper_altered = [total_upper_octave[offset] for offset in altered_mask]
        total_whole_altered = total_lower_altered + total_upper_altered
        
        scale_up = [note_range[offset] for offset in scale if offset < len(note_range)]
        scale_down = copy.copy(scale_up)
        scale_down.reverse()

        # rafale
        tonic_idx = None
        limit = 0
        while tonic_idx is None:
            limit +=1
            try:
                tonic_idx = scale_whole_octave.index(tonic)
            except ValueError, e:
                if tonic is None:
                    tonic = 0
                else:
                    tonic += 1
            if limit >= len(scale_whole_octave):
                print "BUG: BREAK"
                tonic_idx = 0
                break
    
        try:
            scale_raf_up = [scale_whole_octave[tonic_idx],
                            scale_whole_octave[tonic_idx],
                            scale_whole_octave[tonic_idx+1],
                            scale_whole_octave[tonic_idx],
                            scale_whole_octave[tonic_idx+2]]
        except Exception, e:
            scale_raf_up = [scale_whole_octave[tonic_idx]]
Пример #6
0
 def __init__(self, polyphonic, reset):
     self.polyphonic = polyphonic
     self.reset = _util.note_number(reset) if reset is not None else None
     self.notes = []
Пример #7
0
 def trigger(self):
     engine._TheEngine().process(NoteOnEvent(engine.in_ports()[0],
                                             1,
                                             note_number(self.note.label),
                                             127))
Пример #8
0
 def __init__(self, polyphonic, reset):
     self.polyphonic = polyphonic
     self.reset = _util.note_number(reset) if reset is not None else None
     self.notes = []