0

If I have an audio file in WAV format containing markers (or "cue points"), is there a way to get an array of those markers, preferably using the Web Audio API?

I seem to remember seeing a method to do so before, but I can't seem to find it.

Any help or suggestions would be great!

oguz ismail
  • 1
  • 16
  • 47
  • 69
MysteryPancake
  • 1,365
  • 1
  • 18
  • 47

2 Answers2

2

Web Audio API doesn't support parsing marker chunks ("cue "s) in WAVE-RIFF, only the audio data itself.

You'll have to parse and extract the marker chunks manually using for example typed arrays and DataView after loading the file as ArrayBuffer (unrelated to Web Audio API per-se).

It's a bit broad for giving a solution, but this article should be able to point you in the right direction as to how.

1

Today I stumbled across a repository which supports the retrieval of cue markers, along with a ton of other useful functionality. It works perfectly for what I was trying to do:

var request = new XMLHttpRequest();
request.open("GET", "file.wav", true);
request.responseType = "arraybuffer";
request.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200) {
        var wave = new WaveFile(new Uint8Array(this.response));
        console.log(wave.listCuePoints()); // Works perfectly
    }
};
request.send();

It works on the browser as well as on Node.js, which is fantastic!

MysteryPancake
  • 1,365
  • 1
  • 18
  • 47