PlayMusic - what the..

Blitz3D Forums/Blitz3D Programming/PlayMusic - what the..

jfk EO-11110(Posted 2009) [#1]
Recently I decided to use PlayMusic for a System that is too complex to preload and PlaySound all sounds. Since the sounds are not loaded as 3D sounds I was really surprised when I realized whenever I PlayMusic a sound, there will be a 3D sound, positioned at the current listeners location, so when I make a step to the side when a sound is played this way, then the sound comes from a 3D location at the players side.

Is this only me, or are there any other people with the same problem?


_PJ_(Posted 2009) [#2]
Weeeeeeeeeeeeeeeeeeeirrrd....

I assume, then that you have 3D sounds i use already. I imagine if having a Listener in efect "Activates 3D sound mode" (probably trigers something Direct-X-ified ?"
It would seem likely, if this is the case, that to assume a position to play the sound from as it's played direct from the disk, the listeners' position at that time is ideal.

I may be completely wrong of course.

Do you have EAX enabled or anything normally?


jfk EO-11110(Posted 2009) [#3]
This is what I thought too. I only wonder is this something special on my machine, or does it happen on all machines?

Could somebody please test it? Just create a 3d scene, a listener, then playmusic a sound while the camera moves.


Warner(Posted 2009) [#4]
I agree with the theory. I can't try it on this machine, but I wonder why would you create a listener that is not the camera?


jfk EO-11110(Posted 2009) [#5]
Did I ? The code seems to be ok. It's really like loading 2d and hearing 3d sound. Maybe that is an undocumented feature of PlayMusic.
ed: Seems like this is known since 2007 (Bug Report). At least on version 1.98. Gotta try it with 1.01.


jfk EO-11110(Posted 2009) [#6]
Ok, this is a known bug and there is also a further problem with playmusic since it doesn't close a handle, and only 500 handles can be open for a win process like our exe. So after playing 500 sounds with PlayMusic no further file etc. handles could be opened - I really tested it, after 500 sounds it simply doesn't load anymore. No MAV, but as good as it.

Especially interactive Soundsystems, eg. speech output in AI or Dialog Systems etc. shouldn't use it. but it's pretty simple to write a replacement using Loadsound. Just write the handles and channels of the sounds to a stack, then frequently check if a channel is still playing, if it doesn't then remove the sound from memory and stack list.

It doesn't really stream the Music, as PlayMusic claimes to do, but at least it's a "fire and forget" substitute System.


_PJ_(Posted 2009) [#7]
If PlayMusic maintains handles and therefore I imagine, some memory usage, then it makes the command pretty much useless in comparison to PlaySound, the only advantage that it did have, to me, was that it wasn't necessary to retain the sound info in memory.

So PlaySound introduces a little bit more management, but it has much better control and functionality anyway.


jfk EO-11110(Posted 2009) [#8]
Exactly. And to write a little Garbage collection that frequently removes sounds that aren't playing anymore took me only a few minutes.


SLotman(Posted 2009) [#9]
Forget PlayMusic... use my MCI libraries, they work like a charm and files are streamed from disc.


WERDNA(Posted 2009) [#10]
3D sounds give you nothing but problems.
I had 3D sounds enabled for Robo Attack3D, and suddenly would get
an error if I tried to use playmusic on my .mod files.
I could play my first .mod file just fine, but after that if I tried to pause
it, stop it, or play another .mod file, then I would get an error and my
game would crash.
And it was caused by using Load3DSound. Getting rid if, would fix all
my problems.
I finally fixed it byt converting all my .mod files to .wav files, and using
load and play sound instead of playmusic.

So I agree with SLotman. Ditch playmusic. Stick with Playsound.

Good luck getting this fixed!

WERDNA