Hi everyone,
I realize that this is probably a very noobish question because I feel that I’m missing sth. very fundamental about how DSP programming works in general. I hope this is the correct place to post this so bear with me, thank you.
I’ve been playing with a simple OSC with an AdEnv triggered repeatedly by a Metro based on the examples.
I have experience in other programming languages but am fairly new to C++ so I was surprised that the following stopped working as expected when I moved some bits of code out of the for loop in the AudioCallback because I assumed that shouldn’t break things.
static void AudioCallback(float *in, float *out, size_t size)
{
float osc_out, env_out;
// this works when inside the for loop but doesn't like this
if(tick.Process())
{
env.Trigger();
}
env_out = env.Process();
osc.SetAmp(env_out);
osc_out = osc.Process();
// until here
for(size_t i = 0; i < size; i += 2)
{
out[LEFT] = osc_out;
out[RIGHT] = osc_out;
}
}
In this case the envelop stops working correctly. It still triggers but really slow, the oscillator continues to generate sound just fine.
I assumed the env.Process() just returns a float to scale the amplitude of OSC. But why is it not enough to call env.Process() once per Samplerate Callback but has to be called in the for loop or is this maybe related to the Metro?
I hope nobody takes offense by the basic nature of my question. If anyone can point me to some resources to read up on I’d be very thankful!
Thanks in advance and have a great weekend