Skip to content

Commit 071afbf

Browse files
committed
audio.set_param
1 parent 6592876 commit 071afbf

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/host/audio.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,23 @@ fn add_node(state: &mut State, parent_id: u32, proc: Box<dyn firefly_audio::Proc
222222
}
223223
}
224224

225+
pub(crate) fn set_param(mut caller: C, node_id: u32, param: u32, val: f32) {
226+
let state = caller.data_mut();
227+
state.called = "audio.set_param";
228+
let node = match state.audio.get_node(node_id) {
229+
Ok(node) => node,
230+
Err(err) => {
231+
state.log_error(HostError::AudioNode(err));
232+
return;
233+
}
234+
};
235+
if param > 4 {
236+
state.log_error("param index is too high");
237+
return;
238+
}
239+
node.set(param as u8, val);
240+
}
241+
225242
/// Modulate a parameter of the given node using linear modulation.
226243
pub(crate) fn mod_linear(
227244
mut caller: C,
@@ -314,8 +331,8 @@ fn modulate(
314331
return;
315332
}
316333
};
317-
if param > 8 {
318-
state.log_error("param value is too high");
334+
if param > 4 {
335+
state.log_error("param index is too high");
319336
return;
320337
}
321338
node.modulate(param as u8, lfo, low, high);

src/linking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ fn select_audio_external<'a>(
117117
"reset" => Func::wrap(ctx, audio::reset),
118118
"reset_all" => Func::wrap(ctx, audio::reset_all),
119119
"clear" => Func::wrap(ctx, audio::clear),
120+
"set_param" => Func::wrap(ctx, audio::set_param),
120121

121122
// Processors.
122123
"add_all_for_one" => Func::wrap(ctx, audio::add_all_for_one),

0 commit comments

Comments
 (0)