int DM_Music_Play(int looped) { if(!fmodSystem) return false; if(songBuffer) { // Get rid of the old song. releaseSong(); setDefaultStreamBufferSize(); FMOD_CREATESOUNDEXINFO extra; zeroStruct(extra); extra.length = songBuffer->size; if(endsWith(soundFontFileName.c_str(), ".dls")) { extra.dlsname = soundFontFileName.c_str(); } // Load a new song. FMOD_RESULT result; result = fmodSystem->createSound(songBuffer->data, FMOD_CREATESTREAM | FMOD_OPENMEMORY | (looped? FMOD_LOOP_NORMAL : 0), &extra, &song); DSFMOD_TRACE("Music_Play: songBuffer has " << songBuffer->size << " bytes, created Sound " << song); DSFMOD_ERRCHECK(result); needReleaseSong = true; // The song buffer remains in memory, in case FMOD needs to stream from it. } return startSong(); }
int DM_Music_PlayFile(const char *filename, int looped) { if(!fmodSystem) return false; // Get rid of the current song. releaseSong(); releaseSongBuffer(); setDefaultStreamBufferSize(); FMOD_CREATESOUNDEXINFO extra; zeroStruct(extra); if(endsWith(soundFontFileName.c_str(), ".dls")) { extra.dlsname = soundFontFileName.c_str(); } FMOD_RESULT result; result = fmodSystem->createSound(filename, FMOD_CREATESTREAM | (looped? FMOD_LOOP_NORMAL : 0), &extra, &song); DSFMOD_TRACE("Music_Play: loaded '" << filename << "' => Sound " << song); DSFMOD_ERRCHECK(result); needReleaseSong = true; return startSong(); }
/** * Initialize the FMOD Ex sound driver. */ int DS_Init(void) { if(fmodSystem) { return true; // Already initialized. } // Create the FMOD audio system. FMOD_RESULT result; if((result = FMOD::System_Create(&fmodSystem)) != FMOD_OK) { Con_Message("FMOD::System_Create failed: (%d) %s", result, FMOD_ErrorString(result)); fmodSystem = 0; return false; } #ifdef WIN32 // Figure out the system's configured speaker mode. FMOD_SPEAKERMODE speakerMode; result = fmodSystem->getDriverCaps(0, 0, 0, &speakerMode); if(result == FMOD_OK) { fmodSystem->setSpeakerMode(speakerMode); } #endif // Manual overrides. if(CommandLine_Exists("-speaker51")) { fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_5POINT1); } if(CommandLine_Exists("-speaker71")) { fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_7POINT1); } if(CommandLine_Exists("-speakerprologic")) { fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_SRS5_1_MATRIX); } // Initialize FMOD. if((result = fmodSystem->init(50, FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_HRTF_LOWPASS, 0)) != FMOD_OK) { Con_Message("FMOD init failed: (%d) %s", result, FMOD_ErrorString(result)); fmodSystem->release(); fmodSystem = 0; return false; } // Options. FMOD_ADVANCEDSETTINGS settings; zeroStruct(settings); settings.HRTFMaxAngle = 360; settings.HRTFMinAngle = 180; settings.HRTFFreq = 11000; fmodSystem->setAdvancedSettings(&settings); #ifdef _DEBUG int numPlugins = 0; fmodSystem->getNumPlugins(FMOD_PLUGINTYPE_CODEC, &numPlugins); DSFMOD_TRACE("Plugins loaded: " << numPlugins); for(int i = 0; i < numPlugins; i++) { unsigned int handle; fmodSystem->getPluginHandle(FMOD_PLUGINTYPE_CODEC, i, &handle); FMOD_PLUGINTYPE pType; char pName[100]; unsigned int pVer = 0; fmodSystem->getPluginInfo(handle, &pType, pName, sizeof(pName), &pVer); DSFMOD_TRACE("Plugin " << i << ", handle " << handle << ": type " << pType << ", name:'" << pName << "', ver:" << pVer); } #endif // Print the credit required by FMOD license. Con_Message("FMOD Sound System (c) Firelight Technologies Pty, Ltd., 1994-2013."); DSFMOD_TRACE("DS_Init: FMOD initialized."); return true; }