public void Play(string audioPath, bool loop = false, int loopCount = -1) { if (!Game.dummyAudioOn) { return; } Stop(); FMOD.Sound sound = _audioMaster.LoadSound(audioPath); if (loop) { sound.setMode(FMOD.MODE.LOOP_NORMAL); sound.setLoopCount(loopCount - 1); } else { sound.setMode(FMOD.MODE.LOOP_OFF); } FMOD.RESULT result; result = _audioMaster.GetFmodSystem().playSound(sound, null, true, out _channel); // 3rd parameter : paused if (result != FMOD.RESULT.OK) { Console.WriteLine("[SpeakerComponent Play] FMOD playSound failed : " + result); } UpdateSpeakerAttributes(); setVolume(100.0f); PauseResume(); }
void createFMODSound(string fn) { // load the _sound FMOD.RESULT r; r = MusicEngine.AudioEngine.createSound(fn, FMOD.MODE.SOFTWARE, ref _sound); if (Util.ERRCHECK(r)) { throw new ContentLoadException(Util.ERRMSG(r)); } else { if (_sound != null) { r = _sound.setMode(FMOD.MODE.LOOP_NORMAL); // enable loop functionality, Util.ERRCHECK(r); r = _sound.setLoopCount(0); // but do not loop by default Util.ERRCHECK(r); // determine sample duration uint l = 0; r = _sound.getLength(ref l, FMOD.TIMEUNIT.MS); if (!Util.ERRCHECK(r)) { _soundDuration = ((double)l) / 1000.0; } } else { Util.Log("AudioSample.createFMODSound(): Error, _sound is null."); } } }