sparx

MIDI Note on/off filter

2 posts in this topic

Hello all

 

Been ages since I last posted on here, so hope everyone is well?

 

Am revisiting an older project and want to add some way to stop Note messages going to 2 ports.

 

The idea is to have one MIDI In, 2 MIDI Outs, 32 buttons and 32 LEDs arranged in two rows of 16 each, one for each channel.

The idea being, at switch on, all channels are passed to both MIDI Outs, should a button be pressed, LED goes out and Note messages no longer passed on that channel to one of the ports, but still passed to the other. 

 

Got a couple of MIOS 8 cores spare which I would like to use up, anyone got any thoughts/input on this?

 

Thanks and regards

 

Share this post


Link to post
Share on other sites

something like this:

 

this is for MIOS32... you can adapt the most of code by removing the "32" some synthax may changed like "=!" or the {{}} initalizing thing...

 

the code should (not testet) do:

pin 0 of the DIN Modul is the "noteGateSwitch" it is initalized with 1 - meens the Port 32In is in THRU-Mode to Port32 Out

while Port32In to Port33Out is always in ThruMode

 

The thing is when you interuppt the NoteStream/gate you loose NoteOffMessages - that mean your Synth will hang > sound endless!

So I addet a Buffer/array "u8 NoteState" it has 16Midichannels and for that 16x128 Note-States that are saved (notestate=velocity)

 

If you now Deactavete the NoteGateSwitch- a "for" cycle counts from 0-127 > it steps now in every NoteState and compare if one of the States is "ON/>0" if so it sends a noteOFF command out to the Port32Out

 

One Channel one Switch:

#include <mios32.h>
#include "app.h"

 u8 NoteState[16][128]={{}};
 u8 DumpNoteOutCounter=0;
 u8 NotePort = 32; //=Switchable NotePort
 u8 NoteGate = 1;
 u8 ThruPort = 33; //=OutPort which always thruput the NotePort-In!
 
void APP_Init(void){}
void APP_Background(void){}
void APP_MIDI_Tick(void){}

void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package){
   if(port==NotePort){
	//Save the Note-Velocity-State:
	if(midi_package.chn==0) {NoteState[0][midi_package.note] = midi_package.velocity;}
    //Always forward Port32In to Port33Out
    MIOS32_MIDI_SendPackage(ThruPort, midi_package);

   //forward Port32In to Port32Out - only when the gate switch is activated
    if(NoteGate==1) {MIOS32_MIDI_SendPackage(NotePort, midi_package);}
}}

	
void APP_SRIO_ServicePrepare(void){}		
void APP_SRIO_ServiceFinish(void){}

		
void APP_DIN_NotifyToggle(u32 pin, u32 pin_value){	
	//Trigger the NOTE-OFF-Commands & Toggle the MIDI-STREAM-GATE
		if(pin == 0 && pin_value == 1){ //pin= your Hardware Switch 4 the Note-Gate
			NoteGate =! NoteGate; //toggle the Switch-State
			if(NoteGate == 0){
				for(DumpNoteOutCounter=0; DumpNoteOutCounter<128; ++DumpNoteOutCounter) 
				    if(NoteState[0][DumpNoteOutCounter]>0){//Are there Note On-States?
						MIOS32_MIDI_SendNoteOff(NotePort, 0, DumpNoteOutCounter, 0);}}}} //Send Note Offs


void APP_ENC_NotifyChange(u32 encoder, s32 incrementer){} 
void APP_AIN_NotifyChange(u32 pin, u32 pin_value){}
Edited by Phatline

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now