pub struct AudioEngine {
pub volume: f32,
pub buffer: Vec<i16>,
pub midi_events: Vec<MidiNoteEvent>,
pub module_name: String,
pub note_count: usize,
pub sample_rate: u32,
pub channels: u16,
}Expand description
AudioEngine holds the generated interleaved stereo buffer and provides simple utilities to mix/merge buffers and export WAV files.
Notes:
- Buffer is interleaved stereo (L,R,L,R…).
- Methods are synchronous and operate on in-memory buffers.
Fields§
§volume: f32Master volume multiplier (not automatically applied by helpers).
buffer: Vec<i16>Interleaved i16 PCM buffer.
midi_events: Vec<MidiNoteEvent>Collected MIDI note events for export (non-audio representation).
module_name: StringLogical module name used for error traces/diagnostics.
note_count: usizeSimple diagnostic counter for inserted notes.
sample_rate: u32Sample rate (can be overridden per-engine)
channels: u16Number of channels (interleaved). Defaults to 2.
Implementations§
Source§impl AudioEngine
impl AudioEngine
pub fn new(module_name: String) -> Self
pub fn get_buffer(&self) -> &[i16]
pub fn get_normalized_buffer(&self) -> Vec<f32>
pub fn mix(&mut self, other: &AudioEngine)
pub fn merge_with(&mut self, other: AudioEngine)
pub fn set_duration(&mut self, duration_secs: f32)
pub fn generate_midi_file( &mut self, output_path: &String, bpm: Option<f32>, tpqn: Option<u16>, ) -> Result<(), String>
pub fn generate_wav_file( &mut self, output_dir: &String, audio_format: Option<String>, sample_rate: Option<u32>, ) -> Result<(), String>
pub fn insert_note( &mut self, waveform: String, freq: f32, amp: f32, start_time_ms: f32, duration_ms: f32, synth_params: HashMap<String, Value>, note_params: HashMap<String, Value>, automation: Option<HashMap<String, Value>>, )
Trait Implementations§
Source§impl Clone for AudioEngine
impl Clone for AudioEngine
Source§fn clone(&self) -> AudioEngine
fn clone(&self) -> AudioEngine
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AudioEngine
impl Debug for AudioEngine
Source§impl PartialEq for AudioEngine
impl PartialEq for AudioEngine
impl StructuralPartialEq for AudioEngine
Auto Trait Implementations§
impl Freeze for AudioEngine
impl RefUnwindSafe for AudioEngine
impl Send for AudioEngine
impl Sync for AudioEngine
impl Unpin for AudioEngine
impl UnwindSafe for AudioEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more