Ejemplo n.º 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;
}
int string_to_integer(char *s){
  int number, flag;
  number=0;
  flag=0; /*check repeated occurance of neg signs*/
  for ( ; *s ; s++ ){
    if ( *s == '-' )
      toggle_flag( &flag );
    if ( *s >= '0' && *s <= '9' ){
      for ( ; *s >= '0' && *s <= '9' ; s++ ){
	if ( overflow(number, s) ){
	  number=0;
	  break;
	}
	if ( flag ) number=(number*10)-(*s-'0');
	else number=(number*10)+(*s-'0');
      }
      break;
    }
  }
  return number;
}
Ejemplo n.º 3
0
u8 control_bank_setup_handle_press(ControlBank* cb, u8 index, u8 value)
{
    if (index == LP_SHIFT)
    {
        if (value > 0)
        {
            cb->flags = toggle_flag(cb->flags, CBK_SETUP_SHIFTED);
            clear_pad_leds();
        }
        else
        {
            return 0;
        }

        return 1;
    }

    u8 x, y;
    if (!index_to_pad(index, &x, &y))
    {
        return 0;
    }

    if (checkbox_handle_press(
            cb->flags,
            CBK_SHOW_CHECKBOXES,
            index, value,
            CHECKBOX_ROW_INDEX))
    {
            
    }
    else if (flag_is_set(cb->flags, CBK_SETUP_SHIFTED))
    {
        if (number_handle_press(
                &cb->control_numbers[y], index, value,
                coord_to_index(CC_X, y), CC_BITS))
        {

        }
        else
        {
            return 0;
        }
    }
    else
    {
        if (checkbox_handle_press(
                cb->bipolar_checkboxes,
                1 << y,
                index, value,
                coord_to_index(BIPOLAR_CHECKBOX_X, y)))
        {
            cb->sliders[y].offset =
                flag_is_set(cb->bipolar_checkboxes, 1 << y)
                    ? -128 / 2
                    : -1;
        }
        else if (number_handle_press(
                     &cb->channel_numbers[y], index, value,
                     coord_to_index(CHANNEL_X, y), CHANNEL_BITS))
        {
            
        }
        else
        {
            return 0;
        }
    }

    return 1;
}