A modular synthesizer plugin based on AM/FM/PWM synthesis, developed using the NIH-plug framework.
-
Ensure you have Rust installed. If not, follow the instructions at rust-lang.org.
-
Clone the repository:
git clone https://github.com/OseMine/Am-Synth.git cd am-synth
-
Run
cargo fetch
to download all dependencies.
src/lib.rs
: Main plugin file, contains the plugin structure and logicsrc/params.rs
: Definition of plugin parameterssrc/util.rs
: Helper functions, e.g., MIDI note to frequency conversionsrc/filter.rs
: Implementation of filter algorithms (Moog and Roland style)src/bridge/
: Directory for bridge engines (e.g., AM, FM, PWM)src/synth/
: Directory for synth engines (e.g., Sine, Saw)
The plugin is based on a modular system with synth engines and bridge engines. Synth engines generate sounds, while bridge engines define the connection between two synth engines and determine how one operator affects another (amplitude, frequency, pulse width, etc.).
- Create a new file in
src/synth/
, e.g.,saw.rs
for a sawtooth wave:
use std::f32::consts::PI;
pub struct SawOscillator {
phase: f32,
frequency: f32,
sample_rate: f32,
}
impl SawOscillator {
pub fn new(sample_rate: f32) -> Self {
Self {
phase: 0.0,
frequency: 440.0,
sample_rate,
}
}
pub fn set_frequency(&mut self, freq: f32) {
self.frequency = freq;
}
pub fn generate(&mut self) -> f32 {
let output = 2.0 * (self.phase / PI) - 1.0;
self.phase += 2.0 * PI * self.frequency / self.sample_rate;
if self.phase >= 2.0 * PI {
self.phase -= 2.0 * PI;
}
output
}
}
- Add the new oscillator in
src/lib.rs
and use it in theVoice
structure.
- Create a new file in
src/bridge/
, e.g.,fm.rs
for frequency modulation:
pub struct FmBridge {
modulation_index: f32,
}
impl FmBridge {
pub fn new() -> Self {
Self {
modulation_index: 1.0,
}
}
pub fn set_modulation_index(&mut self, index: f32) {
self.modulation_index = index;
}
pub fn process(&self, carrier: f32, modulator: f32) -> f32 {
carrier * (1.0 + self.modulation_index * modulator)
}
}
- Add the new bridge in
src/lib.rs
and use it in theVoice
structure.
-
Run
cargo xtask bundle am_synth
to compile and bundle the plugin. -
Find the bundled plugin in the
target/bundled
directory.
- Implement additional synth engines (wavetable, sample playback, etc.)
- Add more bridge engines (PWM, ring modulation, etc.)
- Develop a user-friendly GUI for configuring the modular structure
- Implement preset management
- Add more effects (reverb, delay, etc.)
- Optimize performance for real-time audio processing
- Support for polyphony and various tuning systems
Contributions are welcome! Please create a pull request or open an issue if you want to suggest improvements or fix bugs.
For questions or support, please reach out to the project maintainer (@OseMine) by sending me A DM on Instagram (@the.muzikar or contacting via Email).