devalang_core/core/audio/engine/notes/
mod.rs

1use devalang_types::Value;
2use std::collections::HashMap;
3
4pub mod dsp;
5pub mod params;
6
7// Minimal safe facade: parse the setup then call DSP renderer.
8
9pub fn insert_note_impl(
10    engine: &mut crate::core::audio::engine::AudioEngine,
11    owner: Option<String>,
12    waveform: String,
13    freq: f32,
14    amp: f32,
15    start_time_ms: f32,
16    duration_ms: f32,
17    synth_params: HashMap<String, Value>,
18    note_params: HashMap<String, Value>,
19    automation: Option<HashMap<String, Value>>,
20) -> Vec<(usize, usize)> {
21    let setup = params::build_note_setup(
22        engine,
23        &waveform,
24        freq,
25        amp,
26        start_time_ms,
27        duration_ms,
28        &synth_params,
29        &note_params,
30        &automation,
31    );
32
33    let ranges = dsp::render_notes_into_buffer(
34        engine,
35        &waveform,
36        freq,
37        amp,
38        start_time_ms,
39        duration_ms,
40        synth_params,
41        note_params,
42        automation,
43        setup,
44    );
45
46    if let Some(owner_name) = owner {
47        for (start, len) in ranges.iter() {
48            engine.record_last_note_range(&owner_name, *start, *len);
49        }
50    }
51
52    ranges
53}