public static void Create(FmodSystem system, string filename, out GraphicsPath maxPath, out GraphicsPath avgPath) { var sound = system.CreateStream(filename); Create(sound, out maxPath, out avgPath); sound.Dispose(); }
private void WaveFormWindow_Load(object sender, EventArgs e) { _system = Factory.CreateSystem(); _system.Initialize(InitFlags.Normal); _sound = _system.CreateStream(SNUFF, Mode.LoopNormal); waveForm1.LoadSound(_sound); _channel = _system.PlaySound(_sound); totalMs = _sound.GetLength(); }
public async Task <bool> Load(Mediafile mediaFile) { if (mediaFile != null && mediaFile.Length != "00:00") { //tell all listeners that we are about to change media await InitializeCore.Dispatcher.RunAsync(() => { MediaChanging?.Invoke(this, new EventArgs()); }); //stop currently playing track and free the channel await Stop(); //create a stream of the new track Result loadResult = _fmodSys.CreateStream(mediaFile.Path, _isMobile ? Mode.LowMem & Mode.IgnoreTags : Mode.Default, out _fmodSound); //load the stream into the channel but don't play it yet. loadResult = _fmodSys.PlaySound(_fmodSound, null, true, out _fmodChannel); //this checks if looping is enabled and then sets the loop SetLoop(); //START EXPERIMENT! //volume normalization code. //FMODSys.CreateDSPByType(Fmod.CoreDSP.DspType.NORMALIZE, out DSP dsp); //FMODChannel.addDSP(ChannelControlDspIndex.HEAD, dsp); //dsp.setParameterFloat((int)Fmod.CoreDSP.DspNormalize.THRESHHOLD, 1.0f); //dsp.setParameterFloat((int)Fmod.CoreDSP.DspNormalize.MAXAMP, 2.0f); //dsp.setActive(true); //END EXPERIMENT! //load equalizer if (Equalizer == null) { Equalizer = new FmodEqualizer(_fmodSys, _fmodChannel); } else { (Equalizer as FmodEqualizer).ReInit(_fmodSys, _fmodChannel); } //get and update length of the track. Length = TimeSpan.FromMilliseconds(_fmodSound.LengthInMilliseconds).TotalSeconds; //set the channel callback for all the syncpoints loadResult = _fmodChannel.SetCallback(_channelEndCallback); //add all the sync points //1. when song ends loadResult = _fmodSound.AddSyncPoint(_fmodSound.LengthInMilliseconds, TimeUnit.Ms, "songended", out _endSyncPoint); //2. when song has reached the last 15 seconds loadResult = _fmodSound.AddSyncPoint(_fmodSound.LengthInMilliseconds - 15000, TimeUnit.Ms, "songabouttoended", out _last15SyncPoint); //3. when song has reached the last 5 seconds loadResult = _fmodSound.AddSyncPoint(_fmodSound.LengthInMilliseconds - 5000, TimeUnit.Ms, "fade", out _last5SyncPoint); //update the system once here so that //all the sync points and callbacks are saved and updated. loadResult = _fmodSys.Update(); PlayerState = PlayerState.Stopped; CurrentlyPlayingFile = mediaFile; //check if all was successful return(loadResult == Result.Ok); } string error = "The file " + mediaFile.OrginalFilename + " is either corrupt, incomplete or unavailable. \r\n\r\n Exception details: No data available."; if (IgnoreErrors) { await InitializeCore.NotificationManager.ShowMessageAsync(error); } else { await InitializeCore.NotificationManager.ShowMessageBoxAsync(error, "File corrupt"); } return(false); }