Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************
- ** **
- ** Codesnippets written by Madwin for MMP 2023 **
- ** **
- ** Not to be used freely. the code still has errors **
- ** It's intended to be used as starting point. **
- ** Code has not been checked and might still need **
- ** (a lot of) work. **
- ** **
- ** © MadMedia Productions 2023 **
- ** **
- ***********************************************************/
- // C# class that emulates a Boss CE-2w Chorus pedal using the
- // CSCore library to process live audio input in real-time:
- using CSCore;
- using CSCore.DSP;
- using CSCore.SoundIn;
- using CSCore.Streams;
- using CSCore.Streams.Effects;
- public class BossCE2wChorus
- {
- private readonly IWaveSource _waveSource;
- private readonly Chorus _chorus;
- public BossCE2wChorus(IWaveSource waveSource)
- {
- _waveSource = waveSource;
- // Set up the chorus effect
- _chorus = new Chorus
- {
- WetDryMix = 0.5f,
- Depth = 0.1f,
- Feedback = 0.1f,
- Frequency = 0.3f,
- Delay = 0.003f,
- };
- }
- public IWaveSource GetOutputSource()
- {
- // Apply the chorus effect to the input source and return the output
- return new DmoEffectStream(_waveSource, _chorus.ToDmoProvider(), DmoStreamFlags.None);
- }
- }
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- // Here's an example of how you could use this class to process
- // live audio input in real-time:
- using CSCore;
- using CSCore.CoreAudioAPI;
- using CSCore.SoundIn;
- using CSCore.Streams;
- public static class Program
- {
- public static void Main()
- {
- // Set up the audio capture device
- var captureDevice = new WasapiCapture(true, AudioClientShareMode.Shared, 100);
- // Set up the output device
- var playbackDevice = new WasapiOut();
- // Set up the chorus effect
- var chorus = new BossCE2wChorus(captureDevice);
- // Set up the output source
- var outputSource = new SingleBlockNotificationStream(chorus.GetOutputSource());
- // Start capturing and playing back audio
- captureDevice.Initialize();
- captureDevice.Start();
- playbackDevice.Initialize(outputSource);
- playbackDevice.Play();
- // Wait for the user to press a key
- Console.ReadKey();
- // Stop capturing and playing back audio
- captureDevice.Stop();
- captureDevice.Dispose();
- playbackDevice.Stop();
- playbackDevice.Dispose();
- }
- }
- /*
- This example sets up a live audio capture device using the CSCore library, applies the Boss CE-2w Chorus effect to the captured audio in real-time using the BossCE2wChorus class we defined earlier, and plays back the processed audio using another CSCore device. Note that this example only captures and plays back audio for a short period of time in response to a user key press, but you could easily modify it to capture and play back audio indefinitely.
- */
Advertisement
Add Comment
Please, Sign In to add comment