Open
Conversation
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.
Before Making this Pull Request
util/fix_style.shand commit any relevant changes.Description
This adds hard oscillator sync support to the Oscillator class, intended for use in synthesis patches where a "master" oscillator resets a "slave" oscillator at each cycle — a classic analog synth technique (Moog, Minimoog, Korg Minilogue, etc.) that produces harmonically rich timbres when the slave is tuned above the master.
New API
void SyncReset(float frac)— resets the slave oscillator's phase with a polyBLEP correction to reduce aliasing at the discontinuity.fracis the sub-sample position (0..1) within the master's last processed sample at which the wrap occurred.float GetEocFraction() const— returns the fractional wrap position afterIsEOC()is true. Used to pass the sub-sample timing to the slave.Usage
Implementation notes
GetEocFraction()is inline; no library rebuild needed to use it.SyncReset(float)lives in oscillator.cpp — requires a library rebuild.The BLEP residual corrects the sample immediately after the sync event. The pre-sync sample cannot be corrected in an online implementation (causality limitation), consistent with the existing polyBLEP approach in this class.
NaiveWaveformValue()is a private helper that evaluates the unfiltered waveform at an arbitrary phase, used to compute the step magnitude at the sync discontinuity.The built-in polyBLEP is suppressed for one sample after sync via skip_builtin_polyblep_, since its assumed step magnitude of 2 is incorrect for a sync event.
Testing
Verified sync waveforms using oscilloscope. I also compared with and without BLEP correction and observed the aliasing improvement visible on the oscilloscope and by ear.
Demos / Example Code
You can test a Korg Minilogue emulation on Daisy Pod hardware with this project: https://github.com/TXBDan/DaisyMinilogue