public SoundLib() { if (system != null) { return; } FMOD.RESULT result = FMOD.Factory.System_Create(out system); if (ERRCHECK(result, "System_Create")) { return; } uint version; result = system.getVersion(out version); ERRCHECK(result, "system.getVersion"); if (version < FMOD.VERSION.number) { Report.ReportLog("Error! Old version of FMOD " + version.ToString("X") + " detected. This program requires " + FMOD.VERSION.number.ToString("X") + "."); system.close(); system.release(); system = null; return; } result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null); if (ERRCHECK(result, "system.init")) { system.close(); system.release(); system = null; return; } }
/// <summary> /// Stop and try to release FMOD sound resources /// </summary> void Stop_Internal() { this.GetComponent <AudioSource>().Stop(); this.isRecording = false; this.isPaused = false; /* * Shut down sound */ if (sound != null) { result = sound.release(); ERRCHECK(result, "sound.release", false); } sound = null; /* * Shut down */ if (system != null) { result = system.close(); ERRCHECK(result, "system.close", false); result = system.release(); ERRCHECK(result, "system.release", false); } system = null; }
public void Destroy() { FMOD.RESULT result; result = s_level1.release(); ERRCHECK(result); result = s_level2.release(); ERRCHECK(result); result = s_jump.release(); ERRCHECK(result); result = s_coin.release(); ERRCHECK(result); result = s_brick.release(); ERRCHECK(result); result = s_block.release(); ERRCHECK(result); result = s_stomp.release(); ERRCHECK(result); result = s_mush.release(); ERRCHECK(result); result = s_fireball.release(); ERRCHECK(result); result = soundsystem.close(); ERRCHECK(result); result = soundsystem.release(); ERRCHECK(result); }
public void Teardown() { m_masterChannelGroup.release(); m_fmodSystem.update(); m_fmodSystem.close(); m_fmodSystem.release(); }
void OnDisable() { this.StopFMODSound(); if (this.pcmReadCallbackBuffer != null) { this.pcmReadCallbackBuffer[0].Clear(); this.pcmReadCallbackBuffer[1].Clear(); this.pcmReadCallbackBuffer[0] = null; this.pcmReadCallbackBuffer[1] = null; this.pcmReadCallbackBuffer.Clear(); this.pcmReadCallbackBuffer = null; } this.pcmreadcallback = null; this.pcmsetposcallback = null; if (system != null) { result = system.close(); // ERRCHECK(result, "system.close", false); result = system.release(); // ERRCHECK(result, "system.release", false); } system = null; }
protected override void Dispose(bool disposing) { if (disposing) { FMOD.RESULT result; /* * Shutdown */ if (sound != null) { result = sound.release(); ERRCHECK(result); } if (system != null) { result = system.close(); ERRCHECK(result); result = system.release(); ERRCHECK(result); } if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
public void Dispose() { if (_fmodEngine != null) { _fmodEngine.release(); _fmodEngine = null; } }
public bool Destroy() { m_system.close(); m_system.release(); Console.WriteLine("[FMOD] SoundSystem destroyed"); return(true); }
/*------------------------*/ /* Unload all FMOD things */ /*------------------------*/ public void Unload() { _fmodSystem.release(); foreach (KeyValuePair <string, FMOD.Sound> sound in _sounds) { sound.Value.release(); } }
public void Dispose() { if (_system != null) { _system.close(); _system.release(); _system = null; } }
public override void Dispose() { if (mSystem != null) { mSystem.release(); mSystem = null; } mIsDisposed = true; }
private static void InitSoundEngine() { if (FMODSystem != null) { FMODSystem.release(); } FMOD.Factory.System_Create(ref FMODSystem); FMODSystem.setDriver(Settings.Current.OutputDevicePreListen); FMODSystem.setDSPBufferSize(500, 8); CurrentOutputDevicePreListen = Settings.Current.OutputDevicePreListen; FMODSystem.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)0); }
protected virtual void OnDisable() { this.Stop(); if (system != null && !this.unstableShutdown) { result = system.close(); // ERRCHECK(result, "system.close", false); result = system.release(); // ERRCHECK(result, "system.release", false); } system = null; }
/// <summary> /// Dispose /// </summary> public void Dispose() { //destroy FMOD if (_system != null) { FMOD.RESULT result; //close system result = _system.close(); CheckError(result); //release system result = _system.release(); CheckError(result); } }
protected override void UnloadGraphicsContent(bool unloadAllContent) { if (unloadAllContent) { Content.Unload(); } FMOD.RESULT result; if (SoundSystem != null) { result = SoundSystem.close(); ERRCHECK(result); result = SoundSystem.release(); ERRCHECK(result); } }
protected override void Dispose(bool disposing) { if (disposing) { FMOD.RESULT result; /* * Shut down */ for (int count = 0; count < 6; count++) { if (sound[count] != null) { result = sound[count].release(); ERRCHECK(result); } } if (groupA != null) { result = groupA.release(); ERRCHECK(result); } if (groupB != null) { result = groupB.release(); ERRCHECK(result); } if (system != null) { result = system.close(); ERRCHECK(result); result = system.release(); ERRCHECK(result); } if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
//gameover sequence and destructor public void GameOver() { //stop timer gravity.Stop(); gravity.Enabled = false; //reinitialize score score = 0; //remove all buttons for (int ix = Controls.Count - 1; ix >= 0; ix--) { if (Controls[ix] is Button && Controls[ix] != start && Controls[ix] != loadSongs) { Controls[ix].Dispose(); } } //get system and then release it to be able to load a new song FMOD.System sys = new FMOD.System(); sys = detector.getSystem(); sys.release(); sys.close(); //messagebox showing high score MessageBox.Show("Game Over" + "\nHigh Score: " + Convert.ToString(high), "Euphoria", MessageBoxButtons.OK, MessageBoxIcon.Information); //show hidden UI start.Visible = true; songs.Visible = true; loadSongs.Visible = true; difficulty.Visible = true; //hide in-game UI highScore.Visible = false; scoreDisplay.Visible = false; np.Visible = false; //remove hitfield Controls.Remove(pic); Controls.Remove(hitBar); }
public static void Dispose() { FMOD.RESULT result; /* * Shut down */ if (sound != null) { result = sound.release(); ERRCHECK(result); } if (system != null) { result = system.close(); ERRCHECK(result); result = system.release(); ERRCHECK(result); } }
/// <summary> /// Exit And Close The Audio Engine /// </summary> public void Dispose() { RESULT result = RESULT.OK; if (music != null) { result = music.release(); if (EngineError != null) { EngineError(result); } } if (system != null) { result = system.release(); } if (EngineError != null) { EngineError(result); } }
protected override void Dispose(bool disposing) { if (disposing) { FMOD.RESULT result; if (sound != null) { result = sound.release(); ERRCHECK(result); } if (dsplowpass != null) { result = dsplowpass.release(); ERRCHECK(result); } if (dspchorus != null) { result = dspchorus.release(); ERRCHECK(result); } if (system != null) { result = system.close(); ERRCHECK(result); result = system.release(); ERRCHECK(result); } if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { /* * Write back the wav header now that we know its length. */ if (recording) { recording = false; WriteWavHeader(datalength); } if (disposing) { FMOD.RESULT result; /* * Shut down */ if (sound != null) { result = sound.release(); ERRCHECK(result); } if (system != null) { result = system.close(); ERRCHECK(result); result = system.release(); ERRCHECK(result); } if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects). } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. foreach (var snd in Cache.Sounds) { FMOD.Error.Check(snd.Value.SoundEffect.release()); } _system.release(); disposedValue = true; } }
public static void Dispose() { FMOD.RESULT result; if (sound1 != null) { result = sound1.release(); ERRCHECK(result); } if (sound2 != null) { result = sound2.release(); ERRCHECK(result); } if (system != null) { result = system.close(); ERRCHECK(result); result = system.release(); ERRCHECK(result); } //base.Dispose(disposing); }
public void Unload() { Stop(); FMODSystem.release(); }
public void Dispose() { FMOD.RESULT result = fmod.release(); CheckResults(result); }
public void Unload() { FMODSystem.release(); }
public static void Unload() => FMODSystem.release();
private float BPMDetection(string filename) { float bpm = 0.0f; const int CHUNKSIZE = 4096; FMOD.RESULT result; FMOD.System systemBpm = null; FMOD.Sound soundBpm = null; // Create a System object and initialize. result = FMOD.Factory.System_Create(ref systemBpm); ERRCHECK(result); // Zuerst in eine WAVE-Umwandeln result = systemBpm.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null); ERRCHECK(result); result = systemBpm.createSound(filename, FMOD.MODE.OPENONLY | FMOD.MODE.ACCURATETIME, ref soundBpm); ERRCHECK(result); /* * Decode the sound and write it to a .raw file. */ { IntPtr data = Marshal.AllocHGlobal(CHUNKSIZE); byte[] buffer = new byte[CHUNKSIZE]; uint length = 0, read = 0; uint bytesread = 0; MemoryStream memStream = new MemoryStream(); result = soundBpm.getLength(ref length, FMOD.TIMEUNIT.PCMBYTES); ERRCHECK(result); bytesread = 0; do { result = soundBpm.readData(data, CHUNKSIZE, ref read); Marshal.Copy(data, buffer, 0, CHUNKSIZE); memStream.Write(buffer, 0, (int)read); bytesread += read; }while (result == FMOD.RESULT.OK && read == CHUNKSIZE); /* * Loop terminates when either * 1. the read function returns an error. (ie FMOD_ERR_FILE_EOF etc). * 2. the amount requested was different to the amount returned. (somehow got an EOF without the file error, maybe a non stream file format like mod/s3m/xm/it/midi). * * If 'bytesread' is bigger than 'length' then it just means that FMOD miscalculated the size, * but this will not usually happen if FMOD_ACCURATETIME is used. (this will give the correct length for VBR formats) */ memStream.Close(); // In float umwandeln byte[] samples = memStream.ToArray(); float[] floatSamples = new float[samples.Length / 2]; //for (int i = 0; i < samples.Length; i += 4) for (int i = samples.Length / 4; i < samples.Length * 3 / 4; i += 4) { short sampleLeft = BitConverter.ToInt16(samples, i); short sampleRight = BitConverter.ToInt16(samples, i + 2); floatSamples[i / 2] = (float)sampleLeft / 32768.0f; floatSamples[i / 2 + 1] = (float)sampleRight / 32768.0f; } BigMansStuff.PracticeSharp.Core.SoundTouchSharp soundTouch = new BigMansStuff.PracticeSharp.Core.SoundTouchSharp(); bpm = soundTouch.DetectBPM(2, 44100, floatSamples, floatSamples.Length); /* * Shut down */ if (soundBpm != null) { result = soundBpm.release(); ERRCHECK(result); } if (systemBpm != null) { result = systemBpm.close(); ERRCHECK(result); result = systemBpm.release(); ERRCHECK(result); } } return(bpm); }
/// <summary> /// Konvertieren von von Sound Dateien zu WAVE mit PCM Header /// </summary> /// <param name="src">Kompletter Pfad zur Quell Datei</param> /// <param name="dest">Kompletter Pfad zur Ziel Datei</param> /// <returns></returns> public bool ConvertToWAVE(string src_file, string dest_file, ConvertToWaveProgressDelegate convertToWaveProgressDelegate) { uint version = 0; FMOD.RESULT result; const int CHUNKSIZE = 262144; FMOD.System system = null; FMOD.Sound sound = null; /* * Global Settings */ result = FMOD.Factory.System_Create(ref system); if (result != FMOD.RESULT.OK) { return(false); } result = system.getVersion(ref version); ERRCHECK(result); if (version < FMOD.VERSION.number) { //MessageBox.Show("Error! You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + FMOD.VERSION.number.ToString("X") + "."); return(false); } result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null); ERRCHECK(result); result = system.createSound(src_file, FMOD.MODE.OPENONLY | FMOD.MODE.ACCURATETIME, ref sound); if (result != FMOD.RESULT.OK) { return(false); } /* * Decode the sound and write it to a .raw file. */ IntPtr data = Marshal.AllocHGlobal(CHUNKSIZE); byte[] buffer = new byte[CHUNKSIZE]; uint length = 0, read = 0; uint bytesread = 0; FileStream fs = new FileStream(dest_file, FileMode.Create, FileAccess.Write); result = sound.getLength(ref length, FMOD.TIMEUNIT.PCMBYTES); ERRCHECK(result); bytesread = 0; do { result = sound.readData(data, CHUNKSIZE, ref read); Marshal.Copy(data, buffer, 0, CHUNKSIZE); fs.Write(buffer, 0, (int)read); bytesread += read; double percent = 100.0 / (double)length * (double)bytesread; convertToWaveProgressDelegate(src_file, dest_file, percent); System.Windows.Forms.Application.DoEvents(); //statusBar.Text = "writing " + bytesread + " bytes of " + length + " to output.raw"; }while (result == FMOD.RESULT.OK && read == CHUNKSIZE); //statusBar.Text = "done"; /* * Loop terminates when either * 1. the read function returns an error. (ie FMOD_ERR_FILE_EOF etc). * 2. the amount requested was different to the amount returned. (somehow got an EOF without the file error, maybe a non stream file format like mod/s3m/xm/it/midi). * * If 'bytesread' is bigger than 'length' then it just means that FMOD miscalculated the size, * but this will not usually happen if FMOD_ACCURATETIME is used. (this will give the correct length for VBR formats) */ fs.Close(); /* * Shut down */ if (sound != null) { result = sound.release(); ERRCHECK(result); } if (system != null) { result = system.close(); ERRCHECK(result); result = system.release(); ERRCHECK(result); } return(true); }
private void playButton_Click(object sender, System.EventArgs e) { uint version = 0; FMOD.RESULT result; /* * Global Settings */ result = FMOD.Factory.System_Create(ref system); ERRCHECK(result); result = system.getVersion(ref version); ERRCHECK(result); if (version < FMOD.VERSION.number) { MessageBox.Show("Error! You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + FMOD.VERSION.number.ToString("X") + "."); Application.Exit(); } result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null); ERRCHECK(result); result = system.createSound("../../../../../examples/media/wave.mp3", FMOD.MODE.OPENONLY | FMOD.MODE.ACCURATETIME, ref sound); ERRCHECK(result); /* * Decode the sound and write it to a .raw file. */ { IntPtr data = Marshal.AllocHGlobal(CHUNKSIZE); byte[] buffer = new byte[CHUNKSIZE]; uint length = 0, read = 0; uint bytesread = 0; FileStream fs = new FileStream("output.raw", FileMode.Create, FileAccess.Write); result = sound.getLength(ref length, FMOD.TIMEUNIT.PCMBYTES); ERRCHECK(result); bytesread = 0; do { result = sound.readData(data, CHUNKSIZE, ref read); Marshal.Copy(data, buffer, 0, CHUNKSIZE); fs.Write(buffer, 0, (int)read); bytesread += read; statusBar.Text = "writing " + bytesread + " bytes of " + length + " to output.raw"; }while(result == FMOD.RESULT.OK && read == CHUNKSIZE); statusBar.Text = "done"; /* * Loop terminates when either * 1. the read function returns an error. (ie FMOD_ERR_FILE_EOF etc). * 2. the amount requested was different to the amount returned. (somehow got an EOF without the file error, maybe a non stream file format like mod/s3m/xm/it/midi). * * If 'bytesread' is bigger than 'length' then it just means that FMOD miscalculated the size, * but this will not usually happen if FMOD_ACCURATETIME is used. (this will give the correct length for VBR formats) */ fs.Close(); /* * Shut down */ if (sound != null) { result = sound.release(); ERRCHECK(result); } if (system != null) { result = system.close(); ERRCHECK(result); result = system.release(); ERRCHECK(result); } } }