Computer Science Canada

Playing two sounds at once

Author:  VB_User [ Mon Apr 14, 2003 8:21 pm ]
Post subject:  Playing two sounds at once

Hey i am adding sound to my mortal kombat clone and i am having some trouble. I want it so that the background music is playing but there are also sound effects. I can only get on or the other to work. If anyone can tell me how to play two sounds at once that would be great.

Thanks alot

Author:  Blade [ Mon Apr 14, 2003 8:49 pm ]
Post subject: 

with a process... have the sound playing in the background then you can play other sounds as well
code:
process bgmusic
loop
Music.PlayFile("themusic.mp3")
end loop
end bgmusic
fork bgmusic

Author:  jamez [ Mon Apr 14, 2003 8:50 pm ]
Post subject:  asdf

i just fooled around with music.playfile and i dont think its possilbe :/

Author:  jamez [ Mon Apr 14, 2003 8:50 pm ]
Post subject: 

no blade, that doesnt work. when it goes to play the SFX it stops playing the BGM. test code before you post it Smile

Author:  Blade [ Mon Apr 14, 2003 9:36 pm ]
Post subject: 

Quote:
Details The Turing 4.0.2 software can play files in the following audio formats: WAVE (.wav) files, MIDI files (.midi or .mid), and MP3 files (.mp3). In general, MIDI files are the most efficient and thus are the preferred form for longer music pieces like background music. WAVE files can record anything, not just music, so are often used for sound effects.

thats what it says in the help file... also, if you are running windows 98 you cant play more than one file at the same time... so try running a midi and an mp3 at the same time... dont accuse me for giving you false info, just because it isn't what you arent looking for.. jeez man

Author:  Asok [ Mon Apr 14, 2003 9:39 pm ]
Post subject: 

let me just say I have had much better experiences with Turing when using mp3s as opposed to midis. MIDIs seem to cause a lot more lag.

Author:  Blade [ Mon Apr 14, 2003 9:44 pm ]
Post subject: 

lol i dunno, i know with windows 98 you cant play more than 1 wav file at the same time... i think thats what his problem may be (i'm not sure about xp, some times it does, sometimes it doesnt)..

Author:  Asok [ Mon Apr 14, 2003 9:46 pm ]
Post subject: 

I'm not totally sure, but it also might be a sound card issue

Author:  jamez [ Mon Apr 14, 2003 9:48 pm ]
Post subject: 

shoudlnt be for me i can have kazaa playing music, winamp playing music, and DoD sfx playing all at once. i think its just turing doesnt output more than 1 sounds at once.

Author:  Blade [ Mon Apr 14, 2003 9:49 pm ]
Post subject: 

i just did it with a midi!

Author:  Blade [ Mon Apr 14, 2003 9:53 pm ]
Post subject: 

could i see the code you are using for it.. it may help

Author:  VB_User [ Mon Apr 14, 2003 10:20 pm ]
Post subject: 

code:
process liu
loop
Music.PlayFile("C:/Sprite/mk2deadpool.mid")
end loop
end liu



process BG
loop
Music.PlayFile("C:/Sprites/liu.wav")
end loop
end BG




fork liu
fork BG



thast my code. It will only play the liu.wav file and not the midi

Author:  Blade [ Mon Apr 14, 2003 10:22 pm ]
Post subject: 

i just tested that code with my midi, and wav, and it works fine...

Author:  Asok [ Mon Apr 14, 2003 10:23 pm ]
Post subject: 

found your error

look at your file path

one is in "Sprite" directory the other is in "Sprites" there is a typo with one of them so double check Smile

Author:  VB_User [ Tue Apr 15, 2003 4:12 pm ]
Post subject: 

Ok now i have another problem. I made it so when you hit the left arrow key it plays the sound but it will only play the sound once. if i hit the key again it doesnt play.

Author:  Asok [ Tue Apr 15, 2003 4:18 pm ]
Post subject: 

again, showing your code would help. Please just post the code whenever you have a problem with the actual code, it saves a lot of frustration.

Author:  Blade [ Tue Apr 15, 2003 4:43 pm ]
Post subject: 

i'm assuming that your problem is not being able to play a file more than once... so i used this code to test it...
code:
var anykey:string(1)
loop
getch(anykey)
if(anykey = "a")then
Music.PlayFile("c:/share/MegaMan2.wav")
end if
end loop

and it worked fine for me, the only thing with this is that you'll have to wait until the file is done being played for anything else to execute... like if you have
code:
var anykey:string(1)
loop
getch(anykey)
if(anykey = "a")then
Music.PlayFile("c:/share/MegaMan2.wav")
put "it's now done playing"
end if
end loop

you will not see the its now done playing until, it has actually stopped playing the file

if you want it to be able to keep executing the program while its playing files, then you'll have to use a process

Author:  VB_User [ Tue Apr 15, 2003 5:51 pm ]
Post subject: 

Ya but i want it so that two sounds are playing and it plays more then once. Try doing that. It doesnt work for me.


: