0
0

Hello

At the moment, I’m having trouble playing more than one sound at a time- for example, when playing an MP3 and a WAV file, the WAV plays and stops the MP3 straight away. The MP3 isn’t being streamed.

Do these two files have to be grouped in order for both to play at the same time ?

Nicholas

  • You must to post comments
0
0

How are you playing them? Are you using a channel per sound, or re-using the same channel? Are you using events etc.

  • You must to post comments
0
0

Not using events.

I’m using FMOD_CHANNEL_FREE with PlaySound, so it should really be any free channel per sound (of which I’ve assigned 32 in Init())

And they are 2D stereo sounds.

It appears that a channel number other than that given above solves the problem…

  • You must to post comments
0
0

That should work, are you calling update? Is everything returning FMOD_OK?

  • You must to post comments
0
0

Yes, everything returns from FMOD okay, and I’m using Update()

  • You must to post comments
0
0

I knocked together a quick test (very quick), and this works fine, anything different to your layout that you can spot:

[code:10shfzje]#include "fmod_event.h"

include <stdio.h>

include <stdlib.h>

include <conio.h>

include <windows.h>

include <assert.h>

struct EventBuffer
{
FMOD::EventGroup *group;
int index;
char *name;
};

FMOD::System *FMODsystem;
FMOD_RESULT result;
FMOD::Sound *sound[10];
FMOD::Channel *channel[10];
int key;
int loaded = 0;

void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
printf("FMOD error! (%d)\n", result);
exit(-1);
}
}

void LoadData()
{
printf("Loading...\n");

result = FMODsystem-&gt;createSound(&quot;test.wav&quot;, FMOD_2D | FMOD_SOFTWARE, NULL, &amp;sound[0]);
ERRCHECK(result);
loaded++;

result = FMODsystem-&gt;createSound(&quot;test.mp3&quot;, FMOD_2D | FMOD_SOFTWARE, NULL, &amp;sound[1]);
ERRCHECK(result);
loaded++;

printf(&quot;======================================================================\n&quot;);   
printf(&quot;Press any number key up to %c to play\n&quot;, loaded + '0');
printf(&quot;Press 0 to stop all\n&quot;);
printf(&quot;Press ESC to quit\n&quot;);
printf(&quot;======================================================================\n&quot;);

}

int main(int argc, char *argv[])
{
float param = 0;
for (int i =0; i < 10; i++)
{
sound[i] = NULL;
channel[i] = NULL;
}

result = FMOD::System_Create(&amp;FMODsystem);
ERRCHECK(result);
result = FMODsystem-&gt;init(32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);

unsigned int version;
result = FMODsystem-&gt;getVersion(&amp;version);
ERRCHECK(result);

if (version != FMOD_VERSION)
{
    printf(&quot;Error: version mismatch %d v %d\n&quot;, version, FMOD_VERSION);
    exit(-1);
}

LoadData();

key = 0;

do
{
    int index = 0;
    if (_kbhit())
    {
        key = _getch();

        if (key)
        {
            index = 99999;

            if ((key &gt;= '0') &amp;&amp; (key &lt;= '9'))
            {
                index = key - '0';
            }

            if (key &amp;&amp; (index &lt;= loaded))
            {
                if (index == 0)
                {
                    for(int i = 0; i &lt; 10; i++)
                    {
                        if (channel[i])
                        {
                            result = channel[i]-&gt;stop();
                            channel[i] = NULL;
                            ERRCHECK(result);
                        }
                    }
                }
                else
                {
                    index--;
                    if (channel[index])
                    {
                        channel[index]-&gt;stop();
                        channel[index] = NULL;
                    }
                    result = FMODsystem-&gt;playSound(FMOD_CHANNEL_FREE, sound[index], false, &amp;channel[index]);                     
                }
            }
        }
    }


    result = FMODsystem-&gt;update();
    ERRCHECK(result);
    Sleep(15);

}
while (key != 27);

result = FMODsystem-&gt;release();
ERRCHECK(result);

return 0;

}[/code:10shfzje]

  • You must to post comments
0
0

Aside from the fact that I’m using the C interface, thats exactly how my stuff is loaded and played…

Its now been solved – the values I had for x_FREE, in my code were wrong – FREE & REUSE were setup as 0 and 1, instead of -1 and -2, whilst in the help files (which I was looking at), they are defined as 0 and 1

Thanks for your help, by the way.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.