Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to compile the wasm example...issue #803

Open
zeukterialpneumaion opened this issue Oct 15, 2023 · 1 comment
Open

trying to compile the wasm example...issue #803

zeukterialpneumaion opened this issue Oct 15, 2023 · 1 comment

Comments

@zeukterialpneumaion
Copy link

zeukterialpneumaion commented Oct 15, 2023

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 */)
|
error[E0038]: the trait Sample cannot be made into an object
--> src\lib.rs:76:24
|
76 | let value: T = cpal::Sample::from::(&next_sample());
| ^^^^^^^^^^^^ 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::(&next_sample());
| ^^^^^^^^^^^^
|
help: add dyn keyword before this trait
|
76 | let value: T = ::from::(&next_sample());
| ++++ +


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!

@gitsmol
Copy link

gitsmol commented Feb 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants