Repository navigation
audiooscillator: a band-limited oscillator with audio-rate sync, FM and PWM; Ladder at any block size - #286
Merged
Merged
Conversation
Ladder takes buffer_size in bytes, as the CircuitPython effects do, from one frame up to the default 256. Each pull then hands out that many frames and takes exactly one block from a source of the same size, so a host running small blocks gets the filter with no latency and a cutoff that can move once a block. The filter is per sample, so the audio is the default render cut smaller; renders at the default size are byte-identical to before.
…ch at audio rate Oscillator renders saw, pulse, triangle and sine from one phase, any sum of them per channel, with a two-channel node putting a second waveform on the right from the same phase. Its pitch (exponential), linear FM, pulse width and hard sync are audio streams read every sample, so one oscillator can sync to another or be modulated by it inside a block. Steps are PolyBLEP and the triangle's corners PolyBLAMP; a sync edge is placed between the samples it fell between and band-limited like any other step, at the cost of one sample of latency. Built for MicroPython, the CPython extension and CircuitPython, with buffer_size like Ladder's. verify_dsp gains its probe and the ladder's block-size probe, and the deinit and host-reset probes cover the new node.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two nodes for synthesizers built from audio-rate parts.
audiooscillator.Oscillatoris the oscillator synthio doesn't have: saw, pulse, triangle and sine from one phase, with pitch, linear FM, pulse width and hard sync read from audio streams every sample.waveformis any sum ofSAW,PULSE,TRIANGLEandSINE, and a two-channel node putswaveform_righton the right channel from the same phase. Steps are band-limited with PolyBLEP and the triangle's corners with PolyBLAMP. A sync edge is placed between the two samples it fell between and band-limited like any other step, which costs one sample of latency. It builds for MicroPython, the CPython extension and CircuitPython (circuitpython.mk), and takesbuffer_sizelike the effects.audioladder.Ladder(buffer_size=...)sets the block size in bytes, as the CircuitPython effects do, from one frame up to the default 256. A host running 64-frame blocks gets the filter with no latency and a cutoff that can move every 64 frames. The filter is per sample, so the audio doesn't change:ladder_probe.pyrenders byte-identical tomainon MicroPython and CPython, and the newladder_frames_probe.pyshows 64-, 1- and 200-frame renders equal to the default one.Evidence
Oscillatormatches the analytic synced saw to within 0.003 away from its edges (the same comparison without sync is off by more than 0.1).buffer_sizeignored in the CPython Ladder (block-size tests fail) and in the MicroPython binding (ladder_frames_probe.pyreports all six renders unequal).verify_dsp.py: 58 comparisons, 0 failures, CPython against a MicroPython unix build of this branch. The deinit-surface and host-reset probes cover the new node on both.