public async void PlayAsync(EffectsProperties properties) { if (waveFile != null) { // Convert wave file to discrete signal var signal = delay.WaveToSignal(waveFile); // Process delay DiscreteSignal delayProcessed = delay.Process( signal, properties.DelaySamples, properties.DelayGain, properties.DelayVolume, properties.DelayBypass); // Process flanger DiscreteSignal flangerProcessed = flanger.Process( delayProcessed, properties.FlangerSamples, properties.FlangerGain, properties.FlangerVolume, properties.FlangerSpeed, properties.FlangerBypass); // Process chorus DiscreteSignal chorusProcessed = chorus.Process( flangerProcessed, properties.ChorusMiliseconds, properties.ChorusGain1, properties.ChorusGain2, properties.ChorusVolume, properties.ChorusBypass); // Process distortion DiscreteSignal distProcessed = distortion.Process( chorusProcessed, properties.DistGain, properties.DistDistortion, properties.DistVolume, properties.DistBypass ); // Redirect last proccesed effect to output var output = distProcessed; if (audioPlayer == null) { audioPlayer = new MciAudioPlayer(); } audioPlayer.Stop(); // Save processed file to stream var processedFileName = string.Format("{0}.wav", Guid.NewGuid()); using (var stream = new FileStream(processedFileName, FileMode.Create)) { var waveFile = new WaveFile(output); waveFile.SaveTo(stream); } await audioPlayer.PlayAsync(processedFileName); // cleanup temporary file File.Delete(processedFileName); } }
public async void PlayUnprocessed() { if (waveFile != null) { if (audioPlayer == null) { audioPlayer = new MciAudioPlayer(); } audioPlayer.Stop(); await audioPlayer.PlayAsync(fileName); } }