Repository navigation
Ramp a bus's volume across the block instead of stepping it - #1262
Open
mateusz28011 wants to merge 1 commit into
Open
mateusz28011 wants to merge 1 commit into
mateusz28011 wants to merge 1 commit into
Conversation
A bus's output gain was one constant per block, so a volume change landed as a step at the block edge. Under a sounding note that is a click: with a 55 Hz sine on a bus and its volume set from 1 to 0.2, the largest sample-to-sample step of the output was about 50 times the note's own. The gain now runs linearly from where the last block left it to the bus's volume over the block (5.8 ms at 44.1 kHz). A bus whose volume does not change gets the same gain as before, sample for sample, and a bus's first block after start or reset takes its volume as it stands, so a bus muted before it has played stays silent. No reference output moves. TestBusVolumeRamp moves a bus's volume down and up under a held note and checks the output takes no step and is at the new level two blocks later, that a bus muted before its first block makes no sound (from the start, and when it is first used later), and that the first note after a reset starts at full level.
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.
Problem. A bus's output gain is one constant per block (
volume_scale[bus]inamy_fill_buffer), soamy.send(bus=N, volume=x)under a sounding note lands as a step at the block edge, which can click. Automating a bus's volume runs into it; my case is ducking a bass bus on every beat.What the new test renders:
On
main(9106f4c) the largest sample-to-sample step of the output is about 50 times the note's own largest step. With this change it is 1.0 times.Change. The gain runs linearly from where the last block left it towards the bus's volume over one block (5.8 ms at 44.1 kHz), reaching it at the next block boundary.
volume_scale[bus]now stores that target and a newvolume_step[bus]the per-sample step; the mix loop is otherwise as it was.What stays the same.
volume=0sent before anything has rendered is silent from the first sample, as now.python -m amy.testpasses at its default threshold (140 tests).What changes, on purpose. Once a bus is being processed, a volume change is no longer instant: it takes one block. That includes a mute. The tests that set a bus volume up front (TestAlgo2, TestXanaduFM, TestBuses, TestSynthBusCmds, TestTranceGlitch among them) are unaffected for the reason above.
Cost. One more array of
max_busessamples; per block, one subtract and divide per bus to set the step; in the mix loop, one more multiply and subtract per bus per channel sample. Host build (macOS, arm64), four buses each with one sine: 7.15 µs per block with the change, 7.25 µs onmain, medians of nine runs of 4000 blocks. On an AMYboard (ESP32-S3) playing a sequenced drum pattern with four buses active,tulip.cpu()read about 44 % before and after, inside the run-to-run spread.make timingcurrently fails ontime=(amy/timing.py), so the host numbers are from this script:benchmark script
Test.
TestBusVolumeRamp(customtest()), with a held 55 Hz note and the volume moved 1 → 0.2 and 0.2 → 1: