Skip to content

Commit

Permalink
External instrument output with notes hardcoded to first 4 instrument…
Browse files Browse the repository at this point in the history
…s on Korg Volca Sampler. Only tested with Yocto as master, not sure about ISR function changes
  • Loading branch information
rv0 committed Sep 8, 2018
1 parent 2c16d69 commit 3fafbaa
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 7 deletions.
70 changes: 63 additions & 7 deletions Yocto/Interruption_fonction.ino
Expand Up @@ -3,28 +3,77 @@
// en mode master
//////////////////////////////////////////////////////////////////////

void Count_96PPQN()
/////////////////////////////////
//MIDI Output Functions
/////////////////////////////////

// plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that
// data values are less than 127: 0x90
void MIDI_noteOn(int cmd, int pitch, int velocity) {
MIDI_Send(cmd);
MIDI_Send(pitch);
MIDI_Send(velocity);
}

// stops a MIDI note. Doesn't check to see that cmd is greater than 127, or that
// data values are less than 127: 0x80
void MIDI_noteOff(int cmd, int pitch, int velocity) {
MIDI_Send(cmd);
MIDI_Send(pitch);
MIDI_Send(velocity);
}


void Send_ExtNoteOn()
{
if (bitRead((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute),TRIG1)) {
MIDI_noteOn(0x90, 0x29, 0x6b);
}
if (bitRead((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute),TRIG2)) {
MIDI_noteOn(0x91, 0x2b, 0x6b);
}
if (bitRead((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute),TRIG3)) {
MIDI_noteOn(0x92, 0x2d, 0x6b);
}
if (bitRead((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute),EXT1)) {
MIDI_noteOn(0x93, 0x2f, 0x6b);
}
}

// if ( selected_mode == MIDI_PLAY ) return;
void Send_ExtNoteOff()
{
if (bitRead((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute),TRIG1)) {
MIDI_noteOff(0x80, 0x29, 0x45);
}
if (bitRead((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute),TRIG2)) {
MIDI_noteOff(0x81, 0x2b, 0x45);
}
if (bitRead((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute),TRIG3)) {
MIDI_noteOff(0x82, 0x2d, 0x45);
}
if (bitRead((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute),EXT1)) {
MIDI_noteOff(0x83, 0x2f, 0x45);
}
}

void Count_96PPQN()
{

// if ( selected_mode == MIDI_PLAY ) return;

//PORTB &=~(1<<2);// met a 0 la sorti TRIG CPU
Reset_Trig_Out();

//MODE ROLL
if(roll_mode && ppqn_count%roll_scale[scale_type][roll_pointer] == 0 && inst_roll>0){
PORTB |= (1<<2);//envoie une impulsion sur la sorti trig CPU a chaque pas

}
if(step_changed){

SR.ShiftOut_Update(temp_step_led,((inst_step_buffer[step_count][pattern_buffer])&(~inst_mute)|inst_roll));
Send_Trig_Out();
Send_ExtNoteOn();
step_changed=0;
PORTB |= (1<<2);//envoie une impulsion sur la sorti trig CPU a chaque pas

}
else{
SR.ShiftOut_Update(temp_step_led,inst_roll);
Expand Down Expand Up @@ -101,7 +150,10 @@ void Count_96PPQN()
load_pattern_ok=0;//reinitialise le flag de load pattern
}
}
}
}
else if (ppqn_count==pattern_scale[pattern_buffer]/2){
Send_ExtNoteOff(); // Don't let midi output notes last longer than half a step.
}
}

//STOP=================================================================
Expand Down Expand Up @@ -165,10 +217,14 @@ ISR (PCINT3_vect)
if(step_changed){
SR.ShiftOut_Update(temp_step_led,inst_step_buffer[step_count][pattern_buffer]&(~inst_mute));
Send_Trig_Out();
Send_ExtNoteOn();
step_changed=0;
}
else{
SR.ShiftOut_Update(temp_step_led,inst_roll);
if (ppqn_count==pattern_scale[pattern_buffer]/2){
Send_ExtNoteOff(); // Don't let midi output notes last longer than half a step.
}
}
//pdate le clignotements des leds
if (tempo_led_count>=12) {
Expand Down Expand Up @@ -240,7 +296,7 @@ ISR (PCINT3_vect)
if((selected_mode==SONG_MIDI_MASTER || selected_mode==SONG_MIDI_SLAVE || selected_mode==SONG_DIN_SLAVE)&&(button_reset)){
pattern_count=0;//reinitilise le compteur
}
MIDI_Send(0xf8);//Serial1.write (0xf8);
MIDI_Send(0xf8);//Serial1.write (0xf8); // Midi Clock Tick
step_count=0;//reinitialise a -1 le compteur de pas pour pouvoir lire le premier pas
ppqn_count=0;
SR.ShiftOut_Update(temp_step_led,0);
Expand Down
4 changes: 4 additions & 0 deletions yocto.h
Expand Up @@ -21,6 +21,8 @@ for future versions.
void Verticalize_Pattern();
void Send_Trig_Out();
void Reset_Trig_Out();
void Send_ExtNoteOn();
void Send_ExtNoteOff();
void Handle_NoteOff(byte channel, byte pitch, byte velocity);
void Check_Midi_Channel();
void Send_Trig_Out_Midi();
Expand All @@ -41,6 +43,8 @@ for future versions.
void Update_Pattern_Led();
void Mode_Pattern();
void MIDI_Send(byte OutByte);
void MIDI_noteOn(byte channel, byte pitch, byte velocity);
void MIDI_noteOff(byte channel, byte pitch, byte velocity);
void Wire_Begin_TX(uint16_t address);
void Save_Midi_Channel();
void Save_Midi_Note();
Expand Down

0 comments on commit 3fafbaa

Please sign in to comment.