Added simple functions for changing sounds, bankd and volume.

master
Holger Wirtz 6 years ago
parent 41e8ac7a75
commit 6ffb41447b
  1. 181
      MIDITESTER.ino

@ -14,8 +14,8 @@
#define TEST_DUR_MIN 200 #define TEST_DUR_MIN 200
#define TEST_DUR_MAX 1500 #define TEST_DUR_MAX 1500
#define MASTER_KEY_MIDI MIDI_C6 #define MASTER_KEY_MIDI MIDI_C7
#define MASTER_NUM1 MIDI_C1 #define MASTER_NUM1 MIDI_C2
class midi_event { class midi_event {
public: public:
@ -41,62 +41,29 @@ void setup()
randomSeed(analogRead(A0)); randomSeed(analogRead(A0));
/* // Bank change 1
// Sound change 17 change_bank(1);
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1); delay(2000);
delay(500);
MIDI.sendNoteOn(MIDI_E3, 66, 1); // Sound change 17
delay(500); change_sound(17);
MIDI.sendNoteOff(MIDI_E3, 0, 1); delay(2000);
delay(500);
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1); // Volume change 0.5
change_volume(5);
delay(2000); delay(2000);
// Volume change 0.5 // Bank change 3
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1); change_bank(3);
delay(500); delay(2000);
MIDI.sendNoteOn(MIDI_AIS1, 66, 1);
delay(500); // Sound change 17
MIDI.sendNoteOff(MIDI_AIS1, 0, 1); change_sound(17);
delay(500); delay(2000);
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1);
// Volume change 0.1
delay(2000); change_volume(1);
delay(5000);
// Bank change 3
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1);
delay(500);
MIDI.sendNoteOn(MIDI_FIS3, 66, 1);
delay(500);
MIDI.sendNoteOff(MIDI_FIS3, 0, 1);
delay(500);
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1);
delay(2000);
// Sound change 17
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1);
delay(500);
MIDI.sendNoteOn(MIDI_E3, 66, 1);
delay(500);
MIDI.sendNoteOff(MIDI_E3, 0, 1);
delay(500);
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1);
delay(2000);
// Volume change 0.1
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1);
delay(500);
MIDI.sendNoteOn(MIDI_DIS1, 66, 1);
delay(500);
MIDI.sendNoteOff(MIDI_DIS1, 0, 1);
delay(500);
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1);
delay(5000);
*/
} }
void loop() void loop()
@ -130,6 +97,104 @@ void sendMIDI(int8_t note, int8_t vel, int8_t chan, uint32_t dur)
Serial.println();*/ Serial.println();*/
} }
void change_sound(uint8_t sound)
{
uint8_t sound_key = base_c_num_key(sound);
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1);
delay(500);
MIDI.sendNoteOn(sound_key, 66, 1);
delay(500);
MIDI.sendNoteOff(sound_key, 0, 1);
delay(500);
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1);
}
void change_volume(uint8_t volume)
{
uint8_t volume_key = base_c_num_key(volume*-1);
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1);
delay(500);
MIDI.sendNoteOn(volume_key, 66, 1);
delay(500);
MIDI.sendNoteOff(volume_key, 0, 1);
delay(500);
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1);
}
void change_bank(uint8_t bank)
{
uint8_t bank_key = base_c_num_key(bank*-1)+24;
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1);
delay(500);
MIDI.sendNoteOn(bank_key, 66, 1);
delay(500);
MIDI.sendNoteOff(bank_key, 0, 1);
delay(500);
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1);
}
uint8_t base_c_num_key(int8_t number)
{
uint8_t base_c = 0;
if (number < 0)
{
number = abs(number)-1;
base_c = int(number / 5) * 12 + MASTER_NUM1;
switch (number % 5)
{
case 0:
base_c += 1;
break;
case 1:
base_c += 3;
break;
case 2:
base_c += 6;
break;
case 3:
base_c += 8;
break;
case 4:
base_c += 10;
break;
}
}
else
{
number -= 1;
base_c = (int(number / 7) * 12) + MASTER_NUM1;
switch (number % 7)
{
case 0:
base_c += 0;
break;
case 1:
base_c += 2;
break;
case 2:
base_c += 4;
break;
case 3:
base_c += 5;
break;
case 4:
base_c += 7;
break;
case 5:
base_c += 9;
break;
case 6:
base_c += 11;
break;
}
}
return (base_c);
}
void ledDecay(void) void ledDecay(void)
{ {
digitalWrite(LED, LOW); digitalWrite(LED, LOW);

Loading…
Cancel
Save