Buffer Samplerate Javascript

AudioMatt's icon

AudioMatt

6月 16 2019 | 3:54 午前

I know this is silly but I nearly missed that I could deduce the sample rate of a buffer like this so for anyone searching in the future:

function bang(){
    var buf = new Buffer("myBuffer");
    post("samplerate: ",buf.samplerate(),"\n");
}
Buffer.prototype.samplerate = function(){
    return 1000*this.framecount()/this.length()
}

DominicThibault's icon

DominicThibault

8月 16 2024 | 3:42 午後

Thanks! This has proved useful!