Music and Sound

BlitzPlus Forums/BlitzPlus Beginners Area/Music and Sound

gadgethead(Posted 2005) [#1]
Hi everyone
I can get my program to play either a .wav file using Playsound or I can get it to play a .wma file using PlayMusic but for some reason it wont do both concurrently. I gave both the music and sounds channels so I could adjust the volume because I thought maybe I just couldnt hear because the music was too loud. No luck. As soon as I remark out the playmusic, the sound files play again.. Is this a limitation to Blitz or am I just overlooking something?

In response to Grey Alien, I didnt define them as Global, simply used the format variable=playmusic("name.wma") then use the channel volume command on the variable. And I did use different variables for sound and music. So its an either/or situation. If music plays, sounds do not.

I noticed a different thread in another section by someone else who was having a similiar problem, but the resoluton was never stated, they simply said they got it to work.

Perhaps some one could post barebones code that play music and will play a sound effect with a key stroke? I would just need to alter the sound/music file to something i have.


Grey Alien(Posted 2005) [#2]
I play modules with playmusic and loads of sounds with playsound at the same time. You say you haven't given them channels, are these global and are they different (most important)?


WolRon(Posted 2005) [#3]
Post your code. It may be obvious.


Damien Sturdy(Posted 2005) [#4]
Using two playmusic commands will cancel the first- So, use PlaySound instead :)


gadgethead(Posted 2005) [#5]
Heres what Im trying to make work:

Graphics 800, 600
Global noise=LoadSound("brook.wav")
Global music=PlayMusic("easy.wma")

While Not KeyDown (1)
If KeyDown(2)
If ChannelPlaying (chnnoise) Then ChannelVolume chnnoise,1 Else chnnoise=PlaySound (noise)
End If

Wend


As is, only the music will play, if you remark out the third line than the sound will play.
If ran in debug mode then this does work with both music and sound.
Any ideas?


WolRon(Posted 2005) [#6]
First off:
if you remark out the third line
Which line is the third line? Are your referring to this Global music=PlayMusic("easy.wma") line?

Secondly, What are the forum codes?

Lastly, the use of the KeyDOWN command is possibly the cause of your problem. KeyDown would be true for every loop of your program, which is unnecessary.
Also, I think the volume is 100% by default so there is no need to set it to 100%.

This is how I would write it.
Graphics 800, 600
Global noise=LoadSound("brook.wav")
Global music=PlayMusic("easy.wma")

While Not KeyHit(1)
	If KeyHit(2) 
		If Not(ChannelPlaying(chnnoise))
			chnnoise=PlaySound(noise)
		EndIf
	EndIf
Wend