[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] A clever way to mix three IdentityDictionarys?



Hi list,

I have stored three presets stored in a structure like this:

Array[
	IdentityDictionary[
		\tGrain -> IdentityDictionary[\dist -> 0.4, \amp ->0.4],
		\filter -> IdentityDictionary[\freq -> 400, \rq -> 7.2]
		\panner -> IdentityDictionary[\width -> 0.3, \freq -> 0.3]
	],
	IdentityDictionary[
		\tGrain -> IdentityDictionary[\dist -> 0.4, \amp ->0.4],
		\filter -> IdentityDictionary[\freq -> 400, \rq -> 7.2]
		\panner -> IdentityDictionary[\width -> 0.3, \freq -> 0.3]
	],
	IdentityDictionary[
		\tGrain -> IdentityDictionary[\dist -> 0.4, \amp ->0.4],
		\filter -> IdentityDictionary[\freq -> 400, \rq -> 7.2]
		\panner -> IdentityDictionary[\width -> 0.3, \freq -> 0.3]
	]
]

I want to mix the values in these IdentityDictionaries. I' have an Array with three weights, where the sum of the three weights is normalized. I want to have the inverted values of these weights determine the mix factors for each preset.
Can anyone help me to figure a clever way to mix these presets?


the data format is a bit irregular. You can't rely on order in an IdentityDictionary. So here is a simple solution when you convert the dicts to a simple n-dimensional array:

var weights = [0.1, 0.3, 0.6], res;
b = a.collect { |x| x.collect { |y| y.as(Array) }.as(Array) };
c = b.collect { |set, i| set * weights[i] }.sum;

now you only have to convert it back..

normally I use arrays of associations when I need order.
--





.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/