bbc / peaks.js

JavaScript UI component for interacting with audio waveforms
https://waveform.prototyping.bbc.co.uk
GNU Lesser General Public License v3.0
3.2k stars 279 forks source link

Retrieve the browser-generated waveform data as json to send back to the server? #473

Closed iandoesallthethings closed 1 year ago

iandoesallthethings commented 1 year ago

I'd like to implement automatic updates for new audio files. I.e. the first user to access a file would have to wait while the audio api generates the waveform, but then we just send the json back to the server and cache it there until the next time the audio file changes.

Is there a way to get the waveform data back out once it's generated in the browser?

chrisn commented 1 year ago

You can get the waveform data using peaksInstance.getWaveformData(). This is an undocumented method so not part of the public API, but there's no reason it couldn't be.

Refer to the API documentation for details of how to use the WaveformData object.

iandoesallthethings commented 1 year ago

Lovely, thank you!