frames var file = fileChooser.files[0]; new Mad.FileStream(file, function(input) { var mp3 = new Mad.MP3File(input); var mpeg = mp3.getMpegStream(); var frame = new Mad.Frame(); while (mpeg.error != Mad.Error.BUFLEN) { frame = Mad.Frame.decode(frame); } });
frame = /* … */; var synth = new Mad.Synth(); function refill(buffer) { // if current frame all used up, decode new one frame = Mad.Frame.decode(frame); // synthesize new one if needed synth.frame(frame); // copy samples from synth to buffer // (TypedArray.set or for loop) } var dev = Sink(refill, channels, bufsize, rate);