Hello guys , I wonder how can I implement midi control to my project so in every note that I hit plays the loaded file thank you very much.
this is my code so far :
http://www.megafileupload.com/6S5i/PluginProcessor.cpp
http://www.megafileupload.com/6S5j/PluginProcessor.h
http://www.megafileupload.com/6S5k/PluginEditor.cpp
http://www.megafileupload.com/6S5l/PluginEditor.h
And I have an issue when I load another file something is not working.
Here’s a basic on how to play a sample when a MIDI note comes in.
MIDITest.zip - Juce Project
The algorithm is basically
for each new midi note on message
Find position in buffer (beginning @ 0 ? middle? end ?
add new note to CurrentNotes (index = array + sampleLength (number of samples int)
Then, you cycle through your ‘current notes’ and add the sample to the output:
For each (n = 0 -> CurrentNotes.size())
{
For each ( i = 0 - > sampleCount in audio buffer)
{
if CurrentNote.index < sampleLength
{
if(CurrentNote[n].index >= 0)
{
int getSample = sampleLength - CurrentNote[n].index
output[i] += sampleData[getSample];
}
}
CurrentNote[n].index -= 1
}
}
As far as loading samples, I’m not sure how to help you there.
1 Like
jules
June 3, 2016, 7:44am
3
Hmm, that’s a pretty bad example algorithm for anyone to try to follow, I’m afraid!
Best plan to just play some samples would be to use the juce Synthesiser/SamplerSound/SamplerVoice classes. See the big juce demo’s synthesiser example, where it plays some sampled cello sounds.
1 Like