0
0

Hi,

I’ve read the excellent tutorials for getting started with the Interactive Music System in the designer, but I can’t seem to find an example of triggering music from code. I’ve tried a forum search but most questions seem to be about the designer itself.

Does anyone have a simple example of playing a cue?

Thanks

  • You must to post comments
0
0

Hi hajasal_sk, welcome to the forums!

To see how to use the music system from code, check out fmoddesignerapi/examples/musicsystem example app, in your FMOD install directory.

-Pete

  • You must to post comments
0
0

Hi Peter,

Thanks for the quick reply.

That folder / app does not exist for me. I am running the latest stable Mac release.

Thanks

  • You must to post comments
0
0

I see that the musicsystem example hasn’t been ported to mac yet. You should be able to get the idea of how it works from the win32 example code.

-Pete

  • You must to post comments
0
0

is there some way i can look at the MusicSystem example code without downloading the Win32 version? (or better yet, is the Mac version available yet??)

i’m running OSX 10.6.4, and want to control music cues using C++ …

  • You must to post comments
0
0

here:
[code:88zr3a1d]/*===============================================================================================
Music System Example
Copyright (c), Firelight Technologies Pty, Ltd 2004-2010.

Demonstrates basic usage of FMOD’s data-driven event library (fmod_event.dll)
===============================================================================================*/

include "../../api/inc/fmod_event.hpp"

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

include <windows.h>

include <stdio.h>

include <stdlib.h>

include <conio.h>

include "examples.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::EventSystem *eventsystem;
FMOD::MusicSystem *musicsystem;
FMOD::MusicPrompt *country;
FMOD::MusicPrompt *stealth;
FMOD::MusicPrompt *retrorock;
FMOD_RESULT result;
int key;

printf(&quot;======================================================================\n&quot;);
printf(&quot;Music System Example.  Copyright (c) Firelight Technologies 2004-2010.\n&quot;);
printf(&quot;======================================================================\n&quot;);
printf(&quot;Press '1'       to activate/deactivate country cue.\n&quot;);
printf(&quot;Press '2'       to activate/deactivate stealth cue.\n&quot;);
printf(&quot;Press '3'       to activate/deactivate retro rock cue.\n&quot;);
printf(&quot;Press '&lt;' / '&gt;' to decrease/increase retro rock intensity parameter.\n&quot;);
printf(&quot;======================================================================\n&quot;);

ERRCHECK(result = FMOD::EventSystem_Create(&amp;eventsystem));
ERRCHECK(result = eventsystem-&gt;init(64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL));
ERRCHECK(result = eventsystem-&gt;setMediaPath(&quot;..\\media\\&quot;));
ERRCHECK(result = eventsystem-&gt;load(&quot;examples.fev&quot;, 0, 0));

ERRCHECK(result = eventsystem-&gt;getMusicSystem(&amp;musicsystem));

ERRCHECK(result = musicsystem-&gt;prepareCue(MUSICCUE_EXAMPLES_COUNTRY_ARENA,    &amp;country));
ERRCHECK(result = musicsystem-&gt;prepareCue(MUSICCUE_EXAMPLES_STEALTH_ARENA,    &amp;stealth));
ERRCHECK(result = musicsystem-&gt;prepareCue(MUSICCUE_EXAMPLES_RETRO_ROCK_ARENA, &amp;retrorock));

/*
    Start off with country cue active
*/
result = country-&gt;begin();
ERRCHECK(result);

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

        bool active = false;

        if (key == '1')
        {
            ERRCHECK(result = country-&gt;isActive(&amp;active));
            if (!active)
            {
                ERRCHECK(result = country-&gt;begin());
                printf(&quot;Country cue begin             \n&quot;);
            }
            else
            {
                ERRCHECK(result = country-&gt;end());
                printf(&quot;Country cue end               \n&quot;);
            }
        }
        else if (key == '2')
        {
            ERRCHECK(result = stealth-&gt;isActive(&amp;active));
            if (!active)
            {
                ERRCHECK(result = stealth-&gt;begin());
                printf(&quot;Stealth cue begin             \n&quot;);
            }
            else
            {
                ERRCHECK(result = stealth-&gt;end());
                printf(&quot;Stealth cue end               \n&quot;);
            }
        }
        else if (key == '3')
        {
            ERRCHECK(result = retrorock-&gt;isActive(&amp;active));
            if (!active)
            {
                ERRCHECK(result = retrorock-&gt;begin());
                printf(&quot;Retro rock cue begin          \n&quot;);
            }
            else
            {
                ERRCHECK(result = retrorock-&gt;end());
                printf(&quot;Retro rock cue end            \n&quot;);
            }
        }

        if (key == '&lt;' || key == ',')
        {
            float intensity;

            ERRCHECK(result = musicsystem-&gt;getParameterValue(MUSICPARAM_EXAMPLES_RETRO_ROCK_INTENSITY, &amp;intensity));

            intensity -= 3.3f;
            if (intensity &lt; 0.0f)
            {
                intensity = 0.0f;
            }

            ERRCHECK(result = musicsystem-&gt;setParameterValue(MUSICPARAM_EXAMPLES_RETRO_ROCK_INTENSITY, intensity));
        }
        if (key == '&gt;' || key == '.')
        {
            float intensity;

            ERRCHECK(result = musicsystem-&gt;getParameterValue(MUSICPARAM_EXAMPLES_RETRO_ROCK_INTENSITY, &amp;intensity));

            intensity += 3.3f;
            if (intensity &gt; 9.9f)
            {
                intensity = 9.9f;
            }

            ERRCHECK(result = musicsystem-&gt;setParameterValue(MUSICPARAM_EXAMPLES_RETRO_ROCK_INTENSITY, intensity));
        }
    }

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

    {
        float intensity = 0.0f;

        musicsystem-&gt;getParameterValue(MUSICPARAM_EXAMPLES_RETRO_ROCK_INTENSITY, &amp;intensity);

        printf(&quot;retro rock intensity : %.02f\r&quot;, intensity);
    }

} while (key != 27);

ERRCHECK(result = eventsystem-&gt;release());
return 0;

}
[/code:88zr3a1d]

  • You must to post comments
0
0

<thumbs up> thanks!! </thumbs up>

  • You must to post comments
0
0

uh, can i please get a look at the "examples.h" file too, so i can maybe compile the example code?

  • You must to post comments
0
0

examples.h is generated from designer. To do that, build the ‘examples’ project in designer and check the "Build header file (.h)" box.

  • You must to post comments
0
0

<facepalm> duh! of course! thanks! :)

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.