예제 #1
0
def loop(last, state, outputs):
    # Set Gate 1 to the state of the MIDI transport.
    # If the transport is "playing" then the gate will
    # be on, otherwise, it'll be off.
    outputs.gate_1 = state.playing

    # Trigger Gate 2, 3, and 4 based on the MIDI clock.
    # Trigger Gate 2 every quarter note.
    if sol.should_trigger_clock(state, 4):
        outputs.trigger_gate_2()
    # Trigger Gate 3 every eighth note.
    if sol.should_trigger_clock(state, 8):
        outputs.trigger_gate_3()
    # Trigger Gate 4 every sixteenth note.
    if sol.should_trigger_clock(state, 16):
        outputs.trigger_gate_4()
예제 #2
0
def loop(last, state, outputs):
    """The loop is run over and over to process MIDI information
    and translate it to outputs.

    "last" holds the previous state, "state" holds the current state,
    and "outputs" lets you control the output jacks.

    You can read more about the state here: TODO.
    And more about the outputs here: TODO.
    """
    # Whenever a new note message comes in, such as from
    # a key being pressed or a sequencer sending a note,
    # update the gate and trigger outputs.
    if sol.was_key_pressed(state):
        # Turn on Gate 1. If it's already on, re-trigger it
        # so that envelope generators and similar modules
        # notice that it's a distinct note.
        outputs.retrigger_gate_1()

        # For Gate 2, just trigger it every time a key
        # is pressed. No need for re-triggering since
        # this will automatically shut off after a few
        # milliseconds.
        outputs.trigger_gate_2()

    # If there's a note currently playing set CV A to the
    # voltage that corresponds to the note. This also
    # takes pitch bend into account. Since pitch bend
    # can change in between keys being pressed this
    # has to update this every loop instead of just when
    # a new note message comes in.
    if state.note:
        outputs.cv_a = sol.voct(state)
    # If no note is being played, turn Gate 1 off.
    if not state.note:
        outputs.gate_1 = False

    # Set CV B's value based on the the Modulation Wheel.
    # The modulation wheel is MIDI controller 1 (CC 1).
    # The value from the state is from 0-1.0 so scale it to
    # 0-10v. If you want the range to be lower, change 10.0
    # to something else. For example, if you wanted it to
    # go from 0-8v, change it to 8.0.
    outputs.cv_b = 10.0 * state.cc(1)

    # Trigger Gate 3 on every 16th note.
    # If you want to trigger on a different division,
    # change 16 to your division. For example, to trigger
    # on every quarter note change it to 4.
    if sol.should_trigger_clock(state, 16):
        outputs.trigger_gate_3()

    # Set Gate 4 to the state of the MIDI transport.
    # If the transport is "playing" then the gate will
    # be on, otherwise, it'll be off.
    outputs.gate_4 = state.playing
예제 #3
0
def loop(last, state, outputs):
    # Trigger for every quarter note.
    if sol.should_trigger_clock(state, 4):

        # Select a random note.
        note = octave + random.choice(notes)

        # Set the CV A output to the notes v/oct value.
        outputs.cv_a = sol.voct(note)

        # And trigger the gate.
        outputs.retrigger_gate_1()

    # Otherwise, no need to have the gate on.
    else:
        outputs.gate_1 = False
예제 #4
0
 def tick(self, last, state):
     self.read_ccs(last, state)
     self.on = sol.should_trigger_clock(state, self.division)