Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion native-bridge/src/effects/granular_delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl GranularDelay {
// Find inactive grain slot index
let slot_idx = self.grains.iter().position(|g| !g.active);
if let Some(idx) = slot_idx {
let delay_samples = (self.sample_rate as f32 * self.settings.delay_time / 1000.0) as usize;
let delay_samples = (self.sample_rate as f32 * self.settings.position / 1000.0) as usize;
let grain_size = self.window.len();

// Add texture randomization (generate randoms before borrowing grain)
Expand Down
64 changes: 54 additions & 10 deletions native-bridge/src/effects/harmonizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Creates up to 3 additional voices at scale-correct intervals.

use super::pitch::{key_to_offset, PitchDetector, PitchShifter, Scale};
use super::types::{HarmonizerSettings, HarmonyType, PitchCorrectionScale};
use super::types::{HarmonizerScale, HarmonizerSettings, HarmonyType};
use super::AudioEffect;

/// A single harmony voice
Expand Down Expand Up @@ -100,15 +100,8 @@ impl Harmonizer {
// Update key/scale
self.key_offset = key_to_offset(&settings.key);
self.scale = match settings.scale {
PitchCorrectionScale::Major => Scale::Major,
PitchCorrectionScale::Minor => Scale::Minor,
PitchCorrectionScale::PentatonicMajor => Scale::PentatonicMajor,
PitchCorrectionScale::PentatonicMinor => Scale::PentatonicMinor,
PitchCorrectionScale::Blues => Scale::Blues,
PitchCorrectionScale::Dorian => Scale::Dorian,
PitchCorrectionScale::Mixolydian => Scale::Mixolydian,
PitchCorrectionScale::HarmonicMinor => Scale::HarmonicMinor,
_ => Scale::Chromatic,
HarmonizerScale::Major => Scale::Major,
HarmonizerScale::Minor => Scale::Minor,
};

// Set up voices based on harmony type
Expand Down Expand Up @@ -139,20 +132,62 @@ impl Harmonizer {
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::MinorThird => {
self.voice1.interval = 3; // Minor third
self.voice1.level = 0.7;
self.voice1.enabled = true;
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::Fourth => {
self.voice1.interval = 5; // Perfect fourth
self.voice1.level = 0.7;
self.voice1.enabled = true;
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::Fifth => {
self.voice1.interval = 7; // Perfect fifth
self.voice1.level = 0.7;
self.voice1.enabled = true;
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::Sixth => {
self.voice1.interval = 9; // Major sixth
self.voice1.level = 0.7;
self.voice1.enabled = true;
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::Octave => {
self.voice1.interval = 12;
self.voice1.level = 0.5;
self.voice1.enabled = true;
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::ThirdBelow => {
self.voice1.interval = -4; // Major third below
self.voice1.level = 0.7;
self.voice1.enabled = true;
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::FifthBelow => {
self.voice1.interval = -7; // Perfect fifth below
self.voice1.level = 0.7;
self.voice1.enabled = true;
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::OctaveBelow => {
self.voice1.interval = -12;
self.voice1.level = 0.5;
self.voice1.enabled = true;
self.voice2.enabled = false;
self.voice3.enabled = false;
}
HarmonyType::PowerChord => {
self.voice1.interval = 7;
self.voice1.level = 0.7;
Expand Down Expand Up @@ -180,6 +215,15 @@ impl Harmonizer {
self.voice2.enabled = true;
self.voice3.enabled = false;
}
HarmonyType::ThirdAndFifth => {
self.voice1.interval = 4; // Major third
self.voice1.level = 0.6;
self.voice1.enabled = true;
self.voice2.interval = 7; // Perfect fifth
self.voice2.level = 0.6;
self.voice2.enabled = true;
self.voice3.enabled = false;
}
HarmonyType::Custom => {
// Custom intervals are set via voice settings
}
Expand Down
1 change: 1 addition & 0 deletions native-bridge/src/effects/multi_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl MultiFilter {
MultiFilterType::Highpass => BiquadType::Highpass,
MultiFilterType::Bandpass => BiquadType::Bandpass,
MultiFilterType::Notch => BiquadType::Notch,
MultiFilterType::Allpass => BiquadType::Allpass,
MultiFilterType::Formant => BiquadType::Peak, // Approximate formant with peak
}
}
Expand Down
1 change: 1 addition & 0 deletions native-bridge/src/effects/rotary_speaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl RotarySpeaker {
RotarySpeed::Stop => (0.0, 0.0),
RotarySpeed::Slow => (settings.slow_rate, settings.slow_rate * 0.85), // Drum slightly slower
RotarySpeed::Fast => (settings.fast_rate, settings.fast_rate * 0.85),
RotarySpeed::Brake => (0.0, 0.0), // Brake slows to stop (handled by acceleration ramp)
};

self.horn.set_speed(horn_speed);
Expand Down
2 changes: 2 additions & 0 deletions native-bridge/src/effects/vibrato.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ impl Vibrato {
let waveform = match settings.waveform {
VibratoWaveform::Sine => LfoWaveform::Sine,
VibratoWaveform::Triangle => LfoWaveform::Triangle,
VibratoWaveform::Square => LfoWaveform::Square,
VibratoWaveform::Sawtooth => LfoWaveform::Sawtooth,
};
self.lfo.set_waveform(waveform);
self.settings = settings;
Expand Down
Loading