SynthMaker

how to init a mem array on voice retriggering?

Archive · 2009 9 old posts

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:

a[0]=(stage!=1)&a[0]; a[1]=(stage!=1)&a[1]; a[2]=(stage!=1)&a[2]; ... a[255]=(stage!=1)&a[255];

MichaelBenjamin ·

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:

a[0]=(stage!=1)&a[0]; a[1]=(stage!=1)&a[1]; a[2]=(stage!=1)&a[2]; ... a[255]=(stage!=1)&a[255];

How about something like this:

float retrig;

retrig = stage!=1; loop(256) { mem[index]=retrig&mem[index]; index=index+1; }

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.