trying to compile the wasm example...issue
i am receiving the following errors when i try :: npm run start :: with the wasm example:
compiling hello_wasm v0.1.0 (C:\Users\Admin\Documents\ajhRust\Yew\ajhYewTree\hello_wasm)
error[E0277]: the trait bound T: SizedSample is not satisfied
--> src\lib.rs:61:10
|
61 | .build_output_stream(
| ^^^^^^^^^^^^^^^^^^^ the trait SizedSample is not implemented for T
|
note: required by a bound in build_output_stream
--> C:\Users\Admin.cargo\registry\src\index.crates.io-6f17d22bba15001f\cpal-0.15.2\src\traits.rs:161:12
|
153 | fn build_output_stream<T, D, E>(
| ------------------- required by a bound in this associated function
...
161 | T: SizedSample,
| ^^^^^^^^^^^ required by this bound in DeviceTrait::build_output_stream
help: consider further restricting this bound
|
46 | T: cpal::Sample + cpal::SizedSample,
| +++++++++++++++++++
error[E0061]: this method takes 4 arguments but 3 arguments were supplied
--> src\lib.rs:61:10
|
61 | .build_output_stream(
| __^^^^^^^^^^^^^^^^^^^-
62 | | config,
63 | | move |data: &mut [T], | write_data(data, channels, &mut next_value),
64 | | err_fn,
65 | | )
| |- an argument of type Option<Duration> is missing
|
note: method defined here
--> C:\Users\Admin.cargo\registry\src\index.crates.io-6f17d22bba15001f\cpal-0.15.2\src\traits.rs:153:8
|
153 | fn build_output_stream<T, D, E>(
| ^^^^^^^^^^^^^^^^^^^
help: provide the argument
|
61 | .build_output_stream(config, move |data: &mut [T], _| write_data(data, channels, &mut next_value), err_fn, /* Option<Duration> */)
|
error[E0038]: the trait Sample cannot be made into an object
--> src\lib.rs:76:24
|
76 | let value: T = cpal::Sample::from::Sample cannot be made into an object
|
6f17d22bba15001f\dasp_sample-0.11.0\src\lib.rs:39:34
|
39 | pub trait Sample: Copy + Clone + PartialOrd + PartialEq {
| ^^^^^^^^^^ ^^^^^^^^^ the trait cannot be made into an object because it uses Self as a type parameter
| |
| the trait cannot be made into an object because it uses Self as a type parameter
error[E0782]: trait objects must include the dyn keyword
--> src\lib.rs:76:24
|
76 | let value: T = cpal::Sample::from::dyn keyword before this trait
|
76 | let value: T = <dyn cpal::Sample>::from::
the first function requires another argument (a duration it seems) , and then there is an issue perhaps with context regarding Self... ...very interested in diving into your library but yes...thx!
I've encountered the same thing in my code. There have been some breaking changes in cpal.
If you carefully look at the beep example you will find that you need to specify T: SizedSample + FromSample<f32> in the function signatures for run and write_data. Furthermore, the write_data function now uses a slightly changed type conversion:
let value: T = T::from_sample(next_sample());
With these changes the example should compile.