Question: How do you use getDecodedData? #2932
-
I recently converted tot he beta version. I was using exportPCM to get the peak data. I converted to getDecodedData as instructed. But I don't understand how to use it now.. Here is the js code: wavesurfer.getDecodedData().then( send json data to service api to save on disc); I am getting an error "wavesurfer.getDecodedData(...).then is not a function". This worked with exportPCM. Could use some guidance on what I need to change with the Beta version to get this to work... Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
It’s a synchronous function, just assign it to a variable like so: const data = wavesurfer.getDecodedData() Keep in mind it’s an AudioBuffer that is returned. So to get the peaks: const peaks = data.getChannelData(0) |
Beta Was this translation helpful? Give feedback.
-
@katspaugh - So I have been messing around to get this to work for a couple of days. Here is the code snippet.. However, when the post occurs, the value of the parameter MyJson is null. So something is happening with the json string being passed. I can pass the word "test" just fine... You'll notice I write the data to the log. This looks like a valid JSON object. This code worked fine when exportPCM function was in the library. What am I missing??
|
Beta Was this translation helpful? Give feedback.
Appreciate the feedback!
1. Load, URL and peaks
Regarding the
url
andpeaks
properties, both can be passed as either a create option or as arguments to load.As
create
options:As
load
arguments:2. Exporting peaks
Yes, correct, you can pass
channelData
arrays directly as peaks, one array per channel.E.g.