void Java_org_fmod_programmerselected_Example_cStart(JNIEnv *env, jobject thiz) { FMOD_RESULT result = FMOD_OK; result = FMOD_EventGroup_GetEvent(gEventGroup, "ProgrammerSelected", FMOD_EVENT_DEFAULT, &gEvent); CHECK_RESULT(result); result = FMOD_Event_SetCallback(gEvent, eventcallback, NULL); CHECK_RESULT(result); result = FMOD_Event_Start(gEvent); CHECK_RESULT(result); }
int main(int argc, char *argv[]) { FMOD_EVENTSYSTEM *eventsystem; FMOD_EVENT *event; FMOD_RESULT result; int key; printf("======================================================================\n"); printf("Simple Event Example. Copyright (c) Firelight Technologies 2004-2014.\n"); printf("======================================================================\n"); printf("This example simply plays an event created with the FMOD Designer tool.\n"); printf("======================================================================\n\n"); ERRCHECK(result = FMOD_EventSystem_Create(&eventsystem)); ERRCHECK(result = FMOD_EventSystem_Init(eventsystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL)); ERRCHECK(result = FMOD_EventSystem_SetMediaPath(eventsystem, "..\\media\\")); ERRCHECK(result = FMOD_EventSystem_Load(eventsystem, "examples.fev", 0, 0)); ERRCHECK(result = FMOD_EventSystem_GetEvent(eventsystem, "examples/FeatureDemonstration/Basics/SimpleEvent", FMOD_EVENT_DEFAULT, &event)); printf("======================================================================\n"); printf("Press SPACE to play the event.\n"); printf("Press ESC to quit\n"); printf("======================================================================\n"); key = 0; do { FMOD_EVENT_STATE state; if (_kbhit()) { key = _getch(); if (key == ' ') { ERRCHECK(result = FMOD_Event_Start(event)); } } ERRCHECK(result = FMOD_EventSystem_Update(eventsystem)); Sleep(15); ERRCHECK(result = FMOD_Event_GetState(event, &state)); printf("Event is %s \r", (state & FMOD_EVENT_STATE_PLAYING) ? "playing" : "stopped"); } while (key != 27); ERRCHECK(result = FMOD_EventSystem_Release(eventsystem)); return 0; }
void Java_org_fmod_parameters_Example_cBegin(JNIEnv *env, jobject thiz) { FMOD_RESULT result = FMOD_OK; result = FMOD_EventSystem_Create(&gEventSystem); CHECK_RESULT(result); result = FMOD_EventSystem_Init(gEventSystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL); CHECK_RESULT(result); result = FMOD_EventSystem_SetMediaPath(gEventSystem, "/sdcard/fmod/"); CHECK_RESULT(result); result = FMOD_EventSystem_Load(gEventSystem, "examples.fev", 0, 0); CHECK_RESULT(result); result = FMOD_EventSystem_GetGroup(gEventSystem, "examples/AdvancedTechniques", 0, &gEventGroup); CHECK_RESULT(result); result = FMOD_EventGroup_GetEvent(gEventGroup, "car", FMOD_EVENT_DEFAULT, &car); CHECK_RESULT(result); result = FMOD_EventSystem_GetCategory(gEventSystem, "master", &gMasterCategory); CHECK_RESULT(result); result = FMOD_Event_GetParameter(car, "load", &load); CHECK_RESULT(result); result = FMOD_EventParameter_GetRange(load, &loadMin, &loadMax); CHECK_RESULT(result); result = FMOD_EventParameter_SetValue(load, loadMax); CHECK_RESULT(result); result = FMOD_Event_GetParameterByIndex(car, 0, &rpm); CHECK_RESULT(result); result = FMOD_EventParameter_GetRange(rpm, &rpmMin, &rpmMax); CHECK_RESULT(result); result = FMOD_EventParameter_SetValue(rpm, 1000.0f); CHECK_RESULT(result); result = FMOD_Event_Start(car); CHECK_RESULT(result); }
int main(int argc, char *argv[]) { FMOD_RESULT result; FMOD_EVENTSYSTEM *eventsystem; FMOD_EVENTGROUP *eventgroup; FMOD_EVENT *event; int key; printf("======================================================================\n"); printf("Programmer Sound. Copyright (c) Firelight Technologies 2006-2011.\n"); printf("======================================================================\n"); ERRCHECK(result = FMOD_EventSystem_Create(&eventsystem)); ERRCHECK(result = FMOD_EventSystem_Init(eventsystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL)); ERRCHECK(result = FMOD_EventSystem_SetMediaPath(eventsystem, (char *)MEDIA_PATH)); ERRCHECK(result = FMOD_EventSystem_Load(eventsystem, "examples.fev", 0, 0)); ERRCHECK(result = FMOD_EventSystem_GetGroup(eventsystem, "examples/FeatureDemonstration/SequencingAndStitching", FMOD_EVENT_DEFAULT, &eventgroup)); ERRCHECK(result = FMOD_EventSystem_GetSystemObject(eventsystem, &sys)); ERRCHECK(result = FMOD_System_CreateStream(sys, FSB_NAME, FMOD_2D | FMOD_NONBLOCKING | FMOD_SOFTWARE, 0, &fsb)); initIndexMap(fsb); printf("======================================================================\n"); printf("Press 'Space' to start the 'Programmer Sound' event\n"); printf("Press '>' to increase sound index\n"); printf("Press '<' to decrease sound index\n"); printf("Press 'Esc' to quit\n"); printf("======================================================================\n"); printf("Sound index = %d\n", g_sound_index + 1); key = 0; do { if (_kbhit()) { key = _getch(); switch(key) { case ' ' : ERRCHECK(result = FMOD_EventGroup_GetEvent(eventgroup, "ProgrammerSounds", FMOD_EVENT_DEFAULT, &event)); ERRCHECK(result = FMOD_Event_SetCallback(event, eventcallback, 0)); ERRCHECK(result = FMOD_Event_Start(event)); break; case '>' : case '.': ++g_sound_index; g_sound_index = (g_sound_index >= SOUND_INDEX_MAX) ? SOUND_INDEX_MAX - 1 : g_sound_index; printf("Sound index = %d\n", g_sound_index + 1); break; case '<' : case ',': --g_sound_index; g_sound_index = (g_sound_index < 0) ? 0 : g_sound_index; printf("Sound index = %d\n", g_sound_index + 1); break; } } ERRCHECK(result = FMOD_EventSystem_Update(eventsystem)); Sleep(10); } while (key != 27); ERRCHECK(result = FMOD_EventSystem_Unload(eventsystem)); ERRCHECK(result = FMOD_Sound_Release(fsb)); ERRCHECK(result = FMOD_EventSystem_Release(eventsystem)); return 0; }
int main(int argc, char *argv[]) { FMOD_RESULT result; FMOD_EVENTSYSTEM *eventsystem; FMOD_EVENTGROUP *eventgroup; FMOD_EVENT *event[NUM_EVENTS]; char *event_name[NUM_EVENTS] = { "Basics/BasicEventWithLooping", "SequencingAndStitching/LoopLogic", "3D Events/2D-3DPanMorph" }; int key, i, userdata = 0; printf("======================================================================\n"); printf("Realtime Tweaking. Copyright (c) Firelight Technologies 2004-2015.\n"); printf("======================================================================\n"); printf("This example shows how to initialize the FMOD Net Event System so that\n"); printf("FMOD Designer can connect to your game and tweak events as they're\n"); printf("playing.\n"); printf("Start some events then connect to this app using the Audition menu\n"); printf("in FMOD Designer. You can use 127.0.0.1 for the IP address if you\n"); printf("don't want to use two machines. Load tutorials.fdp and change the \n"); printf("volume of the playing events using the volume slider in the event\n"); printf("property sheet\n"); printf("======================================================================\n\n"); ERRCHECK(result = FMOD_EventSystem_Create(&eventsystem)); ERRCHECK(result = FMOD_NetEventSystem_Init(eventsystem, FMOD_EVENT_NET_PORT)); ERRCHECK(result = FMOD_EventSystem_Init(eventsystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL)); ERRCHECK(result = FMOD_EventSystem_SetMediaPath(eventsystem, (char *)MEDIA_PATH)); ERRCHECK(result = FMOD_EventSystem_Load(eventsystem, "examples.fev", 0, 0)); ERRCHECK(result = FMOD_EventSystem_GetGroup(eventsystem, "examples/FeatureDemonstration", FMOD_EVENT_DEFAULT, &eventgroup)); for (i=0; i < NUM_EVENTS; i++) { event[i] = 0; } printf("======================================================================\n"); printf("Press 1 - 3 to start/stop events\n"); printf("Press ESC to quit\n"); printf("======================================================================\n"); key = 0; do { if (_kbhit()) { key = _getch(); if ((key >= '1') && (key <= '3')) { i = (int)(key - '1'); if (event[i]) { ERRCHECK(result = FMOD_Event_Stop(event[i], 1)); event[i] = 0; printf("Stopping '%s'\n", event_name[i]); } else { ERRCHECK(result = FMOD_EventGroup_GetEvent(eventgroup, event_name[i], FMOD_EVENT_DEFAULT, &event[i])); ERRCHECK(result = FMOD_Event_SetCallback(event[i], eventcallback, (void *)(userdata++))); ERRCHECK(result = FMOD_Event_Start(event[i])); printf("Starting '%s'\n", event_name[i]); } } } ERRCHECK(result = FMOD_EventSystem_Update(eventsystem)); ERRCHECK(result = FMOD_NetEventSystem_Update()); Sleep(10); } while (key != 27); ERRCHECK(result = FMOD_EventSystem_Release(eventsystem)); ERRCHECK(result = FMOD_NetEventSystem_Shutdown()); return 0; }
int main(int argc, char *argv[]) { FMOD_EVENTSYSTEM *eventsystem; FMOD_EVENTGROUP *eventgroup; FMOD_EVENTCATEGORY *mastercategory; FMOD_EVENT *car; FMOD_EVENTPARAMETER *rpm; FMOD_EVENTPARAMETER *load; FMOD_RESULT result; int key; float rpm_val, rpm_min, rpm_max, rpm_increment, load_val, load_min, load_max, load_increment; printf("======================================================================\n"); printf("Parameters Example. Copyright (c) Firelight Technologies 2004-2015.\n"); printf("==============================-------=================================\n"); printf("This demonstrates the use of FMOD event parameters. It simply plays an\n"); printf("event, retrieves the parameters and allows the user to adjust them.\n"); printf("======================================================================\n\n"); ERRCHECK(result = FMOD_EventSystem_Create(&eventsystem)); ERRCHECK(result = FMOD_EventSystem_Init(eventsystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL)); ERRCHECK(result = FMOD_EventSystem_SetMediaPath(eventsystem, "..\\media\\")); ERRCHECK(result = FMOD_EventSystem_Load(eventsystem, "examples.fev", 0, 0)); ERRCHECK(result = FMOD_EventSystem_GetGroup(eventsystem, "examples/AdvancedTechniques", FMOD_EVENT_DEFAULT, &eventgroup)); ERRCHECK(result = FMOD_EventGroup_GetEvent(eventgroup, "car", FMOD_EVENT_DEFAULT, &car)); ERRCHECK(result = FMOD_EventSystem_GetCategory(eventsystem, "master", &mastercategory)); ERRCHECK(result = FMOD_Event_GetParameter(car, "load", &load)); ERRCHECK(result = FMOD_EventParameter_GetRange(load, &load_min, &load_max)); ERRCHECK(result = FMOD_EventParameter_SetValue(load, load_max)); ERRCHECK(result = FMOD_Event_GetParameterByIndex(car, 0, &rpm)); ERRCHECK(result = FMOD_EventParameter_GetRange(rpm, &rpm_min, &rpm_max)); ERRCHECK(result = FMOD_EventParameter_SetValue(rpm, 1000.0f)); ERRCHECK(result = FMOD_Event_Start(car)); printf("======================================================================\n"); printf("Press '<' or ',' to decrease RPM\n"); printf("Press '>' or '.' to increase RPM\n"); printf("Press '-' or '_' to decrease load\n"); printf("Press '+' or '=' to increase load\n"); printf("Press ESC to quit\n"); printf("======================================================================\n"); rpm_increment = (rpm_max - rpm_min) / (float)UPDATE_INTERVAL; ERRCHECK(result = FMOD_EventParameter_GetValue(rpm, &rpm_val)); load_increment = (load_max - load_min) / (float)UPDATE_INTERVAL; ERRCHECK(result = FMOD_EventParameter_GetValue(load, &load_val)); key = 0; do { if (_kbhit()) { key = _getch(); if (key == '<' || key == ',') { rpm_val -= rpm_increment; if (rpm_val < rpm_min) { rpm_val = rpm_min; } ERRCHECK(result = FMOD_EventParameter_SetValue(rpm, rpm_val)); } else if (key == '>' || key == '.') { rpm_val += rpm_increment; if (rpm_val > rpm_max) { rpm_val = rpm_max; } ERRCHECK(result = FMOD_EventParameter_SetValue(rpm, rpm_val)); } if (key == '-' || key == '_') { load_val -= load_increment; if (load_val < load_min) { load_val = load_min; } ERRCHECK(result = FMOD_EventParameter_SetValue(load, load_val)); } else if (key == '+' || key == '=') { load_val += load_increment; if (load_val > load_max) { load_val = load_max; } ERRCHECK(result = FMOD_EventParameter_SetValue(load, load_val)); } else if (key == ' ') { int paused; ERRCHECK(result = FMOD_EventCategory_GetPaused(mastercategory, &paused)); paused = !paused; ERRCHECK(result = FMOD_EventCategory_SetPaused(mastercategory, paused)); } } ERRCHECK(result = FMOD_EventSystem_Update(eventsystem)); Sleep(15); printf("RPM = %.4f, load = %.4f \r", rpm_val, load_val); } while (key != 27); ERRCHECK(result = FMOD_EventGroup_FreeEventData(eventgroup, 0, 1)); ERRCHECK(result = FMOD_EventSystem_Release(eventsystem)); return 0; }
int main(int argc, char *argv[]) { FMOD_EVENTSYSTEM *eventsystem; FMOD_EVENTGROUP *eventgroup; FMOD_EVENT *event = 0; FMOD_RESULT result; int key; int state_changed = 1; printf("======================================================================\n"); printf("Info-only Event Example. Copyright (c) Firelight Technologies 2004-2015.\n"); printf("==============================-------=================================\n"); printf("This demonstrates usage and functionality of info-only events.\n"); printf("======================================================================\n\n"); ERRCHECK(result = FMOD_EventSystem_Create(&eventsystem)); ERRCHECK(result = FMOD_EventSystem_Init(eventsystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL)); ERRCHECK(result = FMOD_EventSystem_SetMediaPath(eventsystem, "..\\media\\")); ERRCHECK(result = FMOD_EventSystem_Load(eventsystem, "examples.fev", 0, 0)); ERRCHECK(result = FMOD_EventSystem_GetGroup(eventsystem, "examples/FeatureDemonstration/Basics", 0, &eventgroup)); printf("======================================================================\n"); printf("Press 'i' to get an info-only event\n"); printf("Press 'e' to get an event instance\n"); printf("Press 'u' to unload all event data\n"); printf("Press '1' - '0' to set event volume between 10%% - 100%%\n"); printf("Press Space to start/stop the current event\n"); printf("Press ESC to quit\n"); printf("======================================================================\n"); key = 0; do { if (_kbhit()) { key = _getch(); if (key == 'i') { /* Get an info-only event. Notes: - This is the parent from which all instances of the specified event are derived. - This call will not allocate memory for event instances or load sample data. - The resulting event cannot be played, it simply allows querying and setting of event properties. - Any properties which are set on the info-only event will be copied to all instances which are retrieved from then on. */ ERRCHECK(result = FMOD_EventGroup_GetEvent(eventgroup, "BasicEventWithLooping", FMOD_EVENT_INFOONLY, &event)); printf("getEvent(FMOD_EVENT_INFOONLY) succeeded\n"); state_changed = 1; } else if (key == 'e') { /* Get an event instance. Notes: - This call will allocate memory for event instances and load sample data if required. - The resulting event can be played. - Any properties which have been set on the info-only event will be copied to this instance. */ ERRCHECK(result = FMOD_EventGroup_GetEvent(eventgroup, "BasicEventWithLooping", FMOD_EVENT_DEFAULT, &event)); printf("getEvent(FMOD_EVENT_DEFAULT) succeeded\n"); state_changed = 1; } else if (key == ' ') { if (event) { FMOD_EVENT_STATE state; result = FMOD_Event_GetState(event, &state); if (result != FMOD_ERR_INVALID_HANDLE) { ERRCHECK(result); } if (state & FMOD_EVENT_STATE_PLAYING) { /* Attempt to stop the event. - This will fail if the event is info-only. */ result = FMOD_Event_Stop(event, 0); if(result == FMOD_OK) { printf("event->stop() succeeded\n"); state_changed = 1; } else { printf("event->stop() returned an error:\n\t(%d) %s\n", result, FMOD_ErrorString(result)); } } else { /* Attempt to start the event. - This will fail if the event is info-only. */ result = FMOD_Event_Start(event); if (result == FMOD_OK) { printf("event->start() succeeded\n"); state_changed = 1; } else { printf("event->start() returned an error:\n\t(%d) %s\n", result, FMOD_ErrorString(result)); } } } } else if (key >= '0' && key <= '9') { /* Attempt to set the event's volume. - This will succeed on both info-only events and instances. - Volume set on the info-only event will be copied to all instances retrieved from now on. - Volume set on an instance will only apply to that instance. */ float volume = (float)(key - '0'); if (volume == 0) { volume = 10.0f; } volume /= 10.0f; result = FMOD_Event_SetVolume(event, volume); if (result == FMOD_OK) { printf("event->setVolume() succeeded\n"); state_changed = 1; } else { printf("event->setVolume() returned an error:\n\t(%d) %s\n", result, FMOD_ErrorString(result)); } } else if (key == 'u') { ERRCHECK(result = FMOD_EventGroup_FreeEventData(eventgroup, 0, 1)); printf("Event data unloaded\n"); state_changed = 1; } } if (state_changed) { int memory_current, memory_max; ERRCHECK(result = FMOD_Memory_GetStats(&memory_current, &memory_max, 0)); printf("Memory usage: current = %10d, max = %10d\n", memory_current, memory_max); if (event) { /* Attempt to get the event's volume. - This will succeed on both info-only events and instances. */ float volume; result = FMOD_Event_GetVolume(event, &volume); if (result != FMOD_ERR_INVALID_HANDLE) { ERRCHECK(result); printf("Volume: %.2f\n", volume); } } state_changed = 0; } ERRCHECK(result = FMOD_EventSystem_Update(eventsystem)); Sleep(15); } while (key != 27); ERRCHECK(result = FMOD_EventGroup_FreeEventData(eventgroup, 0, 1)); ERRCHECK(result = FMOD_EventSystem_Release(eventsystem)); return 0; }
int main(int argc, char *argv[]) { FMOD_EVENTSYSTEM *eventsystem = 0; FMOD_SYSTEM *system = 0; void *project_mem = 0; unsigned int project_len = 0; FMOD_EVENT *sampleevent = 0; FMOD_SOUND *samplebank = 0; void *samplebank_mem = 0; unsigned int samplebank_len = 0; FMOD_EVENT *streamevent = 0; FMOD_SOUND *streambank = 0; FMOD_RESULT result = FMOD_OK; int key = 0; FMOD_EVENT_LOADINFO load_info; printf("======================================================================\n"); printf("Load Event Data Example. Copyright (c) Firelight Technologies 2004-2014.\n"); printf("==============================-------=================================\n"); printf("This Demonstrates loading all resources from memory allocated and filled\n"); printf("by the user.\n"); printf("======================================================================\n\n"); /* Load FEV file into memory */ loadFileIntoMemory("..\\media\\examples.fev", &project_mem, &project_len); ERRCHECK(result = FMOD_EventSystem_Create(&eventsystem)); ERRCHECK(result = FMOD_EventSystem_GetSystemObject(eventsystem, &system)); ERRCHECK(result = FMOD_EventSystem_Init(eventsystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL)); ERRCHECK(result = FMOD_EventSystem_SetMediaPath(eventsystem, "..\\media\\")); /* we require a loadinfo struct to tell FMOD how big the in memory FEV file is */ memset(&load_info, 0, sizeof(FMOD_EVENT_LOADINFO)); load_info.size = sizeof(FMOD_EVENT_LOADINFO); load_info.loadfrommemory_length = project_len; /* load the project from memory */ ERRCHECK(result = FMOD_EventSystem_Load(eventsystem, (char*)project_mem, &load_info, NULL)); printf("======================================================================\n"); printf("Press 'e' to load sample data\n"); printf("Press 'E' to unload sample data\n"); printf("Press 'd' to start sample event\n"); printf("Press 'w' to open stream\n"); printf("Press 'W' to close stream\n"); printf("Press 's' to start stream event\n"); printf("Press ESC to quit\n"); printf("======================================================================\n"); key = 0; do { if (_kbhit()) { key = _getch(); if (key == 'e') { /* Attempt to get the event without disk access */ result = FMOD_EventSystem_GetEvent(eventsystem, "examples/FeatureDemonstration/Basics/SimpleEvent", FMOD_EVENT_ERROR_ON_DISKACCESS, &sampleevent); if (result != FMOD_ERR_FILE_UNWANTED) { ERRCHECK(result); } else { /* file unwanted error tells us we haven't got the soundbank preloaded, so preload it now... */ FMOD_CREATESOUNDEXINFO info = {0}; printf("Loading event data\n"); loadFileIntoMemory("..\\media\\tutorial_bank.fsb", &samplebank_mem, &samplebank_len); /* We need to create a FMOD_SOUND object to use with preloadFSB */ info.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); info.length = samplebank_len; ERRCHECK(result = FMOD_System_CreateSound(system, (char*)samplebank_mem, FMOD_OPENMEMORY_POINT | FMOD_CREATECOMPRESSEDSAMPLE, &info, &samplebank)); /* Tell FMOD that we have loaded this FSB */ ERRCHECK(result = FMOD_EventSystem_PreloadFSB(eventsystem, "tutorial_bank.fsb", 0, samplebank)); /* Now we can get the event without diskaccess */ ERRCHECK(result = FMOD_EventSystem_GetEvent(eventsystem, "examples/FeatureDemonstration/Basics/SimpleEvent", FMOD_EVENT_ERROR_ON_DISKACCESS, &sampleevent)); } printf("Sample event ready\n"); } else if (key == 'E') { if (!samplebank) { printf("Nothing to unload\n"); } else { ERRCHECK(result = FMOD_Event_Stop(sampleevent, 0)); sampleevent = 0; /* Note: we *MUST* call unload before freeing data */ ERRCHECK(result = FMOD_EventSystem_UnloadFSB(eventsystem, "tutorial_bank.fsb", 0)); ERRCHECK(result = FMOD_Sound_Release(samplebank)); samplebank = 0; if (samplebank_mem) { free(samplebank_mem); samplebank_mem = 0; } printf("Event data unloaded\n"); } } else if (key == 'd') { if (!sampleevent) { printf("no event loaded!\n"); } else { ERRCHECK(result = FMOD_Event_Start(sampleevent)); } } else if (key == 'w') { /* Attempt to get the event without opening a new stream */ result = FMOD_EventSystem_GetEvent(eventsystem, "examples/AdvancedTechniques/MultiChannelMusic", FMOD_EVENT_ERROR_ON_DISKACCESS, &streamevent); if (result != FMOD_ERR_FILE_UNWANTED) { ERRCHECK(result); } else { /* file unwanted error tells us we haven't got the stream instance preloaded so preload it now */ printf("Opening stream\n"); /* If the 'Max Streams' property of the sound bank is greater than 1 then mutiple streams can be opened. This means we need to preload it multiple times if we want to prevent FMOD from creating streams internally. Each stream is uniquely identified using the 'streaminstance' parameter to preloadFSB which counts upwards from 0. */ ERRCHECK(result = FMOD_System_CreateSound(system, "..\\media\\streaming_bank.fsb", FMOD_CREATESTREAM, 0, &streambank)); ERRCHECK(result = FMOD_EventSystem_PreloadFSB(eventsystem, "streaming_bank.fsb", 0, streambank)); /* Now we can get the event without opening a new stream */ ERRCHECK(result = FMOD_EventSystem_GetEvent(eventsystem, "examples/AdvancedTechniques/MultiChannelMusic", FMOD_EVENT_ERROR_ON_DISKACCESS, &streamevent)); } printf("Stream event ready\n"); } else if (key == 'W') { if (!streambank) { printf("Nothing to unload\n"); } else { ERRCHECK(result = FMOD_Event_Stop(streamevent, 0)); streamevent = 0; /* Note: we *MUST* call unload before releasing stream */ ERRCHECK(result = FMOD_EventSystem_UnloadFSB(eventsystem, "streaming_bank.fsb", 0)); ERRCHECK(result = FMOD_Sound_Release(streambank)); streambank = 0; printf("Stream closed\n"); } } else if (key == 's') { if (!streamevent) { printf("no event loaded!\n"); } else { ERRCHECK(result = FMOD_Event_Start(streamevent)); } } } ERRCHECK(result = FMOD_EventSystem_Update(eventsystem)); Sleep(15); } while (key != 27); if (samplebank) { /* Note: we *MUST* call unload before freeing data */ ERRCHECK(result = FMOD_EventSystem_UnloadFSB(eventsystem, "tutorial_bank.fsb", 0)); ERRCHECK(result = FMOD_Sound_Release(samplebank)); if (samplebank_mem) { free(samplebank_mem); } } if (streambank) { /* Note: we *MUST* call unload before releasing stream */ ERRCHECK(result = FMOD_EventSystem_UnloadFSB(eventsystem, "streaming_bank.fsb", 0)); ERRCHECK(result = FMOD_Sound_Release(streambank)); } ERRCHECK(result = FMOD_EventSystem_Release(eventsystem)); /* Free the memory we have allocated */ free(project_mem); return 0; }
int main(int argc, char *argv[]) { FMOD_EVENTSYSTEM *eventsystem; FMOD_EVENT *event; FMOD_EVENTPARAMETER *param00; FMOD_RESULT result; int key; float param00_val, param00_min, param00_max, param00_increment; printf("======================================================================\n"); printf("Effects Example. Copyright (c) Firelight Technologies 2004-2011.\n"); printf("==============================-------=================================\n"); printf("This demonstrates the use of FMOD event effects. It simply plays an\n"); printf("event with effects applied and allows the user to adjust the parameters.\n"); printf("======================================================================\n\n"); ERRCHECK(result = FMOD_EventSystem_Create(&eventsystem)); ERRCHECK(result = FMOD_EventSystem_Init(eventsystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL)); ERRCHECK(result = FMOD_EventSystem_SetMediaPath(eventsystem, "..\\media\\")); ERRCHECK(result = FMOD_EventSystem_Load(eventsystem,"examples.fev", 0, 0)); ERRCHECK(result = FMOD_EventSystem_GetEvent(eventsystem, "examples/FeatureDemonstration/Effects/PropertyAutomationEffectEnvelope", FMOD_EVENT_DEFAULT, &event)); ERRCHECK(result = FMOD_Event_GetParameter(event, "param00", ¶m00)); ERRCHECK(result = FMOD_EventParameter_GetRange(param00, ¶m00_min, ¶m00_max)); ERRCHECK(result = FMOD_EventParameter_SetValue(param00, 0.0f)); ERRCHECK(result = FMOD_Event_Start(event)); printf("======================================================================\n"); printf("Press '<' or ',' to decrease param00\n"); printf("Press '>' or '.' to increase param00\n"); printf("Press ESC to quit\n"); printf("======================================================================\n"); printf("\n"); param00_increment = (param00_max - param00_min) / UPDATE_INTERVAL; ERRCHECK(result = FMOD_EventParameter_GetValue(param00, ¶m00_val)); key = 0; do { if (_kbhit()) { key = _getch(); if (key == '<' || key == ',') { param00_val -= param00_increment; if (param00_val < param00_min) { param00_val = param00_min; } ERRCHECK(result = FMOD_EventParameter_SetValue(param00, param00_val)); } else if (key == '>' || key == '.') { param00_val += param00_increment; if (param00_val > param00_max) { param00_val = param00_max; } ERRCHECK(result = FMOD_EventParameter_SetValue(param00, param00_val)); } } ERRCHECK(result = FMOD_EventSystem_Update(eventsystem)); Sleep(15); printf("param00 = %.4f \r", param00_val); } while (key != 27); ERRCHECK(result = FMOD_EventSystem_Release(eventsystem)); return 0; }
int main(int argc, char *argv[]) { FMOD_RESULT result; FMOD_EVENTSYSTEM *eventsystem; FMOD_EVENTGROUP *eventgroup; FMOD_EVENT *event; int key; enum { StealOldest, StealNewest, StealQuietest, JustFail, JustFailIfQuietest } event_behaviour = StealOldest; ERRCHECK(result = FMOD_EventSystem_Create(&eventsystem)); ERRCHECK(result = FMOD_EventSystem_Init(eventsystem, 64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL)); ERRCHECK(result = FMOD_EventSystem_SetMediaPath(eventsystem, (char *)MEDIA_PATH)); ERRCHECK(result = FMOD_EventSystem_Load(eventsystem, "examples.fev", 0, 0)); ERRCHECK(result = FMOD_EventSystem_GetGroup(eventsystem, "examples/FeatureDemonstration/MaxPlayback", FMOD_EVENT_DEFAULT, &eventgroup)); ERRCHECK(result); printf("======================================================================\n"); printf("Max Playbacks Example. Copyright (c) Firelight Technologies 2004-2014.\n"); printf("----------------------------------------------------------------------\n"); printf("Press '1' to select 'Steal oldest' behaviour\n"); printf("Press '2' to select 'Steal newest' behaviour\n"); printf("Press '3' to select 'Steal quietest' behaviour\n"); printf("Press '4' to select 'Just fail' behaviour\n"); printf("Press '5' to select 'Just fail if quietest' behaviour\n"); printf("Press Space to start an event\n"); printf("Press 's' to stop all events\n"); printf("Press '>' to increase event distance\n"); printf("Press '<' to decrease event distance\n"); printf("Press ESC to quit\n"); printf("======================================================================\n"); key = 0; do { if (_kbhit()) { char *name; key = _getch(); switch(key) { case '1' : // 'Steal oldest' event_behaviour = StealOldest; stopAllEvents(eventgroup); break; case '2' : // 'Steal newest' event_behaviour = StealNewest; stopAllEvents(eventgroup); break; case '3' : // 'Steal quietest' event_behaviour = StealQuietest; stopAllEvents(eventgroup); break; case '4' : // 'Just fail' event_behaviour = JustFail; stopAllEvents(eventgroup); break; case '5' : // 'Just fail if quietest' event_behaviour = JustFailIfQuietest; stopAllEvents(eventgroup); break; case ' ' : // Play an event switch(event_behaviour) { case StealOldest : name = "MaxPlay-StealOldest"; break; case StealNewest : name = "MaxPlay-StealNewest"; break; case StealQuietest : name = "MaxPlay-StealQuietest"; break; case JustFail : name = "MaxPlay-JustFail"; break; case JustFailIfQuietest : name = "MaxPlay-JustFailIfQuietest"; break; } // Clear the line printf("%79s\r", " "); if (event_behaviour == JustFailIfQuietest) { /* The 'Just fail if quietest' behaviour calculates the expected volume of the event based on the properties of the info-only event, so we have to get the info-only event first and set it up appropriately. */ // get the info-only event to set up for volume calculation ERRCHECK(result = FMOD_EventGroup_GetEvent(eventgroup, name, FMOD_EVENT_INFOONLY, &event)); /* set the desired properties on the info-only event Notes: - distances below the event's 3D Min Distance all give the same volume; in this case, getEvent will just fail - we could set other volume-affecting properties here as well (e.g. orientation if the event has a falloff cone) */ setupEvent(event); // attempt to get a real event instance result = FMOD_EventGroup_GetEvent(eventgroup, name, FMOD_EVENT_DEFAULT, &event); if (result == FMOD_OK) { FMOD_EVENTPARAMETER *param; printf("getEvent(\"%s\") succeeded\n", name); /* we don't need to set the position of the instance, as it is copied from the info-only event, but we do need to set the parameter value. */ ERRCHECK(result = FMOD_Event_GetParameter(event, "sound", ¶m)); ERRCHECK(result = FMOD_EventParameter_SetValue(param, g_sound)); ERRCHECK(result = FMOD_Event_Start(event)); } else { printf("getEvent(\"%s\") failed\n", name); } } else { result = FMOD_EventGroup_GetEvent(eventgroup, name, FMOD_EVENT_DEFAULT, &event); if (result == FMOD_OK) { printf("getEvent(\"%s\") succeeded\n", name); setupEvent(event); ERRCHECK(result = FMOD_Event_Start(event)); } else { printf("getEvent(\"%s\") failed\n", name); } } ++g_sound; if(g_sound > 3) { g_sound = 0; } break; case 's' : stopAllEvents(eventgroup); break; case '>' : case '.' : g_distance += 0.1f; break; case '<' : case ',' : g_distance -= 0.1f; g_distance = (g_distance < 0.0f) ? 0.0f : g_distance; break; } switch(event_behaviour) { case StealOldest: name = "Steal oldest"; break; case StealNewest: name = "Steal newest"; break; case StealQuietest: name = "Steal quietest"; break; case JustFail: name = "Just fail"; break; case JustFailIfQuietest: name = "Just fail if quietest"; break; } printf("Sound = %1.0f, Distance = %4.1f, Behaviour = %-25s\r", g_sound, g_distance, name); } ERRCHECK(result = FMOD_EventSystem_Update(eventsystem)); Sleep(10); } while (key != 27); ERRCHECK(result = FMOD_EventSystem_Unload(eventsystem)); ERRCHECK(result = FMOD_EventSystem_Release(eventsystem)); return 0; }