Repository navigation
Vague idea: Low frequency oscillators and related concepts #352
Description
Many audio synthesis systems use LFOs (Low Frequency Oscillators) as inputs for generating sound outputs.
In principle, an audio channel inside the VDP could be used as an LFO. Right now tho the possible frequency range of a channel is a 16-bit integer Hz value, which inherently can't support frequencies less than 1Hz or provide any fidelity in the low range.
An advantage in using a channel in the existing audio system as an LFO would be that existing audio system features could be used, such as envelopes.
Simplistically we could add a setting to an audio channel to declare it as an "LFO", and provide a way to adjust the supported frequency range. Perhaps this could be as simple as deciding that in LFO-mode a channel's frequency becomes an 8.8-bit fixed-point value?
A channel set as an LFO would be omitted from the general audio output mix.
The output level of a channel marked as an LFO channel would likely need greater control than is currently offered. Right now as we have a signed 8-bit audio system a channel's output is set via the volume level of the "note" and the "channel" which support values 0-127 and get combined to produce a value in that range - with the channel producing sample output values in the range -127 to +127. We'd likely wish to allow for much greater control over output, and support a much wider range of values than signed 8-bit. Ideally an LFO should be able to generate at least 16-bit values, with control over the used output range. This likely means supporting more "channel waveform parameters" for LFO channels to provide such control.
For an LFO channel to be useful as a synthesis input we would need to provide ways for that to be possible. As a bare minimum this could be achieved by providing a way to read the current sample value of a channel. This could be done via VDP Variables - which would fit in with the idea that an LFO's output could be a 16-bit value. An advantage of this would be that an LFO could be used for other purposes - for example it could be used for real-time graphics animations.
Indeed the whole audio system currently lacks an integration with VDP Variables and also events/callbacks - this is an outstanding area of work. See #291 and #311. LFOs could have a significant role to play in how such an integration could work. They could for example be used as a source of events - for example one could set up an LFO with a square wave with an adjusted duty cycle to trigger events on "value went high" and "value went low" to generate a rhythm. Events for "note started", "note ended", "sample cycle started" and "sample cycle ended" could have uses for synchronising effects between audio channels.
For more practical audio synthesis applications we would likely want to add in the ability to use LFOs as inputs for envelopes. The entire envelope system could use a revamp to allow them to be more sophisticated. Currently we support two classes of envelopes, one for "volume" and another for "frequency" - with a total of 3 types of envelopes supported. Other audio parameters could be adjusted tho - for example a square wave can have it's duty cycle adjusted, but currently it's not possible to do that via an envelope, as it would require a specific envelope type to do so... An envelope could become a feature that adjusts a VDP Variable over time...
It feels like there is overlap between events/callbacks and envelopes that could be interesting to explore.
Activity