«Enveloppe resizing function.» by Dindoléon
on 22 Jan'20 17:25 inEnveloppes sizes are fixed. This means that if enveloppe's levels are equals to [ 1, 0, 0, 0, 0, 0, 0, 0 ] and times are equals to [ 1, 1, 1, 1, 1, 1, 1, 1 ], the synth UGens will take resources 8 seconds but will only be audible 1 second. To avoid this, passing both the levels and the times to this function will detect when the sound stops playing and will reduce the "silence" times to 0.01s, thus freeing the UGens way faster. Can be useful for granular synthesis APIs, where rapid grain emission can quickly overload the server. This function's purpose is to be used with a graphical display, where user cannot control the enveloppe length.
1 2 3 4 5 6 7 8
( ~resize_enveloppe = { | levels, times | var reverted_levels, index; index = 0; reverted_levels = levels.reverse; while( { reverted_levels[index] == 0 && reverted_levels[index+1] == 0 }, { times[ times.size - 1 - index] = 0.01; index = index + 1 } ); }; )
reception
comments