Let say I want to output from my plugin a note of 1 beat lenght, starting at the second beat. Pattern lenght is 4 beats, than loop.
Sample rate 44100. Due to the tempo, I got the step/size:
stepSize = (BPMTempo / 60) / SampleRate;
and at each sample iteration, I sum it.
Thus, I check the position and output midi, or loop, accordly. This would be the pseudo code
Code: Select all
step = 0
foreach sample
if(step==1)
output noteOn
else if(step==2)
output noteOff
step+=stepSize;
if(step>=4)
step=0
end
How would you fix this problem or approx? Manage offset?
Thanks!