Expose PCM data in Rust
This commit is contained in:
parent
a794e7fd28
commit
981426b681
|
@ -22,4 +22,5 @@ version = "0.3.44"
|
|||
features = [
|
||||
"console",
|
||||
"AudioContext",
|
||||
"AudioBuffer",
|
||||
]
|
||||
|
|
|
@ -64,7 +64,10 @@ impl Agent for AudioAgent {
|
|||
}
|
||||
}
|
||||
Msg::AudioDecoded(samples) => {
|
||||
ConsoleService::log(&format!("Success decoding: {:?}", samples));
|
||||
let audio_buffer = web_sys::AudioBuffer::from(samples);
|
||||
let data = audio_buffer.get_channel_data(0).unwrap(); // TODO: error handling
|
||||
let vec: Vec<f32> = data.to_vec();
|
||||
ConsoleService::log(&format!("Success decoding: {:?}", vec));
|
||||
}
|
||||
Msg::AudioDecodingFailed(err) => {
|
||||
ConsoleService::error(&format!("Error decoding: {:?}", err));
|
||||
|
|
Loading…
Reference in New Issue