|
|
|
@ -14,8 +14,8 @@ |
|
|
|
|
#define TEST_DUR_MIN 200 |
|
|
|
|
#define TEST_DUR_MAX 1500 |
|
|
|
|
|
|
|
|
|
#define MASTER_KEY_MIDI MIDI_C6 |
|
|
|
|
#define MASTER_NUM1 MIDI_C1 |
|
|
|
|
#define MASTER_KEY_MIDI MIDI_C7 |
|
|
|
|
#define MASTER_NUM1 MIDI_C2 |
|
|
|
|
|
|
|
|
|
class midi_event { |
|
|
|
|
public: |
|
|
|
@ -41,62 +41,29 @@ void setup() |
|
|
|
|
|
|
|
|
|
randomSeed(analogRead(A0)); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// 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); |
|
|
|
|
// Bank change 1
|
|
|
|
|
change_bank(1); |
|
|
|
|
delay(2000); |
|
|
|
|
|
|
|
|
|
// Sound change 17
|
|
|
|
|
change_sound(17); |
|
|
|
|
delay(2000); |
|
|
|
|
|
|
|
|
|
// Volume change 0.5
|
|
|
|
|
MIDI.sendNoteOn(MASTER_KEY_MIDI, 99, 1); |
|
|
|
|
delay(500); |
|
|
|
|
MIDI.sendNoteOn(MIDI_AIS1, 66, 1); |
|
|
|
|
delay(500); |
|
|
|
|
MIDI.sendNoteOff(MIDI_AIS1, 0, 1); |
|
|
|
|
delay(500); |
|
|
|
|
MIDI.sendNoteOff(MASTER_KEY_MIDI, 0, 1); |
|
|
|
|
|
|
|
|
|
change_volume(5); |
|
|
|
|
delay(2000); |
|
|
|
|
|
|
|
|
|
// 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); |
|
|
|
|
|
|
|
|
|
change_bank(3); |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
change_sound(17); |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
change_volume(1); |
|
|
|
|
delay(5000); |
|
|
|
|
*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void loop() |
|
|
|
@ -130,6 +97,104 @@ void sendMIDI(int8_t note, int8_t vel, int8_t chan, uint32_t dur) |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
digitalWrite(LED, LOW); |
|
|
|
|