Problem with emit sound?

Blitz3D Forums/Blitz3D Beginners Area/Problem with emit sound?

Guy Fawkes(Posted 2011) [#1]
Hi all, for some reason when I try to play some music in the background with a listener i created for OTHER sounds, the emitsound OR listener is messing with the music.

What I need is a way to play background music WITH the listener NOT effecting the background music.

Thank you! :)


Rob the Great(Posted 2011) [#2]
Hello again. It's still on my todo list to take a look at the other post, but I've been busier than ever and haven't had the time to do it.

A quick question about this post, though. How are you loading the music? Whenever I load music, I always use LoadSound and PlaySound, never the listener commands. If you use the listener commands for music, the music will be effected by the listener.

Now, you probably already knew that, and you might still be experiencing a problem with Blitz treating your 2D sound as a 3D sound. I've had this happen to me once before, and I was able to solve the problem using the steps below. I honestly have no idea why it solved it, let alone what caused the problem, but in my situation, it worked. Hopefully, the same applies to you. This is assuming you've tried everything you can think of with your code and nothing is working.

Take the sound file, e.g., "bgmusic.wav", and duplicate it with another name in windows, e.g. "bgmusic copy.wav". Now, delete the old sound file or move it to another location if you don't want to delete it right away. Take the copy, "bgmusic copy.wav" and rename it back to the original name, "bgmusic.wav".

In Blitz, find the section of code that loads the music, such as
Global music = LoadSound("bgmusic.wav")

Next, rename the variable used to store the music to something different, like
Global music2 = LoadSound("bgmusic.wav")

Now that you've done this, go ahead and run your program. Unless you don't ever use your music variable again in your program, it will fail, but that's alright. If it doesn't fail, that's fine too. Once you've run the program, go ahead and close it.

All that's left is to rename your music variable back to whatever it was.
;music2 now should be renamed back to music
Global music = LoadSound("bgmusic.wav")

At this point, you and probably every other Blitz user who reads this is laughing their asses off and thinking that I'm smoking something really nice. I admit, the steps I've given make very little sense at all, but it worked for me. I was having problems with one specific sound effect that was loaded with LoadSound. For reasons unknown, this sound was affected by the listener, even though none of my code used 3D sound commands on that sound. I tried everything, and only when I did the steps above did it ever fix the problem.

This worked for me, but because this is such an unusual solution, it might not work for you. If ANYONE knows how this solution makes any sense, feel free to share.


Guy Fawkes(Posted 2011) [#3]
Thanks Rob, will try! =D