Repository navigation
audiosampler: raise the voice ceiling from 64 to 128 - #289
Merged
Merged
Conversation
A dense General MIDI piece holds more than 60 keys down at once, and the tails of the notes just let go push the voices sounding higher still. At 64 the sampler had to cut notes still held, and shorten many tails that were still audible; at 128 neither piece in the check needed a held note cut. The ceiling costs nothing until a voice sounds: the table is sized to the voice_count asked for, and an idle voice is skipped. Tests: 128 voices build and sum, the first 64 of a table of 128 render what a table of 64 does, a steal on the last voice fades the old note, and 128 voices render inside the block. The roadmap bullet is done.
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.
audiosampler.Samplernow takes up to 128 voices (audiosampler.MAX_VOICES, was 64).voice_countis still what you ask for, so a board that can't render 128 asks for fewer and pays nothing for the headroom.Why. Two voice-heavy General MIDI files played through the SoundFont instrument (GeneralUser GS, the pool shared by all sixteen parts, a reserve of 8): a symphony movement of 5 min 17 s and a film-score arrangement of 67 s.
Counting release tails, the symphony movement peaks at 90 voices sounding and the film score at over 500 (the bank's release stages are long). 256 voices all but removes the film score's audible truncations, but 128 is the step this change takes.
Cost. One 1,024-frame period (21.3 ms at 48 kHz), every voice looping, panned and pitched apart, x86-64, one core:
64 voices sounding in a table of 128 cost the same as in a table of 64 (0.28 and 0.28 ms on CPython, 0.67 and 0.67 ms on MicroPython). Whole-piece renders at 128 never came near a period's budget.
Correct. With the pool at 64 voices, both pieces render byte for byte the same on the old and new builds. At 128 the symphony movement, which never needs a steal, is byte for byte the render of a pool of 512. Where a 64-voice pool does steal, its render matches a 128-voice one until the block that takes the first steal and diverges there, not before. A high-pass click count against the 512-voice render finds no clicks at either size.
New tests: 128 voices build and sum (and one more is refused), the first 64 voices of a table of 128 render what a table of 64 does, a steal on the last voice fades the old note out, and 128 voices render inside the block. With the define set back to 64 the four fail. The MicroPython unix build and the three-target sampler probe agree at 64 and 128.
Boards. On a P4, 64 voices are about 2.4 ms of a 5.3 ms block, so 128 sounding at once would not fit there; the limit is a ceiling, not a default, and a board keeps its own
voice_count. Not measured on a board here.