katspaugh / wavesurfer.js

Audio waveform player
https://wavesurfer.xyz
BSD 3-Clause "New" or "Revised" License
8.7k stars 1.62k forks source link

Exporting Filtered Audio Data As File #2100

Closed deju1980 closed 1 year ago

deju1980 commented 3 years ago

Hi,

I'm looking for a way to export filtered audio as a file. I currently have a web app with an eq, timestretch and pitch filters, and would like to create a file for download with these filters applied. I've managed to successfully create a wav file (using the following method: https://stackoverflow.com/questions/60079764/how-to-export-wavesurfer-js-as-audio-file), however the filters aren't applied to the output. Is there a way to do this with wavesurfer.js?

marizuccara commented 3 years ago

Hi, you can try to implement and use an AudioWorkletNode connected at the end of your audio graph (because at the end you have your filtered data). Then you can implement an AudioWorkletProcessor class. Processors have the advantage that run in an different worklet. Moreover, they have to implement a process method, which takes in input the raw audio data. You can manipulate these data or, in your case, send them back to your application (via messages) and use them to export an audio file.

https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Using_AudioWorklet

entonbiba commented 3 years ago

@deju1980 how are you applying the filters currently? The final node of the output you may get with the following which will return the AudioDestinationNode.

wavesurfer.backend.getAudioContext().destination
enischa commented 3 years ago

anyone find the solution? i need too :(