grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.59k stars 325 forks source link

Rust backend does not support -double. #999

Closed magnetophon closed 9 months ago

magnetophon commented 9 months ago

When I try to compile process = _,_; with faust2jackrust -double test.dsp, I get:

error[E0308]: arguments to this method are incorrect
   --> src/main.rs:255:13
    |
255 |         dsp.compute(in_a_p.len() as i32, inputs, outputs);
    |             ^^^^^^^                      ------  ------- expected `&mut [&mut [f64]]`, found `&mut [&mut [f32]; 2]`
    |                                          |
    |                                          expected `&[&[f64]]`, found `&[&[f32]; 2]`
    |
    = note: expected reference `&[&[f64]]`
               found reference `&[&[f32]; 2]`
    = note: expected mutable reference `&mut [&mut [f64]]`
               found mutable reference `&mut [&mut [f32]; 2]`
note: method defined here
   --> src/main.rs:77:8
    |
77  |     fn compute(&mut self, count: i32, inputs: &[&[Self::T]], outputs: &mut[&mut[Self::T]]);
    |        ^^^^^^^

I'm working on a project that needs -double to function properly: https://github.com/magnetophon/lamb-rs so I would love to see this fixed! :)

sletz commented 9 months ago

Yes, the architecture file currently only support f32, since JACK port are float, see: https://github.com/grame-cncm/faust/blob/master-dev/architecture/jack.rs#L144

I guess the f32 buffers would need to be converted to f64 in this case, and since @magnetophon you are a Rust guru, maybe you can make this work and prepare a PR ?

BTW, same issue for PortAudio architecture, see: https://github.com/grame-cncm/faust/blob/master-dev/architecture/portaudio.rs#L161

sletz commented 9 months ago

Done in https://github.com/grame-cncm/faust/commit/81249c1e6edb4e0dcaf490731b0da4ada74925ce

magnetophon commented 9 months ago

Merci beaucoup, that was very fast!