-
Notifications
You must be signed in to change notification settings - Fork 85
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
Allow PlayMusic() to work from Sound Library / move sound code to SDL? #759
Comments
Looking at the code, it appears that PlayMusic() uses BASS Audio Library and PlaySound() uses Windows PlaySoundA/W. I'm guessing that this has access to the table container whereas PlayMusic() does not? I imagine then, that this request is not possible to implement? |
It would also be possible, by passing in the in-mem data instead of the file (at the cost of having to have all music in-mem instead of streaming from disc). But lets step back a bit, cause in general there is (at least) one thing that should be done before all of that: There is the ONLY_USE_BASS define that can be used to get rid of the old windows API based sound playing, that i started years ago. One could even be more radical and consider a fully OSS based (and still well maintained and multi-platform!) sound lib instead of BASS (i guess SDL already has plenty of that ;)), too, while at it, and base the whole of the sound code on that. Would be great if you could pick this up.. :) |
FWIW, I think #572 might be fixed in standalone (but not backported to master), so it would be interesting to try I mentioned this on discord, but Blood Machines uses the WMP ocx which we were able to recreate in standalone. I've added all the methods in Lines 198 to 299 in cb17c1d
vpinball/standalone/inc/wmp/WMPControls.cpp Lines 15 to 59 in cb17c1d
|
If we go the SDL way, we could choose to use with https://github.com/libsdl-org/SDL_mixer which seems to offer everything we need. It would be really nice to drop the legacy windows only stuff. |
I would be all for that. I have to do a bunch some trickery (approved) on tvOS with BASS due to licensing issues. |
yes, instead of :
try:
|
Is there a preference of SDL or BASS? |
see above: SDL_mixer |
BASS is not open source licensed, and we are already using SDL, so I would go for SDL. |
Second all of the concerns above.. But at least something open source and well maintained, please.. Back then i picked BASS because i knew it well, and there were not that many options that worked as good in practice. |
@jsm174 i just backported your audio changes, thanks!! |
I'd be willing to look into this. It won't be a fast process. There's a lot I don't know about the sound system of VPX |
Nice! Take your time, this should become a post-10.8 thing anyway. Also take the freedom to restructure what you need, its super convoluted at the moment anyway (as it evolved/mutated over 2 decades ;)). And as vbousquet pointed out, the major hurdle will be 3D sound support (along with multi-soundboard). |
One more thing that just came to mind: If you will pick SDL, please consider going directly to SDL3, as it apparently revamps the audio system, compared to SDL2. |
Just went through SDL2 mixer docs and it mentions this:
https://wiki.libsdl.org/SDL2_mixer/Mix_OpenAudioDevice SDL3 looks similar, static If I understand it correctly this would no longer allow having a separate device for the backglass |
Further SDL2/3 mixer does not support 7.1 sound. |
I understand it does not support 7.1 positional sound but does it support 7.1 simple direct channel (I mean, doing the positional stuff on VPX end, which seems more logical since we have a very specific use case) ? |
Indeed, we could roll our own specific mixer. And if we don't use the mixer we can use multiple audio devices. |
I don't know if this is that complicated. In the end, I would hope that it resolves to compute 4 attenuations (based on the player position, which is already defined in real world unit in latest builds, allowing to apply traditional physics) and sending the same streams but with the attenuations to the 4 exciter channels. It could even prove to be easier to do than spoofing the native 3D positional sounds of Windows like we do now (which expects the listener to be inside the speakers and not outside and above, and could be difficult to make portable). edit: after some search, there are papers that describe solutions for our use case like this one http://decoy.iki.fi/dsound/ambisonic/motherlode/source/2001_Spatial%20Sound%20Generation%20And%20Perception_Ville%20Pulkki.pdf edit2: after some more search, it happens that VBAP seems to be quite admitted as a 'good' solution for this problem and there are a few OSS library available to be used as-is like this one: https://github.com/pierreguillot/vbap |
Something else i just stumbled over by accident, maybe also sufficient for our needs? |
Wow! Very interesting! |
Whoa! |
On top, this could be used for .ogg support: https://github.com/edubart/minivorbis |
Any open source lib would be an improvement as long as the new situation is not stuck with ALSA only for linux. So preferably pipewire support with a fallback to pulseaudio/jack and as last resort alsa. |
So you volunteer? ;) |
Nope, found out I'm allergic to C/C++ |
Is your feature request related to a problem? Please describe.
The behavior of PlayMusic() is ideal for adding features like an in-game jukebox. It is mutually exclusive in that playing another song automatically ends the previous and, it has a handy callback in the table script to process the event when a song ends. Unfortunately, it only works for external music files.
Describe the solution you'd like
I am suggesting adding the ability of using PlayMusic() for songs stored in the Sound Library. This gives more flexibility. For example, if I want to include some default songs without having the user download and install a supplemental music file to store in VPinball/music. Not supplying a path defaults to using the root of vpinball/music, so simply omitting the path is not an option. It would likely require a flag indicating internal or external storage in the command
Describe alternatives you've considered
I've tried PlaySound, but it does not automatically stop previous sounds, nor has the option to. It also does not have a way to determine when a song has finished playing, which is a necessary feature for a jukebox type application
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: