First of all, it only pays to post the RELEVANT code.
I assume the relevant code in this case is:
Secondly, make your question clear. I don't know whether to answer your question literally as you asked it, OR to try to interpret what you may have meant...
Your question:
Taken literally:
Then just remove the other Load command, duh...
so erase these lines:
Interpreted as something else
Assuming what you actually meant to ask was how to PLAY only one at a time, and since I ASSUME you want the "car start" sound to play first, then the idle sound second, you need to fix your mistake of attempting to PAUSE the idle sound channel before it's even created.
Notice these lines:
Then you create a SOUND HANDLE by loading a sound and storing that HANDLE in the box2 variable.
Then you tell the sound to be emitted from the box.
To correct this, all you have to do is store the CHANNEL that is returned from the EmitSound command into some variable and (only then) pausing it.
So your three lines of code should look like this:
Then later, when you want it to play, you should change your PlaySound code (which, by the way defeats the purpose of loading it earlier...) to read like this:
By the way, why are you telling it to play the box1 sound after you told it to emit the box1 sound? Pointless. Erase the PlaySound line:
...
You know, it would make more sense to name your sound handles and channels more descriptive names than box1 and box2.
...
By the way, if you want your sounds to diminish with distance (and other 3D sound effects) then you need to load your sounds with Load3DSound, not LoadSound.
I assume the relevant code in this case is:
;Play and Loop some sound :) box1=LoadSound("Sounds\car start.wav") Listener=CreateListener(Camera,box,1,1) EmitSound box1,box PlaySound box1 PauseChannel box2 box2=LoadSound("Sounds\gpidle.wav") EmitSound box2,boxand
If KeyDown(17)=False Then PlaySound("Sounds\gpidle.wav")
Secondly, make your question clear. I don't know whether to answer your question literally as you asked it, OR to try to interpret what you may have meant...
Your question:
I want to load one sound file at a time but both of them load up at the same time
Taken literally:
Then just remove the other Load command, duh...
so erase these lines:
PauseChannel box2 box2=LoadSound("Sounds\gpidle.wav") EmitSound box2,box
Interpreted as something else
Assuming what you actually meant to ask was how to PLAY only one at a time, and since I ASSUME you want the "car start" sound to play first, then the idle sound second, you need to fix your mistake of attempting to PAUSE the idle sound channel before it's even created.
Notice these lines:
PauseChannel box2 box2=LoadSound("Sounds\gpidle.wav") EmitSound box2,boxRemember that code is always executed from top to bottom, so in the code above, the first thing you try to do is pause a channel that doesn't exist. In fact, you reference a variable that will later contain a SOUND HANDLE, not a SOUND CHANNEL.
Then you create a SOUND HANDLE by loading a sound and storing that HANDLE in the box2 variable.
Then you tell the sound to be emitted from the box.
To correct this, all you have to do is store the CHANNEL that is returned from the EmitSound command into some variable and (only then) pausing it.
So your three lines of code should look like this:
box2=LoadSound("Sounds\gpidle.wav") IdleChannel = EmitSound box2,box PauseChannel IdleChannel
Then later, when you want it to play, you should change your PlaySound code (which, by the way defeats the purpose of loading it earlier...) to read like this:
If (Not KeyDown(17)) And (Not ChannelPlaying(StartChannel)) Then ResumeChannel(IdleChannel)Notice that I referenced a channel by the name of StartChannel? That's because you will have to remember that channel when you created it on this line:
EmitSound box1,boxSo change it to read:
StartChannel = EmitSound box1,box
By the way, why are you telling it to play the box1 sound after you told it to emit the box1 sound? Pointless. Erase the PlaySound line:
PlaySound box1
...
You know, it would make more sense to name your sound handles and channels more descriptive names than box1 and box2.
...
By the way, if you want your sounds to diminish with distance (and other 3D sound effects) then you need to load your sounds with Load3DSound, not LoadSound.