0
0

Hello,

i am new with fmod. I am using the api for a program in my study.

Now, i want to work with fmod. I tried the sample "channelgroups". It works fine and it is impressive, what u can do with simple code.

Now, i want to extend my program. So i can mute unmute simple groups and channels.

Here is my code

[code:2zaeouc5]switch (key)
{
case ‘a’ :
case ‘A’ :
{
groupA->setMute( mute );

                mute = !mute;
                break;
            }
            case 'b' : 
            case 'B' : 
            {
                groupB->setMute( mute );

                mute = !mute;
                break;
            }
            case 'c' : 
            case 'C' : 
            {
                masterGroup->setMute( mute );

                mute = !mute;
                break;
            }
            case '1' :
            {
                channel[1]->setMute( mute );
                mute != mute;
                break;
            }

        }

[/code:2zaeouc5]

Well, Key a, b, c works fine. But if I press 1 the sound in channel 1 (here it is the jaguar) will mute as i want. But if I press 1 twice, the voice is still muted. Why?

When I want to mute / unmute groups it works perfect, but with channels not?

Can anybody pls explain?

Thank you :)

  • You must to post comments
0
0

Because it’s group is muted. Or that channel is done playing.

  • You must to post comments
0
0

Hi,

i don’t get it at all :/

Well, i have 6 sounds. I split them into 2 groups. (0..2 = GroupA, 3..5 = GroupB).

I can mute/unmute these groups without problems. Or both (mastergroup).

Now, i have every sound in 1 Channel ( = 5 channels).
Both groups are unmuted, so all sounds play.

Why can’t i say mute channel 1 and then unmute it?

  • You must to post comments
0
0

channel[1]… Where do you set it?

Does it hold the channel of a sound that is played once or looped

without the rest of the code, it’s hard to see why the mute-unmute is not working

  • You must to post comments
0
0

Hello,

sorry for lag.

Here is the complete code. Please help :)

[code:1mzbh0gn]

include "stdafx.h"

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 *sound[6];
FMOD::Channel *channel[6];
FMOD::ChannelGroup *groupA, *groupB, *masterGroup;
FMOD_RESULT result;
int key, count;
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;
}

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

result = system-&gt;createSound(&quot;../media/drumloop.wav&quot;, FMOD_LOOP_NORMAL, 0, &amp;sound[0] );
ERRCHECK( result );
result = system-&gt;createSound(&quot;../media/jaguar.wav&quot;, FMOD_LOOP_NORMAL, 0, &amp;sound[1] );
ERRCHECK( result );
result = system-&gt;createSound(&quot;../media/swish.wav&quot;, FMOD_LOOP_NORMAL, 0, &amp;sound[2] );
ERRCHECK( result );
result = system-&gt;createSound(&quot;../media/c.ogg&quot;, FMOD_LOOP_NORMAL, 0, &amp;sound[3] );
ERRCHECK( result );
result = system-&gt;createSound(&quot;../media/d.ogg&quot;, FMOD_LOOP_NORMAL, 0, &amp;sound[4] );
ERRCHECK( result );
result = system-&gt;createSound(&quot;../media/e.ogg&quot;, FMOD_LOOP_NORMAL, 0, &amp;sound[5] );
ERRCHECK( result );

result = system-&gt;createChannelGroup( &quot;Group A&quot;, &amp;groupA );
ERRCHECK( result );

result = system-&gt;createChannelGroup( &quot;Group B&quot;, &amp;groupB );
ERRCHECK( result );

result = system-&gt;getMasterChannelGroup( &amp;masterGroup) ;
ERRCHECK( result );

printf( &quot;=======================================================================\n&quot; );
printf( &quot;                           Channel Test                                \n&quot; );
printf( &quot;=======================================================================\n&quot; );
printf( &quot;\n&quot;);
printf( &quot;Group A : drumloop.wav, jaguar.wav, swish.wav\n&quot; );
printf( &quot;Group B : c.ogg, d.ogg, e.ogg\n&quot; );
printf( &quot;\n&quot; );

result = masterGroup-&gt;addGroup( groupA );
ERRCHECK( result );

result = masterGroup-&gt;addGroup( groupB );
ERRCHECK( result);

/*
    Start the sounds!
*/
for ( count = 0; count &lt; 6; count++ )
{
    result = system-&gt;playSound( FMOD_CHANNEL_FREE, sound[count], false, &amp;channel[count] );
    ERRCHECK( result );
    if ( count &lt; 3 )
    {
        result = channel[count]-&gt;setChannelGroup( groupA );
    }
    else
    {
        result = channel[count]-&gt;setChannelGroup( groupB );
    }
    ERRCHECK( result );
    result = channel[count]-&gt;setPaused( false );
    ERRCHECK( result );
}   

result = groupA-&gt;setVolume(1.5f);
ERRCHECK(result);
result = groupB-&gt;setVolume(0.5f);
ERRCHECK(result);

do
{
    if (kbhit())
    {
        key = getch();

        static bool mute = true;

        switch ( key )
        {
            case 'a' : 
            case 'A' : 
            {
                groupA-&gt;setMute( mute );

                mute = !mute;
                break;
            }
            case 'b' : 
            case 'B' : 
            {
                groupB-&gt;setMute( mute );

                mute = !mute;
                break;
            }
            case 'c' : 
            case 'C' : 
            {
                masterGroup-&gt;setMute( mute );

                mute = !mute;
                break;
            }
            case '1' :
            {
                channel[1]-&gt;setMute( mute );

                mute != mute;
                break;
            }

        }
    }


    system-&gt;update();

    {
        int  channelsplaying = 0;

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

        printf( &quot;Channels Playing %d\r&quot;, channelsplaying );
    }


    Sleep( 10 );

} while ( key != 27) ;

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

/*
   Sound langsam herunterfahren
*/
printf( &quot;Goodbye!\n&quot; );
{
    float pitch = 1.0f;
    float vol = 1.0f;

    for ( count = 0; count &lt; 200; count++ )
    {
        masterGroup-&gt;setPitch( pitch );
        masterGroup-&gt;setVolume( vol );

        vol   -= ( 1.0f / 200.0f );
        pitch -= ( 0.5f / 200.0f );

        Sleep( 10 );
    }
}

/*
    Shut down
*/
for ( count = 0; count &lt; 6; count++ )
{
    result = sound[count]-&gt;release();
    ERRCHECK( result );
}

result = groupA-&gt;release();
ERRCHECK( result );
result = groupB-&gt;release();
ERRCHECK( result );

result = system-&gt;close();
ERRCHECK( result );
result = system-&gt;release();
ERRCHECK( result );

return 0;

}

[/code:1mzbh0gn]

  • You must to post comments
0
0

I think the real problem is your ‘mute’ variable being static. I think you want a different mute variable per button press, it would be confusing having it go true and false each time for different objects.

  • You must to post comments
0
0

Hello,

thank you for your post :)

It is correct, the same bool variable for 2 different issues.

But, if i make a new static bool ChannelMute it won’t go at all :/

And if i remove the "static" in front of mute it won’t go too :(

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.