-
Notifications
You must be signed in to change notification settings - Fork 1
Dependencies and Platformindependent sound playing #2
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
base: master
Are you sure you want to change the base?
Conversation
…void beeing slowed by the pythons GIL
|
Thanks for the PR! This repo can definitely use some cleaning up. I got stacktraces with playsound, though: Looks like AppKit is part of macOS's built-in Python and isn't present in independently-installed interpreters or Conda environments. Installing PyObjC fixes this, but there's 1-2 seconds of lag before the sound plays. I see other projects like https://github.com/Krozark/sound-player just look for different executables depending on OS and call whatever they find - which I think I like, assuming it doesn't lag on other OSes (I've found afplay to be fine on macOS). Any thoughts? |
opinionsYeah, that dependency was even listed in pypi https://pypi.org/project/playsound/ Delays of about a second are definetly not acceptable I think the golden way would be to move everything to pip-only deps, to make it most transparent what has to be installed. For robustness reasons i would not want to depend a project on another 0 star github projects as long as there are alternatives. suggestionscrolling through that blog gives me the impression that installing simpleaudio is very nice as it has no dependencies at all. however only supporting wav. pydub could than be used to provide a little bit more support. If you like the idea i might have a look at it in the next couple of weeks but i have currently moved a bit away of speedrunning relatet stuff. the unrelatedi think it would be nice to include some default freesounds, as most people will probably be to lazy to search for it. However my audiofiles are also not entirely free. |
|
Nice, I didn't know about those libraries. Agreed that dependencies should ideally be reasonably mature and available on Pip. My thoughts: PlaysoundI found that most of the lag happens when it's importing AppKit for the first time: import playsound # no lag
playsound.playsound('gold_split.m4a') # lag
playsound.playsound('gold_split.m4a') # no lagIt's possible to pre-load the right libraries and move the lag to when the app starts - so it's still there, but at least it's not when the user hits 'split' and plays the sound: import playsound
from AppKit import NSSound # lag
from Foundation import NSURL # lag
playsound.playsound('gold_split.m4a') # no lagDon't know whether similar workarounds would be needed on other OSes though. We'd also need to set PyObjC as a dependency only when the user is on macOS and not using the system's Python - that should be possible, but not currently sure how it would be done. Simpleaudio/PyDubI quite like this option, yes! Simpleaudio can't play the .m4a files that I use, but PyDub can convert the sound file: sound = pydub.AudioSegment.from_file('gold_split.m4a')
simpleaudio.play_buffer(sound.raw_data, sound.channels, sound.sample_width, sound.frame_rate)The conversion has a dependency on ffmpeg or avconv for non-wav/raw/pcm sounds, though. It worked for me because by chance I had
Default soundsThanks, will open an issue! |
No description provided.