5. DONE Step Input Handling

CLOSED: [2019-02-24 Sun 14:16] The top level function for handling step input is called step_input. Input handling is split up into hierarchical branches. The top level branches go between display and control.

<<step_function_declarations>>=
static void step_input(page_step_d *step, int x, int y);
<<step_functions>>=
static void step_input(page_step_d *step, int x, int y)
{
    if(y < 4) step_input_display(step, x, y);
    else step_input_control(step, x, y);
}

5.1. DONE Display Section Input [2/2]

CLOSED: [2019-02-18 Mon 18:31] The display section interaction has two distinct behaviors, depending on which row you are on: playhead or gate. Rows 0 and 2 are playhead, and rows 1 and 3 are gate. (this order was chosen to mimic the tb303 interface).

<<step_function_declarations>>=
static void step_input_display(page_step_d *step, int x, int y);
<<step_functions>>=
static void step_input_display(page_step_d *step, int x, int y)
{
    if(y == 0 || y == 2) step_input_display_playhead(step, x, y);
    else if(y == 1 || y == 3) step_input_display_gate(step, x, y);
}

5.1.1. DONE Playhead Row Input

CLOSED: [2019-02-18 Mon 18:30]

<<step_function_declarations>>=
static void step_input_display_playhead(page_step_d *step, int x, int y);
<<step_functions>>=
static void step_input_display_playhead(page_step_d *step, int x, int y)
{
    int pos;
    pos = x;

    if(y == 2) pos += 16;
    page_step_editpos_set(step, pos);

    page_step_draw_playhead(step);
    page_step_draw_current_note(step);
}

5.1.2. DONE Gate Row Input

CLOSED: [2019-02-18 Mon 18:30]

<<step_function_declarations>>=
static void step_input_display_gate(page_step_d *pg, int x, int y);

Order matters here.

<<step_functions>>=
static void step_input_display_gate(page_step_d *pg, int x, int y)
{
    int pos;
    signed char g;
    pos = x;
    if(y == 3) pos += 16;
    page_step_editpos_set(pg, pos);
    g = get_current_gate(pg);
    g = (g == 1) ? 0 : 1;
    if(page_step_latch_mode(pg) && g) {
        set_current_note(pg, pg->last_note);
    }
    set_current_gate(pg, g);
    page_step_draw_gate(pg);
    page_step_draw_current_note(pg);
    page_step_draw_playhead(pg);
}

5.2. DONE Control Section Input [2/2]

CLOSED: [2019-02-23 Sat 13:49] The control section is delegated into rows. Each row is a different kind of control interface right now, only the top row and bottom row have controls (note and control, respectively).

<<step_function_declarations>>=
static void step_input_control(page_step_d *step, int x, int y);
<<step_functions>>=
static void step_input_control(page_step_d *step, int x, int y)
{
    y -= 4; /* normalize between 0 and 3 */
    if(y < 0 || y > 3) return;
    if(y == 0) step_input_control_note(step, x);
    else if(y == 3) step_input_control_toolbar(step, x);
}

5.2.1. DONE Note Input Row

CLOSED: [2019-02-18 Mon 18:31]

<<step_function_declarations>>=
static void step_input_control_note(page_step_d *step, int x);
<<step_functions>>=
static void step_input_control_note(page_step_d *step, int x)
{
    if(x < 12) step_input_control_note_pitch(step, x);
    else step_input_control_note_octave(step, x - 12);
}
5.2.1.1. TODO Pitch Control

The current pitch from an input row is set with the function step_input_control_note_pitch.

<<step_function_declarations>>=
static void step_input_control_note_pitch(page_step_d *step, int p);
<<step_functions>>=
static void step_input_control_note_pitch(page_step_d *step, int p)
{
    signed char note;
    int oct, pitch;
    note = get_current_note(step);
    to_pitchoct(note, &pitch, &oct);
    pitch = p;
    page_step_draw_note(step, pitch, oct);
    note = to_note(pitch, oct);
    if(page_step_latch_mode(step)) step->last_note = note;
    set_current_note(step, note);
}
5.2.1.2. TODO Octave Control

The octave control is set using the function step_input_control_note_octave.

<<step_function_declarations>>=
static void step_input_control_note_octave(page_step_d *step, int o);
<<step_functions>>=
static void step_input_control_note_octave(page_step_d *step, int o)
{
    signed char note;
    int oct, pitch;
    note = get_current_note(step);
    to_pitchoct(note, &pitch, &oct);
    oct = o;
    page_step_draw_note(step, pitch, oct);
    note = to_note(pitch, oct);
    if(page_step_latch_mode(step)) step->last_note = note;
    set_current_note(step, note);
}

5.2.2. DONE Toolbar Input Row

CLOSED: [2019-02-23 Sat 13:49]

<<step_function_declarations>>=
static void step_input_control_toolbar(page_step_d *step, int x);
<<step_functions>>=
static void step_input_control_toolbar(page_step_d *step, int x)
{
    switch(x) {
        case 0:
            step->playing = (step->playing) ? 0 : 1;
            page_step_draw_toolbar(step, 0, step->playing);
            break;
        case 1:
            step->jam_mode = (step->jam_mode) ? 0 : 1;
            page_step_draw_toolbar(step, 1, step->jam_mode);
            break;
        case 2:
            step->latch_mode  = (step->latch_mode) ? 0 : 1;
            page_step_draw_toolbar(step, 2, step->latch_mode);
            break;
    }
}



prev | home | next