Repository navigation
fx_lowcut: keep a bus's chorus, echo and reverb out of its low end - #1261
Open
mateusz28011 wants to merge 2 commits into
Open
mateusz28011 wants to merge 2 commits into
mateusz28011 wants to merge 2 commits into
Conversation
A reverb or an echo on a bus that carries a bass or a kick puts its tail into the low end, and nothing on the bus can stop it: the EQ sits before the effects and would take the lows off the dry signal too. `fx_lowcut` (wire `J`, Hz, 0 = off) high-passes what those three effects add. They all mix their output onto the bus on top of the dry signal, so the bus after them minus the bus before them is their contribution; that difference goes through two first-order sections (12 dB/octave, 3 dB down at the cutoff) and back onto the dry signal. Below the cutoff the bus is the dry signal, and low content the effects generate themselves goes too. Off by default: nothing is copied or filtered, and the bus line of a state dump is unchanged. A dump names the cut only when it is set, as it does the bus distortion. The cutoff can move under a sounding note: a running cut keeps its filter state, and set to 0 it fades to the uncut effects over a quarter second before the stage stops, so the lows come back without a step.
…ed corner From a review of the first commit: - Without AMY_HAS_MUL64 (Cortex-M0), FILT_MUL_SS keeps 12 fractional bits of each operand, too few for a pole this close to 1: the filter left a DC offset. The stage now uses a 64-bit product on every build. - Switching the cut back on while it was fading out snapped it on. The fade is now one position that runs either way, so off and on-again both ramp. - The section corner was prewarped after scaling instead of before, which put the 3 dB point slightly off at high cutoffs (2.3 dB down instead of 3 at a quarter of the sample rate). Scaled after the tan now. bus_fx_lowcut takes the whole bus rather than one channel, and the fade and coefficients are set in one place (fx_lowcut_set). TestFxLowCut also switches on again half way through a fade.
This branch has not been deployed
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.
Goal: take the bass out of a bus's wet signal (chorus, echo and reverb tails) while leaving the dry bass as it is.
A bus that carries a kick or a bass gets its reverb and echo tails in the low end too. The bus EQ cannot fix that: it runs before the effects, so it changes the dry signal as well. Echo has its own high-pass (a negative
filter_coef), but that covers the echo alone, not the chorus or the reverb.This adds one per-bus parameter,
fx_lowcut(wireJ, in Hz,0= off, the default):How. The bus chain is distortion → EQ → chorus → echo → reverb → external hook. Chorus, echo and reverb each add their output onto the bus (
+=indelay.c;stereo_reverbwrites input + level × wet), so the bus after the reverb minus the bus before the chorus is their combined wet signal. Withfx_lowcutset,amy_fill_buffercopies the bus before the chorus, and after the reverb high-passes that difference and adds it back onto the copy. The dry signal never goes through a filter; distortion and EQ sit before the copy and the hook after the cut, so they are not affected.The filter is two first-order sections in series (
fx_lowcut_coefs/bus_fx_lowcutinfilters.c): 12 dB/octave, about 3 dB down at the set frequency, which is clamped to a quarter of the sample rate.Why one cutoff on the sum, in core. It needs no change inside the three effects, and it is one setting for "keep the effects out of the bass". A bus hook cannot do it: it runs after the effects and never sees the bus before them.
Cost. Off (the default): a flag test per bus per block; nothing is copied or filtered, and a bus's line in a state dump is unchanged (the setting is written only when it is set). On: one block copy and five multiplies per channel sample. One scratch block of
AMY_BLOCK_SIZE * AMY_MAX_CHANNELSsamples is allocated on first use, shared by all buses (they are processed one after another, after the two cores' blocks are merged) and kept until deinit; if that allocation fails the cut stays off. The loops followAMY_NCHANS, so mono builds are covered. On an AMYboard (ESP32-S3) with chorus, echo and reverb on two buses,tulip.cpu()read 61.0 % without the cut and 61.1 % with it.Changing it while a note sounds. Moving the cutoff keeps the filter state. Setting it to 0 crossfades to the unfiltered wet signal over about 250 ms before the stage stops. In host renders of a held 55 Hz note, the largest sample-to-sample step at any of these changes stayed below the largest step elsewhere in the take.
Test.
TestFxLowCuthas a customtest(): with the effects off, the output is sample-identical with and without the cut; under a 200 Hz cutoff the wet signal drops 16 dB at 55 Hz (±1.5) and is unchanged at 2 kHz (±0.5); switching off under a held note, sent twice, makes no step and ends sample-identical to a bus that never had a cut; the setting shows up indump_state().python -m amy.testpasses (140 tests) atAMY_TEST_THRESHOLD_DB=-70.0;make check-c-apiis clean andgodot/amy.gdis regenerated.Not in this PR: a slope setting, or a cutoff per effect.
Host render, same C code. Left: wet level with the cut at 100 Hz relative to without, against the two-section curve. Right: what reverb and echo add to a bass line (bus minus dry signal) with the cut off, at 100 Hz and at 200 Hz.
I opened this as a PR so there is code to look at. If you would rather settle the API in an issue first, or build it another way, I'm glad to go that route.