[Help] Music problem

BlitzMax Forums/BlitzMax Beginners Area/[Help] Music problem

Big Tree Studios(Posted 2009) [#1]
Hello everybody! I have a problem in one of my program. There are sounds in .wav that are triggered when certain keys are pressed. They all work fine. When I tried to add music to the program, the sound sucks really bad. I tried putting it in .wav and .ogg, but both didn't work fine. I cutted the sound file to 20 seconds, but it doesn't change a thing. I would like to know why it does this and how to fix it.


Brucey(Posted 2009) [#2]
When you say it sucks really bad, what do you mean?
Did the sound not work at all? Was it choppy?

More specific details please :-)


Big Tree Studios(Posted 2009) [#3]
Ya sorry about this, the sound works but what I hear is like the sound would be 1000000% overdrived so it's really unpleasant.


Arowx(Posted 2009) [#4]
Could you post a very simple example of the code that recreates this problem, e.g. a main loop that responds to keys and plays sounds and the muisc playing in the background?

I think there are problems with DirectSound, the default sound driver in BlitzMax on some systems.

Have you tried setting up a different audio driver, most people recommend OpenAL e.g:

SetAudioDriver("OpenAL")



Big Tree Studios(Posted 2009) [#5]
Sorry, I can't really post the code because it's separated in 5 different .bmx files. I would like to know how to use AudioAL in blitzmax, do I need to install it? How? Thanks!


plash(Posted 2009) [#6]
Yes you/your users need to install OpenAL to use the OpenAL driver.


Big Tree Studios(Posted 2009) [#7]
Ok, I'll try it.


Big Tree Studios(Posted 2009) [#8]
It did the same problem, the sounds really creepy. Here's the code I use for the song. Note that I commented out the PlaySound because I don't want to hear it.

		If Not IntroSound
			IntroSound:TSound = LoadSound("sounds/intro.wav")
		EndIf
				
		Select Mode
	
			Case Intro
				
				'PlaySound( IntroSound )
				
				Level = 0
				
				DrawImage( Background,400,300 )
								
				DrawText "Welcome to Asteroids Hugo Beta Version 2",50,100
				
				DrawText "Highest Score this run: "+HighestScore+" points.",50,130
				
				DrawText "Steer with LEFT, RIGHT      ",50,170
				DrawText "Thrust with UP and DOWN     ",50,190
				DrawText "Fire with SPACE             ",50,210
				
				DrawText " ---------  P R E S S   S P A C E   T O  S T A R T  ---------- ",50,260
			
				If KeyHit(Key_Space) StartGame()
				
			Case Playing



xlsior(Posted 2009) [#9]
- What operating system?
- Did you specify a specific sound drivers?


Matty(Posted 2009) [#10]
While I don't use Blitzmax (I use blitzplus and blitz3d) it looks, if that section is looped through repeatedly, that you are playing the sound over and over on top of itself which will sound terrible. You may like to check if the channel is playing first (does blitzmax use channels?).


plash(Posted 2009) [#11]
#1: You Imported the OpenAL module, yes?
#2: Did you set the OpenAL driver as the current sound driver?
(.. Both assumed, since you stated "the sounds really creepy")

EDIT: @Matty: Yes, it does.

Ah! You might want to use a channel with your sound.


Big Tree Studios(Posted 2009) [#12]
@Plash Yes I used OpenAl, but it did the same thing.
Also, I think Matty's right, could you tell me how to use channels? Thanks a lot, I'll be back later like at 4:30 pm so I might not answer anything during now and this time.


Pharmhaus(Posted 2009) [#13]
Here is an example how to use channels:



Big Tree Studios(Posted 2009) [#14]
No, Soory to answer this late, it didn't work either with the channel. I think I'm going to record it and also I'll try with another song. I won't do this now since it's 1 am, but I'll try to do it soon. Also, thanks for the help!


plash(Posted 2009) [#15]
What do you mean by 'it didn't work either'? Did you import and set the driver then load your music correctly with the example?
(You should check if the sound is already playing before resuming the channel.)


Brucey(Posted 2009) [#16]
What happens if you don't try to start playing the sound/channel each time around the loop?


Big Tree Studios(Posted 2009) [#17]
Oh my god, you were right, it's because the sound was looping over it over and over. I changed its place and now it's working. I placed it out of the loop, thanks! Now I would like to know how to loop it, like when it's over it restarts automatically. Also, how to stop the music, like when I want another want to start, how to stop the other.


Big Tree Studios(Posted 2009) [#18]
Ok, I figured out how to stop the music with channels. I just need to know how to loop it please. Thanks in advance!


plash(Posted 2009) [#19]
When you load the sound set the flag to SOUND_LOOP (the channel example given does that).

EDIT: Or, if you want more control over the looping, you could manually check if the channel stopped playing and restart it.


Big Tree Studios(Posted 2009) [#20]
Ok, Nice, now you solved all my sound problems (for the moment). Thanks to all of you who helped me fix this. See you later on the forums!