예제 #1
0
u8 notes_mode_handle_press(u8 index, u8 value)
{
    Sequence* s = sequencer_get_active(&lp_sequencer);
    Layout* l = &s->layout;

    if (layout_handle_transpose(l, index, value))
    {
        sequence_kill_voices(s);
        layout_draw(l);
        keyboard_update_indices(&lp_keyboard);
    }
    else if (sequence_handle_press(s, index, value))
    {
        if (!flag_is_set(lp_flags, LP_RCV_CLOCK)
            && modifier_held(LP_CLICK)
            && value > 0
            && !flag_is_set(s->flags, SEQ_PLAYING))
        {
            u8 beat = lp_tap_tempo_counter % GRID_SIZE;
            Note* n = sequence_get_note(s, beat * STEPS_PER_PAD);
            n->note_number = voices_get_newest(&lp_voices);
            n->velocity = lp_voices.velocity;
            n->flags = 0x00;

            u8 tempo_set = tap_tempo_handle_press(LP_CLICK, 0x7F);
            if (tempo_set && beat == GRID_SIZE - 1)
            {
                // Set did_record_ahead so that the just-entered note is not
                // played twice.
                s->flags = set_flag(s->flags, SEQ_DID_RECORD_AHEAD);
                sequence_queue_at(
                    s, SEQUENCE_LENGTH - STEPS_PER_PAD, SEQ_QUEUED_STEP);
            }
        }
    }
    else if (index == LP_CLICK && modifier_held(LP_SHIFT))
    {
        lp_flags = toggle_flag(lp_flags, LP_TEMPO_BLINK);
    }
    else
    {
        return 0;
    }

    return 1;
}
예제 #2
0
void keyboard_init(Keyboard* k, Layout* l)
{
    k->layout = l;
    keyboard_update_indices(k);
}
예제 #3
0
u8 notes_setup_handle_press(u8 index, u8 value)
{
    Sequence* s = sequencer_get_active(&lp_sequencer);
    Layout* l = &s->layout;

    if (slider_handle_press(&lp_row_offset_slider, index, value, ROW_OFFSET_POS))
    {
        layout_set_row_offset(l, lp_row_offset_slider.value + 1);
    }
    else if (checkbox_handle_press(
                 s->flags, SEQ_RECORD_CONTROL,
                 index, value, CONTROL_CHECKBOX_POS))
    {

    }
    else if (checkbox_handle_press(
                 l->row_offset, LYT_DRUMS,
                 index, value, DRUM_CHECKBOX_POS))
    {
        layout_set_drums(l);
    }
    else if (index == MULTICHANNEL_CHECKBOX_POS)
    {
        sequence_kill_current_note(s);

        checkbox_handle_press(
            s->flags, SEQ_DRUM_MULTICHANNEL,
            index, value, MULTICHANNEL_CHECKBOX_POS);
    }
    else if (checkbox_handle_press(
                 s->flags, SEQ_FULL_VELOCITY,
                 index, value, VELOCITY_CHECKBOX_POS))
    {
        
    }
    else if (checkbox_handle_press(
                 s->flags, SEQ_MOD_WHEEL,
                 index, value, MOD_WHEEL_CHECKBOX_POS))
    {
        sequence_prepare_mod_wheel(s);
    }
    else if (checkbox_handle_press(
                 s->flags, SEQ_MOD_CC,
                 index, value, MOD_CC_CHECKBOX_POS))
    {
        
    }
    else if (number_handle_press(
                 &s->control_code, index, value,
                 CC_POS, CC_BITS))
    {

    }
    else if (slider_handle_press(
                 &lp_control_sens_slider, index, value, CC_SENS_POS))
    {
        s->control_div = CC_SENS_RESOLUTION * GRID_SIZE
            - slider_get_value(&lp_control_sens_slider);

        if (modifier_held(LP_SHIFT))
        {
            s->control_sgn = -1;
        }
        else
        {
            s->control_sgn = 1;
        }

    }
    else if (slider_handle_press(
                 &lp_control_offset_slider, index, value, CC_OFFSET_POS))
    {
        u8 slider_value = slider_get_value(&lp_control_offset_slider);
        s->control_offset = slider_value;

        // Send midi from the offset slider so that you can test the value
        // you put in/use midi learn on a software synth to map parameters.
        send_midi(CC | s->channel,
                  s->control_code,
                  slider_value);

    }
    else if (layout_handle_transpose(l, index, value))
    {
        keyboard_update_indices(&lp_keyboard);
    }
    else if (keyboard_handle_press(&lp_keyboard, index, value)) { }
    else
    {
        return 0;
    }

    return 1;
}