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.16k stars 277 forks source link

Does peak.js work with raw json object directly? #426

Closed shahul-vm closed 2 years ago

shahul-vm commented 2 years ago

Does peak.js work with raw JSON objects not the data URI data directly?

chrisn commented 2 years ago

Yes, it should be possible to use JSON directly:

const myWaveformData = {
  sample_rate: 44100,
  samples_per_pixel: 256,
  bits: 8,
  length: 4,
  data: [0,3,0,3,-1,6,-8,11]
};

const options = {
  // other options as needed

  waveformData: {
    json: myWaveformData
  }
};

Peaks.init(options, (err, peaks) => {
  // etc
});