0
0

Hey this is my first encounter with FMOD and game coding. I am having some problem with implementing the surround sound for my project. I did a small test code but it doesnt work. Can anyone please tell me whats wrong?

[color=orange:2tq4i40w]#include <fmod.h>

include <fmod.hpp>

include <iostream>

using namespace std;

void main(){
FMOD::System *system;
FMOD::System_Create(&system); // Create the main system object
system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
system->init(100, FMOD_INIT_NORMAL, 0); // Initialize FMOD.

FMOD::Sound *sound1;
FMOD::Sound *sound2;
system-&gt;createStream(&quot;Haven.wav&quot;, FMOD_3D|FMOD_HARDWARE, 0, &amp;sound1);      // FMOD_DEFAULT
system-&gt;createStream(&quot;Haven.wav&quot;, FMOD_3D|FMOD_HARDWARE, 0, &amp;sound2);

FMOD::Channel *chan1;
FMOD::Channel *chan2;
float x = 0;
float y = 0;
float z = 0;
FMOD_VECTOR *pos;

cout << "before entering loop" << endl;

for (x=0;x&lt;10;x++){

cout << "Insider first loop" << endl;
pos = new FMOD_VECTOR;

    pos-&gt;x = x;
    pos-&gt;y = y;
    pos-&gt;z = z;

    chan1-&gt;set3DAttributes(pos, 0);
    chan2-&gt;set3DAttributes(pos, 0);

    system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;chan1);
    system-&gt;playSound(FMOD_CHANNEL_FREE, sound2, true, &amp;chan2);

    system-&gt;update();

for (y=0;y&lt;100;y++){


        pos-&gt;x = x;
        pos-&gt;y =j y;


        chan1-&gt;set3DAttributes(pos, 0);
        chan2-&gt;set3DAttributes(pos, 0);
        cout &lt;&lt; &quot;Insider second loop&quot; &lt;&lt; endl;
        system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;chan1);
        system-&gt;playSound(FMOD_CHANNEL_FREE, sound2, true, &amp;chan2);
        system-&gt;update();
    }//end for Y
}//end for X

}//end main[/color:2tq4i40w]

Thanks!

  • You must to post comments
0
0

Try changing the FMOD_HARDWARE to FMOD_SOFTWARE, we tend to force all our loaded samples to software, as the hardware never seems reliable.

You shouldn’t have to play the sound again inside the 2nd loop, as the chan variables will contain a pointer to the already playing sounds.

  • You must to post comments
0
0

Hi a1psx,

I changed FMOD_HARDWARE to FMOD_SOFTWARE and stick to just one loop instead of two but still I cant play the WAV file. I tried to be less ambitious and start with a more simple program. STILL I cant hear anything from my speakers.

[color=orange:3dyyd20c]#include <fmod.h>

include <fmod.hpp>

include <iostream>

using namespace std;

void main(){
FMOD::System *system;
FMOD::System_Create(&system); // Create the main system object
system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
system->init(100, FMOD_INIT_NORMAL, 0); // Initialize FMOD.

FMOD::Sound *sound1 = 0;
system-&gt;createStream(&quot;Haven.wav&quot;, FMOD_SOFTWARE, 0, &amp;sound1);      // FMOD_DEFAULT


FMOD::Channel *chan1 = 0;

    system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;chan1);

    system-&gt;update();

}//end main[/color:3dyyd20c]
  • You must to post comments
0
0

You need to wait for the sound to finish playing before you exit your program – you’re exiting before you get a chance to hear it. Also, in your call to System::playSound you’re specifying "paused" as true – either change this to false or call Channel::setPaused(false) after the System::playSound.

Look at the FMOD example programs for more info.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.