diff --git a/Cargo.lock b/Cargo.lock index 59adaf29..de7d72dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,18 +77,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" -[[package]] -name = "alsa" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5915f52fe2cf65e83924d037b6c5290b7cee097c6b5c8700746e6168a343fd6b" -dependencies = [ - "alsa-sys", - "bitflags", - "libc", - "nix 0.23.2", -] - [[package]] name = "alsa" version = "0.7.0" @@ -123,9 +111,9 @@ dependencies = [ "jni-sys", "libc", "log", - "ndk 0.7.0", + "ndk", "ndk-context", - "ndk-sys 0.4.1+23.1.7779620", + "ndk-sys", "num_enum", ] @@ -375,12 +363,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base-x" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" - [[package]] name = "baseview" version = "0.1.0" @@ -803,10 +785,16 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ - "core-foundation-sys", + "core-foundation-sys 0.8.3", "libc", ] +[[package]] +name = "core-foundation-sys" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -852,11 +840,12 @@ dependencies = [ [[package]] name = "coreaudio-rs" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11894b20ebfe1ff903cbdc52259693389eea03b94918a2def2c30c3bf227ad88" +checksum = "cb17e2d1795b1996419648915df94bc7103c28f7b48062d7acf4652fc371b2ff" dependencies = [ "bitflags", + "core-foundation-sys 0.6.2", "coreaudio-sys", ] @@ -876,7 +865,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a7847ca018a67204508b77cb9e6de670125075f7464fff5f673023378fa34f5" dependencies = [ "core-foundation", - "core-foundation-sys", + "core-foundation-sys 0.8.3", "coremidi-sys", ] @@ -886,7 +875,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79a6deed0c97b2d40abbab77e4c97f81d71e162600423382c277dd640019116c" dependencies = [ - "core-foundation-sys", + "core-foundation-sys 0.8.3", ] [[package]] @@ -910,26 +899,28 @@ dependencies = [ [[package]] name = "cpal" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f342c1b63e185e9953584ff2199726bf53850d96610a310e3aca09e9405a2d0b" +checksum = "d34fa7b20adf588f73f094cd9b1d944977c686e37a2759ea217ab174f017e10a" dependencies = [ - "alsa 0.6.0", - "core-foundation-sys", + "alsa", + "core-foundation-sys 0.8.3", "coreaudio-rs", - "jni", + "dasp_sample", + "jni 0.19.0", "js-sys", "libc", "mach", - "ndk 0.7.0", + "ndk", "ndk-context", "oboe", "once_cell", "parking_lot 0.12.1", - "stdweb", "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", "web-sys", - "windows 0.37.0", + "windows 0.44.0", ] [[package]] @@ -1067,6 +1058,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + [[package]] name = "diopser" version = "0.4.0" @@ -1101,12 +1098,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "dispatch" version = "0.2.0" @@ -2041,6 +2032,20 @@ dependencies = [ "walkdir", ] +[[package]] +name = "jni" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + [[package]] name = "jni-sys" version = "0.3.0" @@ -2294,7 +2299,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a456444d83e7ead06ae6a5c0a215ed70282947ff3897fb45fcb052b757284731" dependencies = [ - "alsa 0.7.0", + "alsa", "bitflags", "coremidi", "js-sys", @@ -2340,19 +2345,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "ndk" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2032c77e030ddee34a6787a64166008da93f6a352b629261d0fee232b8742dd4" -dependencies = [ - "bitflags", - "jni-sys", - "ndk-sys 0.3.0", - "num_enum", - "thiserror", -] - [[package]] name = "ndk" version = "0.7.0" @@ -2361,7 +2353,7 @@ checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" dependencies = [ "bitflags", "jni-sys", - "ndk-sys 0.4.1+23.1.7779620", + "ndk-sys", "num_enum", "raw-window-handle 0.5.0", "thiserror", @@ -2373,15 +2365,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" -[[package]] -name = "ndk-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5a6ae77c8ee183dcbbba6150e2e6b9f3f4196a7666c02a715a95692ec1fa97" -dependencies = [ - "jni-sys", -] - [[package]] name = "ndk-sys" version = "0.4.1+23.1.7779620" @@ -2522,19 +2505,6 @@ dependencies = [ "memoffset 0.6.5", ] -[[package]] -name = "nix" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" -dependencies = [ - "bitflags", - "cc", - "cfg-if 1.0.0", - "libc", - "memoffset 0.6.5", -] - [[package]] name = "nix" version = "0.24.3" @@ -2732,12 +2702,12 @@ dependencies = [ [[package]] name = "oboe" -version = "0.4.6" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f63c358b4fa0fbcfefd7c8be5cfc39c08ce2389f5325687e7762a48d30a5c1" +checksum = "8868cc237ee02e2d9618539a23a8d228b9bb3fc2e7a5b11eed3831de77c395d0" dependencies = [ - "jni", - "ndk 0.6.0", + "jni 0.20.0", + "ndk", "ndk-context", "num-derive", "num-traits", @@ -2746,9 +2716,9 @@ dependencies = [ [[package]] name = "oboe-sys" -version = "0.4.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3370abb7372ed744232c12954d920d1a40f1c4686de9e79e800021ef492294bd" +checksum = "7f44155e7fb718d3cfddcf70690b2b51ac4412f347cd9e4fbe511abe9cd7b5f2" dependencies = [ "cc", ] @@ -2928,7 +2898,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39fe46acc5503595e5949c17b818714d26fdf9b4920eacf3b2947f0199f4a6ff" dependencies = [ - "rustc_version 0.3.3", + "rustc_version", ] [[package]] @@ -3401,15 +3371,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.3.3" @@ -3511,22 +3472,13 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser 0.7.0", -] - [[package]] name = "semver" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser 0.10.2", + "semver-parser", ] [[package]] @@ -3535,12 +3487,6 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "semver-parser" version = "0.10.2" @@ -3602,21 +3548,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - [[package]] name = "shlex" version = "1.1.0" @@ -3760,55 +3691,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version 0.2.3", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - [[package]] name = "stft" version = "0.1.0" @@ -4575,19 +4457,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647" -dependencies = [ - "windows_aarch64_msvc 0.37.0", - "windows_i686_gnu 0.37.0", - "windows_i686_msvc 0.37.0", - "windows_x86_64_gnu 0.37.0", - "windows_x86_64_msvc 0.37.0", -] - [[package]] name = "windows" version = "0.43.0" @@ -4595,12 +4464,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04662ed0e3e5630dfa9b26e4cb823b817f1a9addda855d973a9458c236556244" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc", ] [[package]] @@ -4619,12 +4488,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc", ] [[package]] @@ -4643,12 +4512,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc", ] [[package]] @@ -4657,48 +4526,24 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" -[[package]] -name = "windows_aarch64_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a" - [[package]] name = "windows_aarch64_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" -[[package]] -name = "windows_i686_gnu" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1" - [[package]] name = "windows_i686_gnu" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" -[[package]] -name = "windows_i686_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c" - [[package]] name = "windows_i686_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" -[[package]] -name = "windows_x86_64_gnu" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d" - [[package]] name = "windows_x86_64_gnu" version = "0.42.1" @@ -4711,12 +4556,6 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" -[[package]] -name = "windows_x86_64_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d" - [[package]] name = "windows_x86_64_msvc" version = "0.42.1" @@ -4739,7 +4578,7 @@ dependencies = [ "libc", "log", "mio", - "ndk 0.7.0", + "ndk", "objc2", "once_cell", "orbclient", diff --git a/Cargo.toml b/Cargo.toml index 26f308e4..015b585a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,7 +103,7 @@ assert_no_alloc = { git = "https://github.com/robbert-vdh/rust-assert-no-alloc.g baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "7001c2521fa1a439a01967cb881b411cd75d9ee0", features = ["opengl"], optional = true } # All the claps! clap = { version = "3.2", features = ["derive"], optional = true } -cpal = { version = "0.14.1", optional = true } +cpal = { version = "0.15", optional = true } jack = { version = "0.11.4", optional = true } midir = { version = "0.9.1", optional = true } rtrb = { version = "0.2.2", optional = true } diff --git a/src/wrapper/standalone/backend/cpal.rs b/src/wrapper/standalone/backend/cpal.rs index 888ed471..bd5a379f 100644 --- a/src/wrapper/standalone/backend/cpal.rs +++ b/src/wrapper/standalone/backend/cpal.rs @@ -1,7 +1,7 @@ use anyhow::{Context, Result}; use cpal::{ - traits::*, Device, InputCallbackInfo, OutputCallbackInfo, Sample, SampleFormat, Stream, - StreamConfig, + traits::*, Device, FromSample, InputCallbackInfo, OutputCallbackInfo, Sample, SampleFormat, + Stream, StreamConfig, }; use crossbeam::sync::{Parker, Unparker}; use midir::{ @@ -129,23 +129,32 @@ impl Backend

for CpalMidir { } }; - let stream = match input.sample_format { - SampleFormat::I16 => input.device.build_input_stream( - &input.config, - self.build_input_data_callback::(input_unparker, rb_producer), - error_cb, - ), - SampleFormat::U16 => input.device.build_input_stream( - &input.config, - self.build_input_data_callback::(input_unparker, rb_producer), - error_cb, - ), - SampleFormat::F32 => input.device.build_input_stream( - &input.config, - self.build_input_data_callback::(input_unparker, rb_producer), - error_cb, - ), + macro_rules! build_input_streams { + ($sample_format:expr, $(($format:path, $primitive_type:ty)),*) => { + match $sample_format { + $($format => input.device.build_input_stream( + &input.config, + self.build_input_data_callback::<$primitive_type>(input_unparker, rb_producer), + error_cb, + None, + ),)* + format => todo!("Unsupported sample format {format}"), + } + } } + let stream = build_input_streams!( + input.sample_format, + (SampleFormat::I8, i8), + (SampleFormat::I16, i16), + (SampleFormat::I32, i32), + (SampleFormat::I64, i64), + (SampleFormat::U8, u8), + (SampleFormat::U16, u16), + (SampleFormat::U32, u32), + (SampleFormat::U64, u64), + (SampleFormat::F32, f32), + (SampleFormat::F64, f64) + ) .expect("Fatal error creating the capture stream"); stream .play() @@ -263,43 +272,40 @@ impl Backend

for CpalMidir { } }; - let output_stream = match self.output.sample_format { - SampleFormat::I16 => self.output.device.build_output_stream( - &self.output.config, - self.build_output_data_callback::( - unparker, - input_rb_consumer, - midi_input_rb_consumer, - // This is a MPMC crossbeam channel instead of an rtrb ringbuffer, and we - // also need it to terminate the thread - midi_output_rb_producer.clone(), - cb, - ), - error_cb, - ), - SampleFormat::U16 => self.output.device.build_output_stream( - &self.output.config, - self.build_output_data_callback::( - unparker, - input_rb_consumer, - midi_input_rb_consumer, - midi_output_rb_producer.clone(), - cb, - ), - error_cb, - ), - SampleFormat::F32 => self.output.device.build_output_stream( - &self.output.config, - self.build_output_data_callback::( - unparker, - input_rb_consumer, - midi_input_rb_consumer, - midi_output_rb_producer.clone(), - cb, - ), - error_cb, - ), + macro_rules! build_output_streams { + ($sample_format:expr, $(($format:path, $primitive_type:ty)),*) => { + match $sample_format { + $($format => self.output.device.build_output_stream( + &self.output.config, + self.build_output_data_callback::( + unparker, + input_rb_consumer, + midi_input_rb_consumer, + // This is a MPMC crossbeam channel instead of an rtrb ringbuffer, and we + // also need it to terminate the thread + midi_output_rb_producer.clone(), + cb, + ), + error_cb, + None, + ),)* + format => todo!("Unsupported sample format {format}"), + } + } } + let output_stream = build_output_streams!( + self.output.sample_format, + (SampleFormat::I8, i8), + (SampleFormat::I16, i16), + (SampleFormat::I32, i32), + (SampleFormat::I64, i64), + (SampleFormat::U8, u8), + (SampleFormat::U16, u16), + (SampleFormat::U32, u32), + (SampleFormat::U64, u64), + (SampleFormat::F32, f32), + (SampleFormat::F64, f64) + ) .expect("Fatal error creating the output stream"); // TODO: Wait a period before doing this when also reading the input @@ -445,7 +451,7 @@ impl CpalMidir { let input_config = StreamConfig { channels: input_config_range.channels(), sample_rate: requested_sample_rate, - buffer_size: requested_buffer_size.clone(), + buffer_size: requested_buffer_size, }; let input_sample_format = input_config_range.sample_format(); @@ -604,18 +610,24 @@ impl CpalMidir { }) } - fn build_input_data_callback( + fn build_input_data_callback( &self, input_unparker: Unparker, mut input_rb_producer: rtrb::Producer, - ) -> impl FnMut(&[T], &InputCallbackInfo) + Send + 'static { + ) -> impl FnMut(&[T], &InputCallbackInfo) + Send + 'static + where + T: Sample, + // The CPAL update make the whole interface more complicated by using dasp sample, and then + // they also forgot to expose the `ToSample` trait so now you need to do this + f32: FromSample, + { // This callback needs to copy input samples to a ring buffer that can be read from in the // output data callback move |data, _info| { for sample in data { // If for whatever reason the input callback is fired twice before an output // callback, then just spin on this until the push succeeds - while input_rb_producer.push(sample.to_f32()).is_err() {} + while input_rb_producer.push(sample.to_sample()).is_err() {} } // The run function is blocked until a single period has been processed here. After this @@ -640,7 +652,7 @@ impl CpalMidir { } } - fn build_output_data_callback( + fn build_output_data_callback( &self, unparker: Unparker, mut input_rb_consumer: Option>, @@ -655,7 +667,11 @@ impl CpalMidir { ) -> bool + 'static + Send, - ) -> impl FnMut(&mut [T], &OutputCallbackInfo) + Send + 'static { + ) -> impl FnMut(&mut [T], &OutputCallbackInfo) + Send + 'static + where + P: Plugin, + T: Sample + FromSample, + { // We'll receive interlaced input samples from CPAL. These need to converted to deinterlaced // channels, processed, and then copied those back to an interlaced buffer for the output. // This needs to be wrapped in a struct like this and boxed because the `channels` vectors @@ -849,7 +865,7 @@ impl CpalMidir { .iter_samples() .flat_map(|channels| channels.into_iter()), ) { - *output_sample = T::from(buffer_sample); + *output_sample = T::from_sample(*buffer_sample); } if let Some(output_event_rb_producer) = &mut output_event_rb_producer {