0
0

Hi Everyone,
I’m developing a game for visually impaired persons.
I want three doors to appear: One to the left, one in the center and one at the right.
My initial experiment was to try and load a mono wave file and play it on 3 channels, where each channel had a pan of 0, 128 and 256 respectively to represent the doors.
Yet only one sound (the middle one) was heard.
I’m using FMOD 3.71, since I cannot find docs for FMOD 3.72Pre – would be nice to provide a link (or post in the forum where to get a .zip file or something).
Anyway the source code:
[code:3djede5t]

include <fmod.h>

int main() {
FSOUND_Init(22050, 10, 0);
FSOUND_SAMPLE* Door = FSOUND_Sample_Load(FSOUND_FREE, "Door.wav", 0, 0, 0);
FSOUND_PlaySound(1, Door);
FSOUND_SetPan(1, 0);
FSOUND_PlaySound(2, Door);
FSOUND_PlaySound(3, Door);
FSOUND_SetPan(3, 256);
while (FSOUND_IsPlaying(3)) continue;
FSOUND_Close();
}

Any help would be greatly appreciated.
To try out some of my games, go to
http://tdlgames.ho8.com
Please note that the games are for visually impaired persons, so there are no graphics.
Check out the demo for Temple of Steel – our newest and greatest product so far. At least, our customers think so. :-)
Yours,
Peter.[/code:3djede5t]

  • You must to post comments
0
0

[quote="brett":2wi4dcnw]you’ve played the same sound 3 times at exactly the same time.
if you spread them across left/right/middle, then obviously it will sound like it is in the middle. It is just played all 3 at once like you told it to.

You should use FSOUND_FREE instead of 1,2,3 for channel numbers by the way, and use the return value from playsound to call setpan/setvolume with.

Also 255 is the max for pan, not 256.

Note that you are setting the pan when the sound is already playing. This means it will be in the middle for a split second, then wherever you tell it to. You should use FSOUND_PlaySoundEx and play the sound paused, set the pan, then unpause it.

One more note is that you are using a busy while loop at the end. This is not very cpu friendly and can lock up windows (for the duration of the sound) on some versions of the operating system. You would be better putting a call to Sleep() in there somewhere i think.

regards,[/quote:2wi4dcnw]

Thank you for the answer.
I changed my code according to your suggestions and it works (almost) as expected.
I tried a few things, but there is still a kind of problem.
The sound in the middle and the sound to the left seems to “have taken” each other’s spaces – neither sound is played where it’s ment to be. They seem to have found that playing in the middle of the two pans is the most perfect spot, not where I intend them to be.
Anyway, here’s the changed code.
As before, any help is greatly appreciated.
[code:2wi4dcnw]

include <windows.h>

include <fmod.h>

int main() {
FSOUND_Init(22050, 10, 0);
FSOUND_SAMPLE* Door = FSOUND_Sample_Load(FSOUND_FREE, "Door.wav", 0, 0, 0);
int Channel1 = FSOUND_PlaySoundEx(FSOUND_FREE, Door, NULL, true);
FSOUND_SetPan(Channel1, 0);
FSOUND_SetPaused(Channel1, false);
//Sleep(3500);
int Channel2 = FSOUND_PlaySoundEx(FSOUND_FREE, Door, NULL, false);

Sleep(3500);
int Channel3 = FSOUND_PlaySoundEx(FSOUND_FREE, Door, NULL, true);
FSOUND_SetPan(Channel3, 255);
FSOUND_SetPaused(Channel3, false);
Sleep(3500);
FSOUND_Close();
}

Yours,
Peter.[/code:2wi4dcnw]

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.