//called when data for any output pin is requested public void Evaluate(int SpreadMax) { FOutput.SliceCount = SpreadMax; if (effect != null) { if (Fc1.IsChanged) { effect.c1 = Fc1[0]; } if (Fc2.IsChanged) { effect.c2 = Fc2[0]; } if (Fc3.IsChanged) { effect.c3 = Fc3[0]; } if (FInStream[0] != effect.SourceStream) { effect.SourceStream = FInStream[0]; } } else if (FInStream[0] != null) { effect = new EffectStream(FInStream[0], 2000, 0.5f, Fc1[0], Fc2[0], Fc3[0]); } if (FOutput[0] != this) { FOutput[0] = this; } //FLogger.Log(LogType.Debug, "hi tty!"); }
static void ApplyEffects(IWaveProvider waveChannel32, EffectStream effectStream, TrackRequest trackRequest) { for (var i = 0; i < waveChannel32.WaveFormat.Channels; i++) { if (trackRequest.Echo) { if (trackRequest.EchoLength > 0) { if (trackRequest.EchoFactor > 0) { effectStream.Effects.Add(new Echo(trackRequest.EchoLength, trackRequest.EchoFactor)); } else { effectStream.Effects.Add(new Echo(trackRequest.EchoLength)); } } else { effectStream.Effects.Add(new Echo()); } } else if (trackRequest.Reverb) { effectStream.Effects.Add(new Reverb()); } } }
public void Play(IntPtr handle) { effectStream = new EffectStream(effects, outStream); CreatePlayer(); player.Init(effectStream); player.Play(); }
public void ConnectToSkpe() { Stop(); DisconnectFromSkype(); interceptor = new SkypeConnector(log, effects); effectStream = interceptor.OutputStream; }
public void Play() { effectStream = new EffectStream(outStream.ToSampleProvider()); effectStream.UpdateEffectChain(effectChain.ToArray()); CreatePlayer(); player.Init(effectStream); player.Play(); }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { FOutput.SliceCount = SpreadMax; if (effect != null) { if (FInStream[0] != effect.SourceStream) { effect.SourceStream = FInStream[0]; } } else if (FInStream[0] != null) { effect = new EffectStream(FInStream[0], 20000, 0.5f); } if (FOutput[0] != this) { FOutput[0] = this; } //FLogger.Log(LogType.Debug, "hi tty!"); }
public PlaybackMixer(WaveFormat waveFormat) { /* * var mmFmt = outputDevice.AudioClient.MixFormat; * WaveFormat = new WaveFormat(mmFmt.SampleRate, mmFmt.BitsPerSample <= 16 ? mmFmt.BitsPerSample : 16, mmFmt.Channels); */ WaveFormat = waveFormat; mixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(WaveFormat.SampleRate, WaveFormat.Channels)); mixer.ReadFully = true; // convert to 32 bit floating point bufferStream32 = new Pcm16BitToSampleProvider(mixer.ToWaveProvider16()); // pass through the effects effectStream = new EffectStream(bufferStream32); //effectStream.UpdateEffectChain(effects.ToArray()); }
public AudioPipeline(EffectChain effects) { // Audio pipeline: // get the audio from Skype this.bufferStream = new SkypeBufferProvider(16000); // convert to 32 bit floating point var bufferStream32 = new Pcm16BitToSampleProvider(bufferStream); // pass through the effects var effectStream = new EffectStream(bufferStream32); // now mix in any sound effects mixer = new MixingSampleProvider(effectStream.WaveFormat); mixer.AddMixerInput(effectStream); // and convert back to 16 bit ready to be given back to skype outputProvider = new SampleToWaveProvider16(mixer); effects.Modified += (s, a) => effectStream.UpdateEffectChain(effects.ToArray()); }
private void passThroughEffectToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "*.wav|*.wav"; if (openFileDialog.ShowDialog() == DialogResult.OK) { using (WaveFileReader reader = new WaveFileReader(openFileDialog.FileName)) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "*.wav|*.wav"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { string fileName = saveFileDialog.FileName; EffectStream effectStream = new EffectStream(new PitchDown(), reader); WaveFileWriter.CreateWaveFile(fileName, effectStream); System.Diagnostics.Process.Start(fileName); } } } }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { FOutput.SliceCount = SpreadMax; if (effect != null) { if (Fc1.IsChanged) effect.c1 = Fc1[0]; if (Fc2.IsChanged) effect.c2 = Fc2[0]; if (Fc3.IsChanged) effect.c3 = Fc3[0]; if (FInStream[0] != effect.SourceStream) { effect.SourceStream = FInStream[0]; } } else if (FInStream[0] != null) { effect = new EffectStream(FInStream[0], 2000, 0.5f, Fc1[0], Fc2[0], Fc3[0]); } if (FOutput[0] != this) { FOutput[0] = this; } //FLogger.Log(LogType.Debug, "hi tty!"); }
public SkypeConnector(ILog log, EffectChain effects) { this.log = log; InitSockets(); skype = new Skype(); ISkype iSkype = (ISkype)skype; if (!iSkype.Client.IsRunning) { log.Error("Skype is not running"); } _ISkypeEvents_Event events = (_ISkypeEvents_Event)skype; events.AttachmentStatus += OnSkypeAttachmentStatus; skype.CallStatus += OnSkypeCallStatus; skype.Error += OnSkypeError; skype.Attach(Protocol, false); bufferStream = new SkypeBufferStream(44100); OutputStream = new EffectStream(effects, bufferStream); }
public void PlaySound(AudioService audioService, IAudioClient audioClient, TrackRequest trackRequest) { var channels = audioService.Config.Channels; var timePlayed = 0; var outFormat = new WaveFormat(48000, 16, channels); SetVolumeOfCurrentTrack(trackRequest.Volume); using (var audioFileStream = new MediaFoundationReader(trackRequest.Track.Path)) using (var waveChannel32 = new WaveChannel32(audioFileStream, (_volumeOverride > 0 ? _volumeOverride : _volume) * 0.2f, 0f) { PadWithZeroes = false }) using (var effectStream = new EffectStream(waveChannel32)) using (var blockAlignmentStream = new BlockAlignReductionStream(effectStream)) using (var resampler = new MediaFoundationResampler(blockAlignmentStream, outFormat)) { resampler.ResamplerQuality = 60; ApplyEffects(waveChannel32, effectStream, trackRequest); // Establish the size of our AudioBuffer var blockSize = outFormat.AverageBytesPerSecond / 50; var buffer = new byte[blockSize]; int byteCount; // Read audio into our buffer, and keep a loop open while data is present while ((byteCount = resampler.Read(buffer, 0, blockSize)) > 0) { waveChannel32.Volume = (_volumeOverride > 0 ? _volumeOverride : _volume) * 0.2f; // Limit play length (--length) timePlayed += byteCount * 1000 / outFormat.AverageBytesPerSecond; if (trackRequest.TimeLimit > 0 && timePlayed > trackRequest.TimeLimit) { break; } if (byteCount < blockSize) { // Incomplete Frame for (var i = byteCount; i < blockSize; i++) { buffer[i] = 0; } } if (audioClient.State == ConnectionState.Disconnected || Stop) { break; } // Send the buffer to Discord try { audioClient.Send(buffer, 0, blockSize); } catch (Exception) { break; } } MyLogger.WriteLine("Voice finished enqueuing", ConsoleColor.Green); } if (Stop) { audioClient.Clear(); Stop = false; } audioClient.Wait(); }