lichen-community-systems / Flocking

Flocking - Creative audio synthesis for the Web
GNU General Public License v2.0
695 stars 60 forks source link

Under some situations, flock.ugen.playBuffer fails to reset when re-triggered #202

Closed colinbdclark closed 7 years ago

colinbdclark commented 7 years ago

Flocking's flock.ugen.playBuffer unit generator, in some circumstances, will fail to play a buffer more than once. The following conditions seem to be required to reproduce this bug:

  1. The buffer must have played fully to the end
  2. Any combination of the speed, start, and end inputs must be running at non-constant rate and/or set to values other than their default, and the trigger needs to be running at audio rate—this is in order to cause the poorly-named otherwiseGen function to be used by Flocking
  3. The loop input must be set to not loop

If all these things are the case, the buffer will play fine the first time around, but when triggered a second or subsequent times, the unit generator will output only silence.

Upon inspection, this is due to the fact that the rather tangled logic in this case uses a continue statement, causing it to bail out before the previous trigger value is recorded. As a result, the buffer can never be successfully re-triggered, because even if it is specified as a high value, the intervening low value was never properly recorded.