A versatile audio synthesizer plugin that implements various waveform types and allows for dynamic parameter control.
src/lib.rs: Main plugin file, contains the plugin implementation and audio processing logic.params.rs: Defines the plugin parameters.synth/: Contains the waveform generation logic.
This guide explains in detail how to add a new synth type/engine/algorithm to the plugin.
- In the
src/synth/directory, create a new file for your synth algorithm, e.g.,custom_synth.rs. - Implement the
WaveformGeneratortrait for your new synth type:
use super::WaveformGenerator;
pub struct CustomSynth {
// Add any necessary fields for your synth
}
impl WaveformGenerator for CustomSynth {
fn generate(&self, phase: f32) -> f32 {
// Implement your custom waveform generation logic here
// The 'phase' parameter represents the current phase of the waveform (0 to 2π)
// Return a value between -1.0 and 1.0
// Example: Simple sine wave
phase.sin()
}
}- Open
src/params.rs. - Add your new synth type to the
Waveformenum:
#[derive(Enum, PartialEq, Clone, Copy)]
pub enum Waveform {
// Existing waveforms...
#[name = "Custom Synth"]
CustomSynth,
}- Open
src/synth/mod.rs. - Import your new synth type:
mod custom_synth;
use custom_synth::CustomSynth;- Update the
create_waveformfunction to include your new synth type:
pub fn create_waveform(waveform: Waveform) -> Arc<dyn WaveformGenerator + Send + Sync> {
match waveform {
// Existing waveforms...
Waveform::CustomSynth => Arc::new(CustomSynth::new()), // Assuming you have a new() method
}
}If your synth algorithm requires custom parameters:
- Add new parameters to
VariableSynthParamsinsrc/params.rs:
#[derive(Params)]
pub struct VariableSynthParams {
// Existing parameters...
#[id = "custom_param"]
pub custom_param: FloatParam,
}- Initialize the new parameter in the
Defaultimplementation:
impl Default for VariableSynthParams {
fn default() -> Self {
Self {
// Existing parameters...
custom_param: FloatParam::new(
"Custom Param",
0.5,
FloatRange::Linear { min: 0.0, max: 1.0 },
)
.with_smoother(SmoothingStyle::Linear(50.0)),
}
}
}After implementing the steps above, rebuild the project to test your new oscillator.
- Fork the repository.
- Create a feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
- Ensure Rust and Cargo are installed.
- Clone the repository:
git clone https://github.com/OseMine/variable-synth.git - Navigate to the project directory:
cd variable-synth - Install all necessary dependencies:
cargo fetch - Build the project:
cargo xtask bundle variable-synth --release - Find the plugin files in the
target/releasedirectory.
- Copy the created plugin files to your VST3/CLAP plugin directory.
- Load the plugin in your preferred DAW.