nucular / sfxrlua

A port of the sfxr sound effect synthesizer to Lua
http://nucular.github.io/sfxrlua/
MIT License
97 stars 11 forks source link

Generator yields nil #5

Closed nucular closed 10 years ago

nucular commented 10 years ago

clipboard01 It causes SoundData.setSample to fail. It happens when trying to play a randomized sound. I could just or the output but that doesn't seem feasible. I guess one of the generator locals doesn't get initialized or there's a typo somewhere.

nucular commented 10 years ago

Turns out the problem is somewhere in the demo application, when the random sound with a seed of 94 is played, it crashes only when the envelope tab is closed. I couldn't find any changes in the parameter set though...

jorio commented 10 years ago

The problem lies here. A nil gap appears in the array if generate() yields fewer samples than what getLimit() returns. Comment out that line and the bug vanishes. I don't understand the purpose of that line; is it necessary to keep it?

jorio commented 10 years ago

Related: the statement t[i] = v or 0 in the for loop in generateTable() (here) can be considered part of the problem. The for loop halts at the first nil value, so the or 0 part of the statement is never executed.