-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Enabling users to set the soundfont on midi playback #2274
Conversation
For the two failing runs you asked about clarification about:
|
As well as the type stubs the CI complained about, this PR also needs an entry into the pygame-ce test suite. See the tests/ directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thanks for contributing to pygame-ce! 🍰
Left a couple of typing related reviews. Also I'd like to discuss the API a bit more? Should we go with SDL's semicolon-separated style? I wouldn't mind making the API more pythonic and having the users deal with sequences of strings
Co-authored-by: Ankith <46915066+ankith26@users.noreply.github.com>
Co-authored-by: Ankith <46915066+ankith26@users.noreply.github.com>
Question: why is this in mixer.music? Does this not apply to midi added as sounds (I'm on Windows so I can't test)? If it applies to all midi I'd think it should go in the mixer music. |
I'm not sure what you're asking. It is in mixer.music, and you're suggesting it should go in mixer music.... |
Starbuck5 is probably referring to |
Sorry I mistyped. I meant why does it not go in mixer. |
I hadn't considered this. I tested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks good. I just have a few (mostly minor) nitpicks
One final note here. Perhaps we can learn something from this issue to get soundfonts working on windows. |
I tried including fluidsynth in the windows build config but didn't have the compiling experience or intuition to make the SDL_Mixer use soundfonts on windows, so I'd prefer to wrap up this PR and make an issue regarding this. |
Co-authored-by: Ankith <46915066+ankith26@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR 🎉
PS: to the person merging this, please squash and merge this PR (you may remove any extra co-author tags that github adds)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work getting this up to be fully ready!
This PR adds a new
set_soundfont
function to thepygame.mixer.music
module. This new feature allows game developers to leverage to pay a lower cost for storing music in their game by using smaller midi-formatted music tied with any soundfont they choose.Technical Notice
This PR relies on SDL_mixer's Mix_SetSoundFonts function. At the initial commit, tests showed that setting the soundfont before loading and playing a MID file did not yield using the specified soundfont but instead fell back on the system default soundfont. This needs to be addressed before a merge will contribute anything.
UPDATE
A new
get_soundfont
function was added topygame.mixer.music
to verify whether SDL_mixer's internal soundfonts variable was correctly being updated. It turns out both functions work correctly, but there is still something in the SDL_mixer that is not immediately using the updated soundfont variable.UPDATE 2
It appears the feature works on Raspbian, but not Windows. This means the compilation of SDL_Mixer needs to be considered in the compilation of pygame-ce because it is not compiled to support soundfonts for all operation systems. At this time, the only known working platform is Raspbian 64-bit.
UPDATE 3
set_soundfont
now allows passing an empty string or no argument to clear thesoundfont_paths
variable in the SDL_Mixer. A stub has been added for both functions. I didn't see a MIDI used in the tests, so I wasn't sure if one existed, so both tests are left as todo tests. The docs now reflect this update too.UPDATE 4
The todo tests have now been replaced with real tests that validate setting and getting soundfont paths will yield expected behavior.
UPDATE 5
More quick fixes. Some extra testing has been reported.
@oddbookworm and @rethanon have done some testing. On
main
(for both manjaro linux and mac), loading a midi yields a pygame errorCouldn't open timidity.cfg
which is the alternative to fluidsynth. Installingtimidity
withyay
removes the error, but does not produce music. On this PR, (for both manjaro linux and mac), setting the soundfont before loading a midi works as intended. It seems Windows is still an issue.UPDATE 6
Moved API to
pygame.mixer
, fixed some typos, and allowedset_soundfont
to accept aNone
argument.