audiality2
audiality2 copied to clipboard
On-demand waveform rendering
If we're going to add any significant number of waves, longer waves, wave that are expensive to render, external wave libraries etc, we're going to have to be smarter about when they're actually rendered. A wave should never be rendered until someone is actually going to use it. Normally, the compiler would have waves rendered as programs being compiled reference them.
One way of implementing this would be to add a wave type A2_WDEMAND or similar to A2_wavetypes, so that these yet-to-be-rendered waves actually have handles and objects. However, that seems like a waste of resources - handles in particular.
Another option is to deal with it on the symbol level, but the problem with that is that symbols are thrown away (in fact, the whole compiler state is thrown away as of recently) after a module has been compiled. Exports are not compiler symbols!
As to the actual rendering, we should probably build this around the 'wave' directive. The current implementation already provides most of what we need. We'd just keep the A2_wavedef struct around, instead of calling a2_RenderWave() as soon as the parsing is done.
As to the current built-in waves, we could reimplement those using some "live" oscillator units and A2S programs, eliminating the need for any special cases at all. (Well, except for 'noise'. See #151.)