Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

midi.config.add_synth now subsumes add_synth_object. #453

Merged
merged 4 commits into from
Jan 27, 2025
Merged

midi.config.add_synth now subsumes add_synth_object. #453

merged 4 commits into from
Jan 27, 2025

Conversation

dpwe
Copy link
Collaborator

@dpwe dpwe commented Jan 27, 2025

Originally we had midi.config.add_synth() which took a patch number and voices count.
Then we created the Synth() object which handled the patch number. But add_synth called it.
Then we added add_synth_object so you could construct your own Synth object and add it to MIDI.
But users were confused about how synths were created since midi.config.add_synth() was doing it for them.

This change alters midi.config.add_synth() to accept a Synth object, and to prefer that pattern. This makes it obvious to the user that Synth objects are the core concept.

The problem here, I realize, is that in order to manage the limited voices resources, it's best to release any existing synth before creating the new Synth object. However, if the Synth is passed as an instantiated object it will already have grabbed its voices. Maybe we can fix with some kind of deferred initialization in the Synth object.

@dpwe
Copy link
Collaborator Author

dpwe commented Jan 27, 2025

I added deferred initialization to the Synth() object, so the midi.config.add_synth(synth=Synth()) will cleanly reuse the voices from any synth it replaces.

@bwhitman
Copy link
Collaborator

This LGTM and does make more sense, i think

@dpwe dpwe merged commit c09f8cb into main Jan 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants