[Help] Music problem
BlitzMax Forums/BlitzMax Beginners Area/[Help] Music problem
| ||
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. |
| ||
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 :-) |
| ||
Ya sorry about this, the sound works but what I hear is like the sound would be 1000000% overdrived so it's really unpleasant. |
| ||
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") |
| ||
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! |
| ||
Yes you/your users need to install OpenAL to use the OpenAL driver. |
| ||
Ok, I'll try it. |
| ||
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 |
| ||
- What operating system? - Did you specify a specific sound drivers? |
| ||
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?). |
| ||
#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. |
| ||
@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. |
| ||
Here is an example how to use channels: |
| ||
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! |
| ||
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.) |
| ||
What happens if you don't try to start playing the sound/channel each time around the loop? |
| ||
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. |
| ||
Ok, I figured out how to stop the music with channels. I just need to know how to loop it please. Thanks in advance! |
| ||
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. |
| ||
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! |