0
0

Hey there,

I just upgraded from a very old version 4.40.07 to the current 4.44.32. I found that ASIO and CoreAudio don’t support multichannels anymore. I can use the very first channel but none of the higher channels.
To make sure I this is not a code bug on my side I used a modified multispeaker example. The example didn’t work neighter on Windows nor on Mac

regards
Martin

[code:2s8ploay]
/*===============================================================================================
Multi Speaker Output Example
Copyright (c), Firelight Technologies Pty, Ltd 2004-2014.

This example shows how to play sounds in multiple speakers, and also how to even assign
sound subchannels, such as those in a stereo sound to different individual speakers.
===============================================================================================*/

include <windows.h>

include <stdio.h>

include <conio.h>

include "../../api/inc/fmod.hpp"

include "../../api/inc/fmod_errors.h"

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

int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound1, *sound2;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
FMOD_SPEAKERMODE speakermode;
int key;
unsigned int version;

/*
    Create a System object and initialize.
*/
result = FMOD::System_Create(&amp;system);
ERRCHECK(result);

result = system-&gt;getVersion(&amp;version);
ERRCHECK(result);

if (version &lt; FMOD_VERSION)
{
    printf(&quot;Error!  You are using an old version of FMOD %08x.  This program requires %08x\n&quot;, version, FMOD_VERSION);
    return 0;
}

/* 
   Choose the speaker mode selected by the Windows control panel.
*/
result = system-&gt;getDriverCaps(0, 0, 0, &amp;speakermode);
ERRCHECK(result);

system-&gt;setOutput(FMOD_OUTPUTTYPE_ASIO);

speakermode = FMOD_SPEAKERMODE_RAW;
result = system-&gt;setSpeakerMode(speakermode);
ERRCHECK(result);


system-&gt;setDriver(0);
int samplerate = 0;
FMOD_SOUND_FORMAT format;
int output = 0, input = 0;
FMOD_DSP_RESAMPLER resampler;
int bits =0;
ERRCHECK(system-&gt;getSoftwareFormat(&amp;samplerate, &amp;format, &amp;output, &amp;input, &amp;resampler, &amp;bits));

ERRCHECK(system-&gt;setSoftwareFormat(samplerate, format, output+4, input, resampler));

result = system-&gt;init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);

result = system-&gt;createSound(&quot;../media/drumloop.wav&quot;, FMOD_SOFTWARE | FMOD_2D, 0, &amp;sound1);
ERRCHECK(result);
result = sound1-&gt;setMode(FMOD_LOOP_OFF);
ERRCHECK(result);

result = system-&gt;createSound(&quot;../media/stereo.ogg&quot;, FMOD_SOFTWARE | FMOD_2D,  0, &amp;sound2);
ERRCHECK(result);

printf(&quot;==============================================================================\n&quot;);
printf(&quot;Multi Speaker Output Example.  Copyright (c) Firelight Technologies 2004-2014.\n&quot;);
printf(&quot;==============================================================================\n&quot;);
printf(&quot;\n&quot;);
speakermode = FMOD_SPEAKERMODE_MAX;
switch (speakermode)
{
    case FMOD_SPEAKERMODE_MONO    :
    {
        printf(&quot;Using control panel speaker mode : MONO.\n&quot;);
        printf(&quot;\n&quot;);
        printf(&quot;Note! This output mode is very limited in its capability.\n&quot;);
        printf(&quot;Most functionality of this demo is only realized with at least FMOD_SPEAKERMODE_QUAD\n&quot;);
        printf(&quot;and above.\n&quot;);
        break;
    }
    case FMOD_SPEAKERMODE_STEREO  :
    {
        printf(&quot;Using control panel speaker mode : STEREO.\n&quot;);
        printf(&quot;\n&quot;);
        printf(&quot;Note! This output mode is very limited in its capability.\n&quot;);
        printf(&quot;Most functionality of this demo is only realized with FMOD_SPEAKERMODE_QUAD\n&quot;);
        printf(&quot;and above.\n&quot;);
        break;
    }
    case FMOD_SPEAKERMODE_QUAD :
    {
        printf(&quot;Using control panel speaker mode : QUAD.\n&quot;);
        printf(&quot;Side left, side right, center and subwoofer mix will be disabled.\n&quot;);
        break;
    }
    case FMOD_SPEAKERMODE_SURROUND :
    {
        printf(&quot;Using control panel speaker mode : SURROUND.\n&quot;);
        printf(&quot;Side left, side right and subwoofer mix will be disabled.\n&quot;);
        break;
    }
    case FMOD_SPEAKERMODE_5POINT1 :
    {
        printf(&quot;Using control panel speaker mode : 5.1 surround.\n&quot;);
        printf(&quot;Side left and right mix will be disabled..\n&quot;);
        break;
    }
    case FMOD_SPEAKERMODE_7POINT1 :
    {
        printf(&quot;Using control panel speaker mode : 7.1 surround.\n&quot;);
        printf(&quot;Full capability.\n&quot;);
        break;
    }
};
printf(&quot;\n&quot;);

printf(&quot;Press '1' to play a mono sound on the FRONT LEFT speaker.\n&quot;);
printf(&quot;Press '2' to play a mono sound on the FRONT RIGHT speaker.\n&quot;);

if (speakermode &gt;= FMOD_SPEAKERMODE_SURROUND)
{
    printf(&quot;Press '3' to play a mono sound on the CENTER speaker.\n&quot;);
}
else
{
    printf(&quot;- CENTER Disabled\n&quot;);
}

if (speakermode &gt;= FMOD_SPEAKERMODE_QUAD)
{
    printf(&quot;Press '4' to play a mono sound on the REAR LEFT speaker.\n&quot;);
    printf(&quot;Press '5' to play a mono sound on the REAR RIGHT speaker.\n&quot;);
}
else
{
    printf(&quot;- REAR LEFT Disabled\n&quot;);
    printf(&quot;- REAR RIGHT Disabled\n&quot;);
}
if (speakermode &gt;= FMOD_SPEAKERMODE_7POINT1)
{
    printf(&quot;Press '6' to play a mono sound on the SIDE LEFT speaker.\n&quot;);
    printf(&quot;Press '7' to play a mono sound on the SIDE RIGHT speaker.\n&quot;);
}
else
{
    printf(&quot;- SIDE LEFT Disabled\n&quot;);
    printf(&quot;- SIDE RIGHT Disabled\n&quot;);
}

printf(&quot;\n&quot;);
printf(&quot;Press '8' to play a stereo sound on the front speakers.\n&quot;);
printf(&quot;Press '9' to play a stereo sound on the front speakers but channel swapped.\n&quot;);

if (speakermode &gt;= FMOD_SPEAKERMODE_SURROUND)
{
    printf(&quot;Press '0' to play the right part of a stereo sound on the CENTER speaker.\n&quot;);
}

printf(&quot;Press 'Esc' to quit\n&quot;);
printf(&quot;\n&quot;);

/*
    Main loop.
*/
do
{
    if (_kbhit())
    {
        key = _getch();

if 0

        switch (key)
        {
            case '1' :
            {
                result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;channel);
                ERRCHECK(result);

                //result = channel-&gt;setSpeakerMix(1.0f, 0, 0, 0, 0, 0, 0, 0);
                float levels[2];
                levels[0] = 1.0f;
                levels[1] = 1.0f;
                result = channel-&gt;setSpeakerLevels((FMOD_SPEAKER)0, levels, 2);
                ERRCHECK(result);

                result = channel-&gt;setPaused(false);
                ERRCHECK(result);
                break;
            }
            case '2' :
            {
                result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;channel);
                ERRCHECK(result);

                result = channel-&gt;setSpeakerMix(0, 1.0f, 0, 0, 0, 0, 0, 0);
                ERRCHECK(result);

                result = channel-&gt;setPaused(false);
                ERRCHECK(result);
                break;
            }
            case '3' :
            {
                if (speakermode &gt;= FMOD_SPEAKERMODE_SURROUND)   /* All formats that have a center speaker. */
                {
                    result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;channel);
                    ERRCHECK(result);

                    result = channel-&gt;setSpeakerMix(0, 0, 1.0f, 0, 0, 0, 0, 0);
                    ERRCHECK(result);

                    result = channel-&gt;setPaused(false);
                    ERRCHECK(result);
                }
                break;
            }
            case '4' :
            {
                if (speakermode &gt;= FMOD_SPEAKERMODE_QUAD)
                {
                    result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;channel);
                    ERRCHECK(result);

                    result = channel-&gt;setSpeakerMix(0, 0, 0, 0, 1.0f, 0, 0, 0);
                    ERRCHECK(result);

                    result = channel-&gt;setPaused(false);
                    ERRCHECK(result);
                }
                break;
            }
            case '5' :
            {
                if (speakermode &gt;= FMOD_SPEAKERMODE_QUAD)
                {
                    result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;channel);
                    ERRCHECK(result);

                    result = channel-&gt;setSpeakerMix(0, 0, 0, 0, 0, 1.0f, 0, 0);
                    ERRCHECK(result);

                    result = channel-&gt;setPaused(false);
                    ERRCHECK(result);
                }
                break;
            }
            case '6' :
            {
                if (speakermode &gt;= FMOD_SPEAKERMODE_7POINT1)
                {
                    result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;channel);
                    ERRCHECK(result);

                    result = channel-&gt;setSpeakerMix(0, 0, 0, 0, 0, 0, 1.0f, 0);
                    ERRCHECK(result);

                    result = channel-&gt;setPaused(false);
                    ERRCHECK(result);
                }
                break;
            }
            case '7' :
            {
                if (speakermode &gt;= FMOD_SPEAKERMODE_7POINT1)
                {
                    result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;channel);
                    ERRCHECK(result);

                    result = channel-&gt;setSpeakerMix(0, 0, 0, 0, 0, 0, 0, 1.0f);
                    ERRCHECK(result);

                    result = channel-&gt;setPaused(false);
                    ERRCHECK(result);
                }
                break;
            }
            case '8' :
            {
                float levels[2] = { 0, 1.0f };

                result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound2, true, &amp;channel);
                ERRCHECK(result);

                /*
                    By default a stereo sound would play in all right and all left speakers, so this forces it to just the front.
                */
                result = channel-&gt;setSpeakerMix(1.0f, 1.0f, 0, 0, 0, 0, 0, 0);
                ERRCHECK(result);

                result = channel-&gt;setPaused(false);
                ERRCHECK(result);

                break;
            }
            case '9' :
            {
                result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound2, true, &amp;channel);
                ERRCHECK(result);

                /*
                    Clear out all speakers first.
                */
                result = channel-&gt;setSpeakerMix(0, 0, 0, 0, 0, 0, 0, 0);
                ERRCHECK(result);

                /*
                    Put the left channel of the sound in the right speaker.
                */
                {
                    float levels[2] = { 0, 1.0f };    /* This array represents the source stereo sound.  l/r */

                    result = channel-&gt;setSpeakerLevels(FMOD_SPEAKER_FRONT_LEFT, levels, 2);
                    ERRCHECK(result);
                }
                /*
                    Put the right channel of the sound in the left speaker.
                */
                {
                    float levels[2] = { 1.0f, 0 };    /* This array represents the source stereo sound.  l/r */

                    result = channel-&gt;setSpeakerLevels(FMOD_SPEAKER_FRONT_RIGHT, levels, 2);
                    ERRCHECK(result);
                }

                result = channel-&gt;setPaused(false);
                ERRCHECK(result);

                break;
            }
            case '0' :
            {
                if (speakermode &gt;= FMOD_SPEAKERMODE_SURROUND)   /* All formats that have a center speaker. */
                {
                    result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound2, true, &amp;channel);
                    ERRCHECK(result);

                    /*
                        Clear out all speakers first.
                    */
                    result = channel-&gt;setSpeakerMix(0, 0, 0, 0, 0, 0, 0, 0);
                    ERRCHECK(result);

                    /*
                        Put the left channel of the sound in the right speaker.
                    */
                    {
                        float levels[2] = { 0, 1.0f };    /* This array represents the source stereo sound.  l/r */

                        result = channel-&gt;setSpeakerLevels(FMOD_SPEAKER_FRONT_CENTER, levels, 2);
                        ERRCHECK(result);
                    }

                    result = channel-&gt;setPaused(false);
                    ERRCHECK(result);
                }
                break;
            }
        }

endif

        result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound1, true, &amp;channel);
        ERRCHECK(result);

        //result = channel-&gt;setSpeakerMix(1.0f, 0, 0, 0, 0, 0, 0, 0);
        float levels[2];
        levels[0] = 1.0f;
        levels[1] = 1.0f;
        result = channel-&gt;setSpeakerLevels((FMOD_SPEAKER)(key-49), levels, 2);
        ERRCHECK(result);

        result = channel-&gt;setPaused(false);
        ERRCHECK(result);
    }

    system-&gt;update();

    {
        unsigned int ms = 0;
        unsigned int lenms = 0;
        bool         playing = false;
        bool         paused = false;
        int          channelsplaying = 0;

        if (channel)
        {
            FMOD::Sound *currentsound = 0;

            result = channel-&gt;isPlaying(&amp;playing);
            if ((result != FMOD_OK) &amp;&amp; (result != FMOD_ERR_INVALID_HANDLE) &amp;&amp; (result != FMOD_ERR_CHANNEL_STOLEN))
            {
                ERRCHECK(result);
            }

            result = channel-&gt;getPaused(&amp;paused);
            if ((result != FMOD_OK) &amp;&amp; (result != FMOD_ERR_INVALID_HANDLE) &amp;&amp; (result != FMOD_ERR_CHANNEL_STOLEN))
            {
                ERRCHECK(result);
            }

            result = channel-&gt;getPosition(&amp;ms, FMOD_TIMEUNIT_MS);
            if ((result != FMOD_OK) &amp;&amp; (result != FMOD_ERR_INVALID_HANDLE) &amp;&amp; (result != FMOD_ERR_CHANNEL_STOLEN))
            {
                ERRCHECK(result);
            }

            channel-&gt;getCurrentSound(&amp;currentsound);
            if (currentsound)
            {
                result = currentsound-&gt;getLength(&amp;lenms, FMOD_TIMEUNIT_MS);
                if ((result != FMOD_OK) &amp;&amp; (result != FMOD_ERR_INVALID_HANDLE) &amp;&amp; (result != FMOD_ERR_CHANNEL_STOLEN))
                {
                    ERRCHECK(result);
                }
            }
        }

        system-&gt;getChannelsPlaying(&amp;channelsplaying);

        printf(&quot;Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r&quot;, ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? &quot;Paused &quot; : playing ? &quot;Playing&quot; : &quot;Stopped&quot;, channelsplaying);
    }

    Sleep(10);

} while (key != 27);

printf(&quot;\n&quot;);

/*
    Shut down
*/
result = sound1-&gt;release();
ERRCHECK(result);
result = sound2-&gt;release();
ERRCHECK(result);
result = system-&gt;close();
ERRCHECK(result);
result = system-&gt;release();
ERRCHECK(result);

return 0;

}

[/code:2s8ploay]

  • You must to post comments
0
0

any news about that? I currently switched back to 4.40. Maybe you can just tell me when you added the bug 😉 So I can just take the last working version? Thx Martin

  • You must to post comments
0
0

I just installed asio4all and ran your code, and the sounds came out in 5.1 as expected. Can you be more specific in what is not working?

  • You must to post comments
0
0

Beeing an audio driver developer in my real live I always use real ASIO devices. I haven’t tested ASIO4All.
If this works for you, it will be something concering volume.
I am controlling every channel separately. Actually my testing environment is always a stereo channel with panning.
That means when I play on 1/2, all others are muted by setSpeaker(0). When I am on 3/4 this is leveled up to 1.0,1.0 and 1/2 is "muted".
So I am able to test all channels sparetely. My assumption is now that muting the very first stereo channel leads to a mute of 3/4 as well?
Hhm, I am just thinking about what I have tested. Actually, I tried setSpeakerMix(1,1,1,1,1,1,1,1,1) as well and this didn’t work either in this example above.
So muting might not be an issue. I am going to try with another sound device. …<a while later>

I got an ESI UDJ6 hooked up to my computer running their latest drivers and using ASIO in the example above. I am always getting a signal from 1/2 all other
channels are "muted".

  • lemart
    are there any news about that?
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.