Skip to content

Save waveform from WebAudio processing #381

Answered by jgentes
jgentes asked this question in Q&A
Discussion options

You must be logged in to vote

For future readers, here's what I did to get this working:

import WaveformData from 'waveform-data'

const arrayBuffer = await file.arrayBuffer()
const audioCtx = new window.AudioContext()
const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer)

await new Promise<void>(resolve =>
  WaveformData.createFromAudio(
    {
      audio_context: audioCtx,
      audio_buffer: audioBuffer,
      scale: 64
    },
    (err, wave: WaveformData) => {
      if (err) throw err
      peakOptions.waveformData = { json: wave.toJSON() }
      resolve()
    }
  )
)

Peaks.init(peakOptions, .....)

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@jgentes
Comment options

@chrisn
Comment options

Comment options

You must be logged in to vote
1 reply
@chrisn
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jgentes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants