1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//! Advanced audio modulation effects for `OxiMedia`.
//!
//! This module provides production-quality implementations of classic
//! modulation effects used in music production and audio processing:
//!
//! # Effects
//!
//! - **Chorus** - Multi-voice chorus with LFO modulation for thicker, richer sounds
//! - **Flanger** - Short delay with feedback and LFO for jet-like sweeping sounds
//! - **Phaser** - All-pass filter cascade with LFO for frequency-dependent phase shifts
//!
//! # Common Infrastructure
//!
//! - **LFO** - Low-frequency oscillator with multiple waveforms (sine, triangle, sawtooth, square, random)
//! - **Delay Lines** - Fractional delay with interpolation for smooth modulation
//! - **All-pass Filters** - Phase-shifting filters for phaser effects
//! - **Parameter Smoothing** - Smooth parameter changes to avoid audio artifacts
//!
//! # Examples
//!
//! ## Chorus Effect
//!
//! ```ignore
//! use oximedia_audio::effects::{StereoChorus, ChorusConfig};
//!
//! let config = ChorusConfig::lush(); // 6-voice lush chorus preset
//! let mut chorus = StereoChorus::new(config, 48000.0);
//!
//! // Process stereo audio (planar format)
//! let mut left = vec![0.0; 1024];
//! let mut right = vec![0.0; 1024];
//! chorus.process_planar(&mut left, &mut right);
//! ```
//!
//! ## Flanger Effect
//!
//! ```ignore
//! use oximedia_audio::effects::{StereoFlanger, FlangerConfig};
//!
//! let config = FlangerConfig::jet(); // Fast, high-feedback jet preset
//! let mut flanger = StereoFlanger::new(config, 48000.0);
//!
//! // Process stereo audio (interleaved format)
//! let mut samples = vec![0.0; 2048];
//! flanger.process_interleaved(&mut samples, 1024);
//! ```
//!
//! ## Phaser Effect
//!
//! ```ignore
//! use oximedia_audio::effects::{StereoPhaser, PhaserConfig, LfoWaveform};
//!
//! let config = PhaserConfig::new(8, 0.5, 1.0) // 8 stages, 0.5 Hz, full depth
//! .with_resonance(0.7)
//! .with_waveform(LfoWaveform::Triangle);
//! let mut phaser = StereoPhaser::new(config, 48000.0);
//!
//! // Process mono audio
//! let mut samples = vec![0.0; 1024];
//! phaser.process(&mut samples);
//! ```
//!
//! ## Custom LFO
//!
//! ```ignore
//! use oximedia_audio::effects::{Lfo, LfoWaveform};
//!
//! let mut lfo = Lfo::new(2.0, 48000.0, LfoWaveform::Sine);
//!
//! for _ in 0..100 {
//! let value = lfo.next(); // Value between -1.0 and 1.0
//! println!("LFO: {}", value);
//! }
//! ```
//!
//! # Technical Details
//!
//! ## Chorus
//!
//! The chorus effect works by creating multiple delayed copies (voices) of the
//! input signal, each with a slightly different delay time that varies with an LFO.
//! This simulates the natural variations that occur when multiple musicians
//! play the same part together.
//!
//! Key features:
//! - 2-8 voices with independent LFO phases
//! - Configurable base delay (10-50ms) and modulation depth (0-20ms)
//! - Stereo spread control for wider stereo image
//! - Optional feedback for more pronounced effect
//! - Multiple waveform types for different modulation characteristics
//!
//! ## Flanger
//!
//! The flanger uses a very short delay line (0.5-10ms) with feedback, modulated
//! by an LFO. When the delayed signal is mixed with the original, it creates
//! a comb filter with moving notches that produce the characteristic sweeping sound.
//!
//! Key features:
//! - Short delay times for distinctive flanging sound
//! - Positive and negative feedback modes
//! - High feedback creates more pronounced resonant peaks
//! - Linear interpolation for smooth delay modulation
//! - Stereo processing with independent LFO phases
//!
//! ## Phaser
//!
//! The phaser uses a cascade of all-pass filters whose cutoff frequencies are
//! modulated by an LFO. Each all-pass filter introduces a frequency-dependent
//! phase shift. When the phase-shifted signal is mixed with the original,
//! notches appear in the frequency spectrum at points where the signals are
//! out of phase.
//!
//! Key features:
//! - Configurable number of stages (2-12, even numbers only)
//! - First-order all-pass filters for efficient processing
//! - Feedback/resonance control for more pronounced notches
//! - Wide frequency range (200-5000 Hz center, ±3000 Hz range)
//! - Positive and negative feedback modes
//!
//! ## LFO (Low-Frequency Oscillator)
//!
//! The LFO generates periodic control signals used to modulate effect parameters.
//! It supports multiple waveforms for different modulation characteristics:
//!
//! - **Sine**: Smooth, natural modulation
//! - **Triangle**: Linear rise and fall
//! - **Sawtooth**: Linear rise with instant reset (good for "barber pole" effects)
//! - **Square**: Instant switching (trill-like effects)
//! - **Random**: Stepped random values (sample-and-hold)
//!
//! ## Delay Lines
//!
//! The fractional delay line implementation supports reading at non-integer
//! delay times using interpolation:
//!
//! - **None**: Nearest sample (no interpolation)
//! - **Linear**: Linear interpolation between two samples
//! - **Cubic**: Hermite interpolation using four samples (higher quality)
//!
//! Linear interpolation provides a good balance between quality and performance
//! for most modulation effects.
//!
//! ## Parameter Smoothing
//!
//! All effects use parameter smoothers to avoid audio artifacts (clicks, pops)
//! when parameters change. The smoother uses a one-pole lowpass filter with
//! a configurable time constant (typically 10ms).
//!
//! # Performance
//!
//! All effects are optimized for real-time processing:
//!
//! - No dynamic allocations during processing
//! - Efficient circular buffer implementation for delay lines
//! - SIMD-friendly processing (single sample at a time or buffer-based)
//! - Minimal branching in inner loops
//!
//! # Thread Safety
//!
//! Effect processors are not `Send` or `Sync` by default. For multi-threaded
//! use, create separate effect instances per thread.
// Re-exports for convenience
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;