Repository navigation
soundmodule: prepare() makes channel 1's and the drums' instruments - #183
Merged
Merged
Conversation
A part's instrument was made by its first note when nothing selected a program first, which is how a keyboard plays channel 1 and the drums. With a large SoundFont on a board, making it and working out its preset is most of a second, so the first key sounded late. prepare() now makes those two parts once the bank is open (ready(), which takes other channels too). Checked with tests/test_engine.py on CPython, MicroPython and CircuitPython, with a planted fault for each new check, and on an ESP32-P4 with a 32 MB General MIDI bank.
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.
The first key played into midiEngine on a board was late when the SoundFont is a large one: with a 32 MB General MIDI bank on an ESP32-P4, the first note on channel 1 took 0.9 to 1.3 s to start and the first drum 0.45 to 0.63 s. A part's instrument is made by its first program change or, when nothing selects a program first, by its first note. A keyboard plays channel 1 and the drums exactly that way.
prepare()now makes those two parts' instruments once the bank is open, through a newready()that takes other channels too. A part that can't be made is left for its first note, anderrorstays as it was.This is half of the fix. The other half is PyDevices/audioinstruments#123, which works out a SoundFont preset when it is selected rather than in its first note; until a firmware carries it, the instruments made here still leave that work to the first note, so this change alone moves about 30 ms. Measured on the P4 with both changes put over the frozen modules at run time:
prepare()So opening the app takes 0.7 s longer with a bank that size, once, while it already shows that it is loading. With a 315 KB bank the first note was never late.
tests/test_engine.pypasses on CPython, MicroPython and CircuitPython, and the two new plants (ready-skipped,ready-keeps-error) each fail the contract.tools/check_stubs.pypasses. Not done: no firmware was built with this, and midiEngine's file player was not timed.