Reading around a bit, it seems the problem is related to arguments being converted to .kr values. Besides the fact that I don’t know how to convert them to usable values for this specific task, it is obviously not clear to me how the input arguments work. I was wondering if anyone could briefly explain to me where and why I’m wrong in this example…
Thanks a lot!
SynthDef inputs may only be floats. There’s no exception to this rule.
Dictionary-at is a language-side operation, so the server can’t perform it.
So on both counts, it has to be done a different way.
One way is to flatten the data into an array and access the data by index. If it’s a small array, you could hard code the array into the SynthDef; otherwise load it into a Buffer.
I’ve followed your suggestion of hard-coding the array into the SynthDef, but I got the same problem. It works when I access the index directly, as in:
Not quite. I had suggested to get the data into an array, but your code snippet gets the keys into an array.
Again – the server does not know what to do with symbols. So an array of symbols is useless in the server.
at (= array[something]) is a language-side operation. This means that it needs to know, right now, exactly which index to look up.
A SynthDef argument is not a specific value. It’s an object that represents a place where a future value will be filled in.
So SynthDef arguments will always be incompatible with array[something].
In the server, if you want to index based on a synth argument, you can use Select.kr with a flat array of numbers (only numbers) that’s embedded into the SynthDef, or you can use Index.kr with a buffer. Other approaches are not going to work.
This means you have to manipulate the data into a format that can be embedded into a SynthDef, or loaded into a buffer. Fortunately, that’s the same format: a flat array (no sub-arrays).
Vowel(\a) gives you an object with properties freqs, widths and dBs. This is not an array, but you can make one:
Note that there are 15 numbers for one vowel. That’s important later.
This is not a flat array – it has sub-arrays – but .flat helps with that.
Again, you can’t use Vowel directly in a SynthDef with changeable indexing. The help file examples work because the key is hardcoded (never changes). But you can collect all the vowels you need in advance, and pack them into one array.