SynthMaker

Code Component - control statements

Archive · 2005 5 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

Dman6x ·

Hi everyone,

My first post, so first thing: Thanks to outsime for a cool program!

I like the new code component but I need "if" statements and loops (for, while, etc). Is that in the works?

jorge ·

Hi Dman6x, welcome to our forum.

The existing code component processes four channels of sound at the same time in order to take advantage of the SSE instructions. Each channel is dedicated to a separate sound process ( each sound process corresponds to a note being played ). You cant have conditional jumps that affect one of the channels but not the others. There are ways around that limitation as I described in the following kvr post: http://www.kvraudio.com/forum/viewtopic.php?t=39186&postdays=0&postorder=asc&highlight=synthmaker+jorge&start=52

Eliminating the conditional jump is also good for performance reasons.

If you want to use the "if" statement on a Mono component that processes only one channel then it should be possible. If you have an example of an algorithm you're trying to create using an "if" statement it would make it easier while implementing it.

jorge ·

Having thought a bit more about the "if" statement used on 4 simultaneous sound channels I realised that it is possible although the if statement would have to run if at least one of the channels needs it, for example:

if(condition) { process(ch0,ch1,ch2,ch3); }

the process function would have to run if at least one of the channels needs it which is not ideal from a performance point of view but it is easy to make all the other channels unnafected.

So basically the answer to your question is that I think the "if" statement will be available soon. It's certainly becoming a priority after a few people requested it.

Dman6x ·

I'd like to do something like this:

monoin in; monoout out; float prev; float curr; prev = curr; curr = in; if prev > 0 and curr <= 0 or if prev <0 and curr > 0 then out = 1; out = 0;

I'm not 100% sure the logic is correct but I think this would give a pulse (send 1 to out) whenever a zero crossing happened. Not maybe that usefull yet but could be very usefull when a wave file module is released.

I'd also like to do stuff with say a for loop to create a buffer of sound (again mostly thinking ahead to when wave files can be loaded). For instance connecting a float array module to a code module and using the code module to send succesive floats to the array for a certain number of samples.

These are a couple examples of the kind of things I'd want to do with the code module. I think it would also be great if it could have integer ins and outs to.

Thanks for listening 🙂

jorge ·

You're on the same wavelength as me and you're mentioning things that have already been developed but are not yet ready for beta releasing. We have internally a component for loading a wave file, it exposes a pointer to a sound buffer which can be used inside a code component to do processing like the example you give. I'll try to use the example code you give and make it work. Eventually we hope to also have a wave editor that accepts the same type of BufferPointer.

I have been playing with a 3rd generation of Code component that integrates the other types of connectors, i.e: float, int, midi, view etc. It allows for things like playing a sound buffer when you get a trigger on a certain input etc. It works with event handlers, one for each Input connector and it already does something but it is far too incomplete for a beta release. What your example code does is already possible with the assembler code component in a similar way as I describe in the kvr post I mentioned but I guess you ( and most people including me ) prefer to stay high-level and not touch the assembler code component.

The way to achieve the same as an "if" statement in SSE is to create a mask as a result of a comparison:

cmpps xmm1,one,5 --> xmm1=0xffffffff 0x00000000 0xffffffff 0x00000000

and use that mask to only affect the channels that need to be affected. I'll try to do something similar when translating from high-level to assembler.

Thanks a lot for your example, I much prefer to implement features when they're needed and with real examples.

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.