Synthesizers
Generate audio from oscillators, FM synthesis, physical modeling, and more.
SubtractiveSynth
SubtractiveSynth
CoreClassic subtractive synthesis with oscillators, filters, ADSR envelope, and LFO modulation.
Constructor Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| sample_rate | int | 44100 | Audio sample rate in Hz |
Oscillator Properties
| Property | Type | Default | Description |
|---|---|---|---|
| osc_wave | str | "sine" | Waveform: "sine", "square", "saw", "triangle", "pwm", "wavetable" |
| pwm_depth | float | 0.5 | Pulse width for PWM waveform (0-1) |
| wavetable | np.array | None | Custom wavetable array for "wavetable" mode |
ADSR Envelope Properties
| Property | Type | Default | Description |
|---|---|---|---|
| attack | float | 0.01 | Attack time in seconds |
| decay | float | 0.1 | Decay time in seconds |
| sustain | float | 0.7 | Sustain level (0-1) |
| release | float | 0.2 | Release time in seconds |
Filter Properties
| Property | Type | Default | Description |
|---|---|---|---|
| filter_type | str | "lowpass" | "lowpass", "highpass", or "bandpass" |
| filter_cutoff | float | 1000 | Cutoff frequency in Hz (50-5000) |
| filter_resonance | float | 0.7 | Resonance amount (0-5) |
| filter_q | float | 1.0 | Q factor (0.1-10) |
LFO Properties
| Property | Type | Default | Description |
|---|---|---|---|
| lfo_freq | float | 5.0 | LFO frequency in Hz |
| lfo_depth | float | 0.2 | LFO modulation depth (0-1) |
| lfo_target | str | "filter" | "filter", "pitch", or "amplitude" |
Example Usage
from audio_dsp.synth import SubtractiveSynth
import soundfile as sf
# Create synth with sawtooth oscillator
synth = SubtractiveSynth(sample_rate=44100)
synth.osc_wave = "saw"
# Configure filter
synth.filter_type = "lowpass"
synth.filter_cutoff = 800
synth.filter_resonance = 2.0
# Configure envelope
synth.attack = 0.05
synth.decay = 0.2
synth.sustain = 0.6
synth.release = 0.5
# Add LFO modulation to filter
synth.lfo_target = "filter"
synth.lfo_freq = 3.0
synth.lfo_depth = 0.4
# Synthesize a note
audio = synth.synthesize(freq=220, duration=2.0)
sf.write("subtractive_synth.wav", audio, 44100)
DX7FMSynth
DX7FMSynth
CoreYamaha DX7-inspired FM synthesis with 4 operators, 5 algorithms, and per-operator envelopes.
Constructor / Properties
| Property | Type | Default | Description |
|---|---|---|---|
| algorithm | int | 1 | FM algorithm (1-5) |
| freq_ratios | list[float] | [1.0, 2.0, 1.0, 0.5] | Frequency ratio for each of 4 operators |
| mod_indices | list[float] | [1.0, 1.0, 1.0, 1.0] | Modulation index for each operator |
| feedback | float | 0.0 | Op4 feedback amount (0-5) |
| adsr | list[dict] | see below | ADSR envelope per operator |
FM Algorithms
| Algorithm | Structure | Description |
|---|---|---|
| 1 | Op4 → Op3 → Op2 → Op1 | Linear carrier chain |
| 2 | (Op4 → Op3) + (Op2 → Op1) | Two parallel chains mixed |
| 3 | (Op4 + Op3) → Op2 → Op1 | Dual modulators into chain |
| 4 | Op4 → (Op3 + Op2) → Op1 | Split modulation |
| 5 | Op4 + Op3 + Op2 + Op1 | All operators independent (additive) |
Example Usage
from audio_dsp.synth import DX7FMSynth
import soundfile as sf
# Create FM synth
synth = DX7FMSynth()
# Configure operator ratios (harmonic series)
synth.freq_ratios = [1.0, 2.0, 3.0, 4.0]
# Set modulation indices
synth.mod_indices = [1.0, 2.0, 1.5, 0.5]
# Add feedback for richness
synth.feedback = 1.0
# Synthesize with algorithm 3
audio = synth.synthesize(freq=110, duration=2.0, algorithm=3)
sf.write("fm_synth.wav", audio, 44100)
# Electric piano style
synth.freq_ratios = [1.0, 1.0, 7.0, 14.0]
synth.mod_indices = [1.0, 0.5, 2.0, 1.0]
audio = synth.synthesize(freq=440, duration=1.5, algorithm=2)
SuperStackedSynth
SuperStackedSynth
CoreMassive unison synth with up to 10,000 detuned oscillators for huge, lush sounds.
Synthesize Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| base_freq | float | required | Central frequency in Hz |
| duration | float | required | Length in seconds |
| num_oscillators | int | 100 | Number of oscillators (1-10000) |
| detune_spread | float | 0.02 | Max detune amount (0.02 = ±2%) |
| wave_mix | dict | equal mix | Waveform weights {"sine": 1, "saw": 1, ...} |
| fade_in_time | float | 0.1 | Staggered fade-in per oscillator |
| output_file | str | "super_synth.wav" | Output file path |
Example Usage
from audio_dsp.synth import SuperStackedSynth
synth = SuperStackedSynth()
# Massive pad sound
synth.synthesize(
base_freq=220,
duration=5.0,
num_oscillators=200,
detune_spread=0.03,
wave_mix={"saw": 1.0, "square": 0.3},
output_file="massive_pad.wav"
)
# Subtle chorus effect
synth.synthesize(
base_freq=440,
duration=3.0,
num_oscillators=20,
detune_spread=0.005,
wave_mix={"sine": 1.0},
output_file="subtle_chorus.wav"
)
DrumSynth
DrumSynth
CoreSynthesize kicks, snares, cymbals, claps, rims, and toms with pitch sweeps and layering.
kick()
| Parameter | Type | Default | Description |
|---|---|---|---|
| length | float | 0.5 | Duration in seconds |
| max_pitch | float | 1000 | Starting pitch in Hz |
| min_pitch | float | 50 | Ending pitch in Hz |
| decay_factor | float | 10 | Amplitude decay speed |
| signal_mix | str | "sine:1.0" | Waveform mix "sine:1.0,fm:0.3" |
snare()
| Parameter | Type | Default | Description |
|---|---|---|---|
| length | float | 0.3 | Duration in seconds |
| high_pitch | float | 300 | High tone frequency |
| low_pitch | float | 150 | Low tone frequency |
| mix | float | 0.5 | Noise vs tone balance (0-1) |
| signal_mix | str | "sine:1.0" | Waveform mix for tone |
cymbal()
| Parameter | Type | Default | Description |
|---|---|---|---|
| length | float | 1.0 | Duration in seconds |
| op_a_freq | float | 587 | FM operator A frequency |
| op_b_freq | float | 845 | FM operator B frequency |
| noise_env | float | 5 | Noise decay envelope |
| tone_env | float | 10 | Tone decay envelope |
| cutoff | float | 8000 | Filter cutoff Hz |
| mix | float | 0.5 | Noise/tone mix (0-1) |
clap()
| Parameter | Type | Default | Description |
|---|---|---|---|
| length | float | 0.3 | Duration in seconds |
| pitch | float | 1000 | Tone frequency |
| burst_count | int | 3 | Number of burst hits |
| noise_mix | float | 0.8 | Noise/tone mix (0-1) |
tom() / rim()
Similar parameters to kick/snare with pitch sweep and noise mix controls.
Example Usage
from audio_dsp.synth import DrumSynth
import soundfile as sf
import numpy as np
drums = DrumSynth()
# Create a punchy kick
kick = drums.kick(
length=0.5,
max_pitch=800,
min_pitch=40,
decay_factor=15,
signal_mix="sine:1.0,fm:0.2"
)
# Crispy snare
snare = drums.snare(
length=0.25,
high_pitch=350,
low_pitch=180,
mix=0.6
)
# Hi-hat cymbal
hihat = drums.cymbal(
length=0.15,
cutoff=10000,
mix=0.3
)
# Combine into a pattern
pattern = np.concatenate([kick, snare, hihat, hihat])
sf.write("drum_pattern.wav", pattern, 44100)
Pluck Synth (Karplus-Strong)
generate_string_pluck
synth.pluckPhysical modeling string synthesis using Karplus-Strong algorithm with extended parameters.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| length | float | required | Duration in seconds |
| frequency | float | required | Note frequency in Hz |
| intensity | float | 1.0 | Pluck amplitude |
| damping | float | 0.5 | 0=bright, 1=dark (0-1) |
| brightness | float | 0.5 | Filter brightness (0-1) |
| mute_strength | float | 0.5 | Palm muting amount (0-1) |
| pitch_bend | float | 0.5 | Pitch envelope amount (0-1) |
| pluck_position | float | 0.5 | Position along string (0-1) |
| plectrum_size | float | 0.5 | Pick size (0=small, 1=large) |
Example Usage
from audio_dsp.synth.pluck import generate_string_pluck
# Bright acoustic guitar pluck
generate_string_pluck(
output_file="guitar_pluck.wav",
length=2.0,
frequency=329.63, # E4
damping=0.3,
brightness=0.7,
pluck_position=0.2
)
# Muted bass string
generate_string_pluck(
output_file="bass_muted.wav",
length=1.0,
frequency=82.41, # E2
damping=0.7,
mute_strength=0.8,
plectrum_size=0.8
)
Physical Modeling Synth
PhysicalModelingSynth
synth.physical_modeling_synthExcite spectral models with extracted transients for realistic instrument synthesis.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| frequency | float | required | Target frequency in Hz |
| length | float | required | Duration in seconds |
| transient_file | str | required | Path to .transient JSON file |
| spectral_file | str | required | Path to .spectral JSON file |
| decay_rate | float | 0.5 | Body resonance decay speed |
Dialup Modem Synth
generate_56k_dialup
synth.dialup_synthGenerate randomized 56k modem handshake sounds with authentic phases.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| filename | str | "56k_dialup_random.wav" | Output file path |
| duration | float | 8.0 | Total duration in seconds |
| sample_rate | int | 44100 | Sample rate in Hz |
Example Usage
from audio_dsp.synth.dialup_synth import generate_56k_dialup
# Generate nostalgic dialup sounds
generate_56k_dialup(
filename="dialup.wav",
duration=10.0
)
Chip Tone Synths
ChipTone
synth.chip_tone8-bit retro chiptune synthesis with square waves, arpeggiation, and classic game sounds.
Example Usage
from audio_dsp.synth.chip_tone import ChipTone
chip = ChipTone()
# Generate 8-bit melody
chip.generate_melody(
notes=[440, 523, 587, 659],
durations=[0.2, 0.2, 0.2, 0.4],
output_file="chiptune.wav"
)