faust_types/
lib.rs

1#![allow(unused_parens)]
2#![allow(non_snake_case)]
3#![allow(non_camel_case_types)]
4#![allow(dead_code)]
5#![allow(unused_variables)]
6#![allow(unused_mut)]
7#![allow(non_upper_case_globals)]
8
9//! Faust JACK architecture file
10#[cfg(feature = "jack")]
11pub use libm;
12
13pub type F32 = f32;
14pub type F64 = f64;
15
16#[derive(Copy, Clone, Debug)]
17pub struct ParamIndex(pub i32);
18
19pub struct Soundfile<'a> {
20    fBuffers: &'a &'a F32,
21    fLength: &'a i32,
22    fSR: &'a i32,
23    fOffset: &'a i32,
24    fChannels: i32,
25}
26
27pub trait FaustDsp {
28    type T;
29
30    fn new() -> Self
31    where
32        Self: Sized;
33    fn metadata(&self, m: &mut dyn Meta);
34    fn get_sample_rate(&self) -> i32;
35    fn get_num_inputs(&self) -> i32;
36    fn get_num_outputs(&self) -> i32;
37    fn class_init(sample_rate: i32)
38    where
39        Self: Sized;
40    fn instance_reset_params(&mut self);
41    fn instance_clear(&mut self);
42    fn instance_constants(&mut self, sample_rate: i32);
43    fn instance_init(&mut self, sample_rate: i32);
44    fn init(&mut self, sample_rate: i32);
45    fn build_user_interface(&self, ui_interface: &mut dyn UI<Self::T>);
46    fn build_user_interface_static(ui_interface: &mut dyn UI<Self::T>)
47    where
48        Self: Sized;
49    fn get_param(&self, param: ParamIndex) -> Option<Self::T>;
50    fn set_param(&mut self, param: ParamIndex, value: Self::T);
51    fn compute(&mut self, count: i32, inputs: &[&[Self::T]], outputs: &mut [&mut [Self::T]]);
52
53    // NOTE:
54    // these seem to be created by the faust codegen,
55    // but are not present here? weird, investigate.
56    fn get_output_rate(&self, channel: i32) -> i32 {
57        1
58    }
59    fn get_input_rate(&self, channel: i32) -> i32 {
60        1
61    }
62}
63
64pub trait Meta {
65    // -- metadata declarations
66    fn declare(&mut self, key: &str, value: &str);
67}
68
69pub trait UI<T> {
70    // -- widget's layouts
71    fn open_tab_box(&mut self, label: &str);
72    fn open_horizontal_box(&mut self, label: &str);
73    fn open_vertical_box(&mut self, label: &str);
74    fn close_box(&mut self);
75
76    // -- active widgets
77    fn add_button(&mut self, label: &str, param: ParamIndex);
78    fn add_check_button(&mut self, label: &str, param: ParamIndex);
79    fn add_vertical_slider(
80        &mut self,
81        label: &str,
82        param: ParamIndex,
83        init: T,
84        min: T,
85        max: T,
86        step: T,
87    );
88    fn add_horizontal_slider(
89        &mut self,
90        label: &str,
91        param: ParamIndex,
92        init: T,
93        min: T,
94        max: T,
95        step: T,
96    );
97    fn add_num_entry(&mut self, label: &str, param: ParamIndex, init: T, min: T, max: T, step: T);
98
99    // -- passive widgets
100    fn add_horizontal_bargraph(&mut self, label: &str, param: ParamIndex, min: T, max: T);
101    fn add_vertical_bargraph(&mut self, label: &str, param: ParamIndex, min: T, max: T);
102
103    // -- metadata declarations
104    fn declare(&mut self, param: Option<ParamIndex>, key: &str, value: &str);
105}