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 **
- ** **
- ***********************************************************
- ***********************************************************
- ** **
- ** -- Disclaimer: -- **
- ** **
- ** If code is used in private projects and/or for **
- ** study purposes please mention resource. Any other **
- ** use -whether commercial or non-commercial- is not **
- ** condoned by the author and violates his intent. **
- ** **
- ** [email protected] **
- ** **
- ***********************************************************
- ***********************************************************/
- using CSCore;
- using CSCore.SoundIn;
- using CSCore.Streams;
- using CSCore.Streams.Effects;
- using CSCore.WaveTables;
- public class BossSY1Emulator
- {
- private ISoundIn soundIn;
- private IWaveSource waveSource;
- private ISampleSource sampleSource;
- private EffectChain effectChain;
- // Control parameters
- public float Effect { get; set; }
- public float Direct { get; set; }
- public float Tone { get; set; }
- public float Rate { get; set; }
- public float Depth { get; set; }
- public float Variation { get; set; }
- public int Type { get; set; } // 0 = Lead 1, 1 = Lead 2, 2 = Pad, 3 = Bass, 4 = STR, 5 = Organ, 6 = Bell, 7 = SFX 1, 8 = SFX 2, 9 = SEQ 1, 10 = SEQ 2
- public BossSY1Emulator()
- {
- soundIn = new WasapiLoopbackCapture();
- waveSource = new SoundInSource(soundIn);
- sampleSource = waveSource.ToSampleSource().ToStereo();
- effectChain = new EffectChain();
- // Add your desired effects here based on control parameters
- effectChain.Add(new DelayEffect { WetDryMix = Effect });
- effectChain.Add(new ToneFilter { CutOff = Tone });
- // Select sound type based on Type parameter
- switch (Type)
- {
- case 0: // Lead 1
- effectChain.Add(new SineGenerator(440f)); // Replace with your own lead 1 sound generator
- break;
- case 1: // Lead 2
- effectChain.Add(new SineGenerator(880f)); // Replace with your own lead 2 sound generator
- break;
- case 2: // Pad
- effectChain.Add(new SquareGenerator(440f)); // Replace with your own pad sound generator
- break;
- case 3: // Bass
- effectChain.Add(new SawtoothGenerator(220f)); // Replace with your own bass sound generator
- break;
- case 4: // STR
- effectChain.Add(new TriangleGenerator(440f)); // Replace with your own STR sound generator
- break;
- case 5: // Organ
- effectChain.Add(new SquareGenerator(440f)); // Replace with your own organ sound generator
- break;
- case 6: // Bell
- effectChain.Add(new SineGenerator(880f)); // Replace with your own bell sound generator
- break;
- case 7: // SFX 1
- effectChain.Add(new WhiteNoiseGenerator()); // Replace with your own SFX 1 sound generator
- break;
- case 8: // SFX 2
- effectChain.Add(new PinkNoiseGenerator()); // Replace with your own SFX 2 sound generator
- break;
- case 9: // SEQ 1
- effectChain.Add(new SawtoothGenerator(440f)); // Replace with your own SEQ 1 sound generator
- break;
- case 10: // SEQ 2
- effectChain.Add(new TriangleGenerator(440f)); // Replace with your own SEQ 2 sound generator
- break;
- default:
- break;
- }
- sampleSource = effectChain.ToSampleSource();
- }
- public void Start()
- {
- soundIn.Start();
- }
- public void Stop()
- {
- soundIn.Stop();
- }
- public ISampleSource GetOutputSource()
- {
- return sampleSource;
- }
- }
- /*
- I've added the control parameters (`Effect`, `Direct`, `Tone`, `Rate`, `Depth`, `Variation`, `Type`) as properties of the
- `BossSY1Emulator` class. You can set these parameters to adjust the behavior of the synthesizer emulation.
- The effects in the `effectChain` have been updated to include a `DelayEffect` with the `WetDryMix` parameter set to the
- `Effect` value, and a `ToneFilter` with the `CutOff` parameter set to the `Tone` value.
- Based on the `Type` parameter, the appropriate sound generator is added to the `effectChain`. You can replace the placeholder
- sound generators (`SineGenerator`, `SquareGenerator`, `SawtoothGenerator`, `TriangleGenerator`, `WhiteNoiseGenerator`,
- `PinkNoiseGenerator`) with your own implementation or use other sound generation techniques to create the desired synth sounds.
- Now you can create an instance of the `BossSY1Emulator` class, set the control parameters, and retrieve the output
- `ISampleSource` using the `GetOutputSource` method. This `ISampleSource` object can be used for real-time audio processing or playback.
- Remember to add the necessary CSCore NuGet package to your project. Additionally, make sure to replace the placeholder sound generators
- with your own sound generation logic or use appropriate libraries for generating the desired synth sounds.
- */
Advertisement
Add Comment
Please, Sign In to add comment