I am trying to write a sound generator external that uses my own "real-time" audio synthesizer (C library). My synth responds to a set of inputs parameters by outputing a buffer of 512 samples of audio. When the next set of parameters is presented, the synth outputs the next 512 samples etc. What is the correct way of integrating such a synth as an external?
So far I have a patcher that present the parameters to my external as a list every 10 ms using metro.
In my external then, the function that handles the list message inputs the parameters to my synth which in turn fills a global variable buffer "gBuffer" with 512 samples.
Then the perfom routine copies the content of the gBuffer to the output signal vector (I have io vector size = 512 and sigal vector size = 512).
I do hear what seems to be phase discontinuity clicks with this method. The perform routine seems not to be called every 512 samples excately or not starting to copy the ignal where it should. I say that because by comparison, when I write the content of gBuffer to a wav file instead of to the ouput sinal vector, then I get no discontinuities clicks if metro is set to more than 11.6ms (12ms) which is the duration of one audio buffer generated by my synth.
I have also tried to call my synth inside the perform routine. I also get discontinuities and under some conditions get crossfading artifacts.
So again what would be the proper way of inegrating my synth as a real-time external?
Also, any hint or insight of how and when does the perform routine gets called would help.