olofson / audiality2

A realtime scripted modular audio engine for video games and musical applications.
http://audiality.org/
zlib License
79 stars 5 forks source link

One bit/PWM noise/pulse generator unit #36

Open olofson opened 11 years ago

olofson commented 11 years ago

Essentially a DC generator that flips the output sign bit at random intervals, generating full amplitude noise in a specified frequency range.

It would probably be nice and handy to have the usual 'p' (linear pitch) and 'a' (amplitude) registers (like wtosc), along with 'low' and 'high' registers which specify the longest and shortest periods allowed in terms of linear pitch offsets from 'p'. Setting 'low' and 'high' to 0 would result in a square wave at pitch 'p'.

An amplitude randomness control would probably be useful too, allowing the oscillator to use random output levels. Setting this to 1 should result in only a and -a levels, setting it to 0 would result in completely random levels, and 0.5 would result in levels from the two ranges [-a, -.5a] and [a, .5a].

Any other interesting controls that make sense to build into the unit?

It would be nice to implement subsample accurate timing for accurate handling of high frequencies, but doing that well is actually rather complicated and expensive. Is it worth the effort? Maybe simple interpolation around the switch points is sufficient? We're not trying to generate crystal clear square waves here, after all...

olofson commented 10 years ago

Another control register: Probability control for latching a new output level. 0 means DC output, 0.5 means "latch with 50% probability," and 1 means "latch every time".

The point with this is that we can set the oscillator to a fixed pitch (no period randomness), and instead implement the randomness in terms of the probability of a change.