예제 #1
0
파일: midipult.c 프로젝트: wesen/midipult
void midi_buttons(void) {
  int i, j;
  for (i = 0; i < BUTTON_ROWS; i++)
    for (j = 0; j < 8; j++) {
      unsigned char button = i + j * BUTTON_ROWS;
      switch (button_status[button]) {
      case BUTTON_NOTHING:
      case BUTTON_NORMAL:
	break;
      case BUTTON_PRESSED:
	midi_send_note_on(1, 30 + button, 128);
	button_status[button] = BUTTON_NORMAL;
	//	_delay_ms(10);
	break;
      case BUTTON_RELEASED:
	midi_send_note_off(1, 30 + button, 128);
	button_status[button] = BUTTON_NOTHING;
	//	_delay_ms(10);
	break;
      }
    }
}
예제 #2
0
파일: keyboard.c 프로젝트: westlicht/x0xb0x
void do_keyboard_mode(void) {
  signed int shift = 0;
  uint8_t accent=0, slide=0;
  uint8_t i, last_bank;
  
  // turn tempo off!
  turn_off_tempo();
  
  clear_bank_leds();

  read_switches();
  last_bank = bank;
  has_bank_knob_changed(); // ignore startup change

  while (1) {
    read_switches();

    if (function_changed) {
      midi_notesoff();           // turn all notes off
      return;
    }
  
    // show the current MIDI address
    if (!is_bank_led_set(midi_out_addr)) {
      clear_bank_leds();
      set_bank_led(midi_out_addr);
    }

    if (has_bank_knob_changed()) {
      // bank knob was changed, which means they want a different
      // midi addr... OK then!
      midi_out_addr = bank;

      // set the new midi address (burn to EEPROM)
      internal_eeprom_write8(MIDIOUT_ADDR_EEADDR, midi_out_addr);

      last_bank = bank;
    }

    // show the octave
    display_octave_shift(shift);

    for (i=0; i<13; i++) {
      // check if any notes were just pressed
      if (just_pressed(notekey_tab[i])) {
	note_on((C2+i) + shift*OCTAVE, slide, accent);
	midi_send_note_on( ((C2+i) + shift*OCTAVE) | (accent << 6));
	slide = TRUE;

	// turn on that LED
	set_notekey_led(i);	
      }
      
      // check if any notes were released
      if (just_released(notekey_tab[i])) {
	midi_send_note_off( ((C2+i) + shift*OCTAVE) | (accent << 6));

	// turn off that LED
	clear_notekey_led(i);
      }
    }

    if (just_pressed(KEY_UP)) {
      if (shift < 2)
	shift++;
    } else if (just_pressed(KEY_DOWN)) {
      if (shift > -1)
	shift--;
    } 

    // check if they turned accent on
    if (just_pressed(KEY_ACCENT)) {
      accent = !accent;
      if (accent)
	set_led(LED_ACCENT);
      else
	clear_led(LED_ACCENT);
    }
    
    // if no keys are held down and there was a note just playing
    // turn off the note.
    if ((NOTE_PIN & 0x3F) && no_keys_pressed()) {
      note_off(0);
      slide = FALSE;
      clear_notekey_leds();
    }
  }
}