int FMOD_Main() { FMOD::System *system = 0; FMOD_RESULT result; unsigned int version; void *extradriverdata = 0; unsigned int pluginhandle; InspectorState state = PLUGIN_SELECTOR; PluginSelectorState pluginselector = { 0 }; ParameterViewerState parameterviewer = { 0 }; Common_Init(&extradriverdata); /* Create a System object and initialize */ result = FMOD::System_Create(&system); ERRCHECK(result); result = system->getVersion(&version); ERRCHECK(result); if (version < FMOD_VERSION) { Common_Fatal("FMOD lib version %08x doesn't match header version %08x", version, FMOD_VERSION); } result = system->init(32, FMOD_INIT_NORMAL, extradriverdata); ERRCHECK(result); result = system->getNumPlugins(FMOD_PLUGINTYPE_DSP, &pluginselector.numplugins); ERRCHECK(result); pluginselector.system = system; do { Common_Update(); if (state == PLUGIN_SELECTOR) { state = pluginSelectorDo(&pluginselector); if (state == PARAMETER_VIEWER) { result = pluginselector.system->getPluginHandle(FMOD_PLUGINTYPE_DSP, pluginselector.cursor, &pluginhandle); ERRCHECK(result); result = pluginselector.system->createDSPByPlugin(pluginhandle, ¶meterviewer.dsp); ERRCHECK(result); FMOD_RESULT result = parameterviewer.dsp->getNumParameters(¶meterviewer.numparams); ERRCHECK(result); parameterviewer.scroll = 0; } } else if (state == PARAMETER_VIEWER) { state = parameterViewerDo(¶meterviewer); if (state == PLUGIN_SELECTOR) { result = parameterviewer.dsp->release(); ERRCHECK(result); parameterviewer.dsp = 0; } } result = system->update(); ERRCHECK(result); Common_Sleep(INTERFACE_UPDATETIME - 1); } while (!Common_BtnPress(BTN_QUIT)); if (parameterviewer.dsp) { result = parameterviewer.dsp->release(); ERRCHECK(result); } result = system->close(); ERRCHECK(result); result = system->release(); ERRCHECK(result); Common_Close(); return 0; }
int main(int argc, char *argv[]) { FMOD::System *system = 0; FMOD::Sound *sound = 0; FMOD::Channel *channel = 0; FMOD_RESULT result; int count; bool playing = false; int key, numoutputplugins; unsigned int version; unsigned int handle; /* Create a System object and initialize. */ result = FMOD::System_Create(&system); ERRCHECK(result); result = system->getVersion(&version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); return 0; } /* Set the source directory for all of the FMOD plugins. */ #ifdef _WIN64 result = system->setPluginPath("../../api/plugins/64bit"); #else result = system->setPluginPath("../../api/plugins"); #endif ERRCHECK(result); /* Load up an extra plugin that is not normally used by FMOD. */ #ifdef _WIN64 result = system->loadPlugin("output_mp364.dll", 0, 0); #else result = system->loadPlugin("output_mp3.dll", 0, 0); #endif if (result == FMOD_ERR_FILE_NOTFOUND) { /* If it isn't in the same directory, try for the plugin directory. */ #ifdef _WIN64 result = system->loadPlugin("../plugin_dev/output_mp3/output_mp364.dll", 0, 0); #else result = system->loadPlugin("../plugin_dev/output_mp3/output_mp3.dll", 0, 0); #endif ERRCHECK(result); } /* Display plugins */ { int num; char name[256]; printf("Codec plugins\n"); printf("--------------\n"); result = system->getNumPlugins(FMOD_PLUGINTYPE_CODEC, &num); ERRCHECK(result); for (count = 0; count < num; count++) { result = system->getPluginHandle(FMOD_PLUGINTYPE_CODEC, count, &handle); ERRCHECK(result); result = system->getPluginInfo(handle, 0, name, 256, 0); ERRCHECK(result); printf("%2d - %-30s", count + 1, name); if (count % 2) { printf("\n"); } } printf("\n"); if (count % 2) { printf("\n"); } printf("DSP plugins\n"); printf("--------------\n"); result = system->getNumPlugins(FMOD_PLUGINTYPE_DSP, &num); ERRCHECK(result); for (count = 0; count < num; count++) { result = system->getPluginHandle(FMOD_PLUGINTYPE_DSP, count, &handle); ERRCHECK(result); result = system->getPluginInfo(handle, 0, name, 256, 0); ERRCHECK(result); printf("%2d - %-30s", count + 1, name); if (count % 2) { printf("\n"); } } printf("\n"); if (count % 2) { printf("\n"); } printf("Output plugins\n"); printf("--------------\n"); result = system->getNumPlugins(FMOD_PLUGINTYPE_OUTPUT, &numoutputplugins); ERRCHECK(result); for (count = 0; count < numoutputplugins; count++) { result = system->getPluginHandle(FMOD_PLUGINTYPE_OUTPUT, count, &handle); ERRCHECK(result); result = system->getPluginInfo(handle, 0, name, 256, 0); ERRCHECK(result); printf("%2d - %-30s", count + 1, name); if (count % 2) { printf("\n"); } } if (count % 2) { printf("\n"); } } /* System initialization */ printf("-----------------------------------------------------------------------\n"); // print driver names printf("Press a corresponding number for an OUTPUT PLUGIN to use or ESC to quit\n"); do { key = _getch(); } while (key != 27 && key < '1' && key > '0' + numoutputplugins); if (key == 27) { return 0; } result = system->getPluginHandle(FMOD_PLUGINTYPE_OUTPUT, key - '1', &handle); ERRCHECK(result); result = system->setOutputByPlugin(handle); ERRCHECK(result); int drivers; result = system->getNumDrivers(&drivers); ERRCHECK(result); result = system->init(32, FMOD_INIT_NORMAL, 0); ERRCHECK(result); result = system->createSound("../media/wave.mp3", FMOD_SOFTWARE | FMOD_CREATESTREAM, 0, &sound); ERRCHECK(result); printf("Press a key to play sound to output device.\n"); result = system->playSound(FMOD_CHANNEL_FREE, sound, 0, &channel); ERRCHECK(result); /* Main loop. */ do { unsigned int ms = 0; unsigned int lenms = 0; bool paused = false; int channelsplaying = 0; FMOD::Sound *currentsound = 0; system->update(); playing = false; result = channel->isPlaying(&playing); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = channel->getPaused(&paused); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } channel->getCurrentSound(¤tsound); if (currentsound) { result = currentsound->getLength(&lenms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } } system->getChannelsPlaying(&channelsplaying); printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying); Sleep(5); if (_kbhit()) { key = _getch(); if (key == 27) { break; } } } while (playing); printf("\n"); /* Shut down */ result = sound->release(); ERRCHECK(result); result = system->close(); ERRCHECK(result); result = system->release(); ERRCHECK(result); return 0; }