I've been using MATLAB and Audio Toolbox to implement a program that reads notes in from 2 midi keyboards and loops a respective audio file of the note being played.
I'm using a seperate mididevice object for each keyboard and I'm able to see the midi messages being sent from both of these using midireceive(device).
I want to have a loop that receives midi messages continuously and when there's a NoteOn message (i.e. a key is pressed), I want a sound file to repeat until the NoteOff message (i.e. the note is released). I was thinking something along the lines of if message == noteOn and note == 60 then loop the note.
How do I take the NoteOn and NoteOff messages and the note value into variables to be used with an if statement like above? Thanks in advance and please don't hesitate to ask if you have any questions.