Hi Malte,
So I've been working on converting it some more. If you could give me some pointers as to the meaning of variables, that would be useful.
What are the EG... variables, like "EG", "EGFaktor","EGtrigger", and "EGState"?
Also if you're looking for a channel stealing algorithm, try this:
the type of a synth engine is "synth"
typedef struct _synthblock {
_synthblock* next;
_synthblock* previous;
synth item;
} synthblock;
Initially, you start out using the synthblock as an element of a singly linked list of free synths. You only need to use the "next", pointer, and can ignore the "previous" pointer. You can either only keep track of the head, and use it as a stack, or you can keep track of the head and the tail and use it as a queue. Either way, adding is a constant time operation, and taking the most recently or least recently used one is also a constant time operation.
Then, you have an array which keeps track of which notes are on.
synthblock* currentnotes[NUM_MIDINOTES];
When you get a note-on signal, you pop the first synth block off of the "free synth" list, and then you add a pointer to it in this array, indexed according to what note it is playing. However, you also add it to the doubly linked list of which synths are playing, again, a constant time operation, because you are just twiddling with the next and previous pointers of two blocks. Now, the array contains a pointer to a block which is in the doubly linked list.
Now, when you want all the synths to process, you can iterate through the doubly linked list, and thus you only need to process the ones that are playing notes.
When you receive a note off signal, you look up the note in the array, and then remove that item from the doubly linked list, and add it to the singly linked one.
In the end, you can do everything in constant time (or O(number of notes being played))
Anyway, I don't know if it's pointless for me to put my ideas here, but I'll probably implement it too, if this doesn't make sense now.
Jeremy
On Thu, Jan 6, 2011 at 3:36 PM, Malte Steiner
<steiner@block4.com> wrote:
On 06.01.2011 12:48, Jeremy wrote:
Yes. Except it seems that you can select different settings for each of
your voices. This doesn't really make sense if you are automatically
assigning the notes to synth engines. I think perhaps the best way
would be to have one set of settings for *all* copies of the synth
engine, and if you want different settings, then you'd have to create
another copy of the plugin.
Yes, each voice has a different sound and response to a fixed midichannel, 1 for the first, 2 for the second voice and so on...
Actually I find it rather interesting to have different settings between automatically assigned notes. For instance with slightly different sounds it even would become more alive.
But yes, for the average usage it would be great to just copy the settings across the voices.
The channel stealing algorhythm kept me from implementing polyphony so far, got to study that...
A while ago I was against the idea of plugins but actually find it now usefull for recalling sessions. It would be great to stuff PD, Csound or AlsaModularSynth into a sequencer. So far I know that you can create LADSPA plugs with Faust and Csound but instruments??