vsariola / sointu

Fork of 4klang that can target 386, amd64 and WebAssembly. Tools run on Windows, Mac & Linux
MIT License
249 stars 17 forks source link

playback freezes if you add an Oscillator to Global without having a Send #32

Closed esaruoho closed 3 years ago

esaruoho commented 3 years ago

Steps to replicate:

  1. Toggle playback, hear tune
  2. Add Oscillator to Global

Expected: Playback continues Current: Playback dies

Only resumes if you add Send after Oscillator

vsariola commented 3 years ago

Every time a new unit is added, the player tries to recompile the patch into the internal virtual machine. However, if a source (e.g. an oscillator) is not balanced by a sink (e.g. an out), it leads to a compile error.

There's a few options how to resolve this: 1) Keep on using "last known good" synth until the user makes a valid patch. This is how it worked earlier, but lead to confusing situations where one does not notice the compile error and tries adjust parameters and nothing happens, as the patch is in erroneous state and is not getting compiled. 2) Make the sound silent because the synth does not compile, but keep the time running (play advances). 3) Keep it as it is: when a synth does not compile or throws an error (e.g. not a number, division by zero etc.), the sound and playing is stopped.

Tangential to all these is that the compiler could do "best effort" to fix patch errors. For example: 1) any signals left on stack in the end of the patch are automatically popped (discarded). This might not help too much, as at most 8 signals can be on the x87 stack and any extra useless signals will quickly lead to stack overflows. 2) If a specific instrument gives an error, try to compile the patch by excluding the instruments. The sound still "disappears" suddenly for that particular instrument, so not entirely different from the option 2) above.

esaruoho commented 3 years ago

maybe best for user to learn how to use the app rather than hold their hand. closing