From the original SynthMaker forum (2004–2014), with its members’ names and dates.
MichaelBenjamin ·
is there a way to reinitialize a code mem array when retriggering a voice on the same channel?
currently it seems like the mem keeps its data from the previous voice.
stage(0)
{
loop(256)
{
mem[index]=0;
index=index+1;
}
}
does not work.
any ideas?
Tzarls ·
If you use stage 0, that part of the code will only be executed once when the process is initialized, AFAIk. One way would be to force a recompile, making the retrigger to disconnect and reconnect the code block using a selector.
The other way would be to use a conditional jump in ASM, in such a way that the reinit loop is only executed when a retrigger (1?) is received.
MichaelBenjamin ·
that asm jump might work but it will be some time untill i translate this. any other temporary solution in code?
rl ·
huh? AFAIK stage (0) should be the way to go. Maybe you should file a bug report
exonerate ·
I think setting "using samples" to true in the midi to poly will work.
Without that set when retriggering a note it uses the same voice and so there is no new initialization stage.
Cheers 😉
Exo
MichaelBenjamin ·
i tried all the green settings but it made no difference. i will re-check the stage 0 init in an isolated module, maybe the problem is somewhere else, but so far it sounded like the mem content was being carried over when max poly was reached and a voice was stolen.
rl ·
did some tests... indeed it's not as easy as I thought. Sure, stage(0) is executed when a new voice is created. But pressing a note seems to not necessarily trigger a new voice.
Test: put this code between the frequency out of a MIDI to Poly module and the freq input of an oscillator. It creates a rising pitch tone. When stage(0) is executed the pitch is reset. Now repeatedly hit the same note => the pitch does not reset.
streamin i;
streamout o;
float a0;
stage (0) {
a0 = 0.01;
}
a0=a0+0.001;
o=a0 + i;
Here's a method to reach the desired behaviour using the env module. The variable a0 is initialized when stage has the value 1 (it has it for one sample)
This isn't really helpful in your case, since for initializing the array you would need to code like:
good test, but yes this wont work with a mem array.
since stage 0 obviously does not get retriggered when a voice gets stolen the only solution i can think of would be with a update.
mwvdlee ·
rl wrote: This isn't really helpful in your case, since for initializing the array you would need to code like: