Do not require 48KHz
This commit is contained in:
parent
6f26dced64
commit
7bf03b02ae
10
blarf.js
10
blarf.js
@ -17,14 +17,17 @@
|
||||
|
||||
var AudCtx
|
||||
var AudScript
|
||||
var AudHz
|
||||
|
||||
function create_audio(hz, channels) {
|
||||
if(AudCtx) {
|
||||
AudCtx.close()
|
||||
}
|
||||
|
||||
AudHz = hz
|
||||
|
||||
AudCtx = new AudioContext({sampleRate: hz})
|
||||
AudScript = AudCtx.createScriptProcessor(1024, 2, 2)
|
||||
AudScript = AudCtx.createScriptProcessor(1024, channels, channels)
|
||||
AudScript.onaudioprocess = function(e) {
|
||||
var outL = e.outputBuffer.getChannelData(0)
|
||||
var outR = channels > 1 ? e.outputBuffer.getChannelData(1) : null
|
||||
@ -106,7 +109,7 @@
|
||||
if(AudCtx && AudCtx.state != "running") {
|
||||
var durationInAudioQueue = AudioQueue.length ? AudioQueue.reduce((acc, el) => acc + el.left.length, 0) : 0
|
||||
|
||||
var durationToRemove = Math.max(durationInAudioQueue - (VideoQueue.length ? (VideoQueue[VideoQueue.length - 1].t - VideoQueue[0].t) : 0) * 48, 0)
|
||||
var durationToRemove = Math.max(durationInAudioQueue - (VideoQueue.length ? (VideoQueue[VideoQueue.length - 1].t - VideoQueue[0].t) : 0) * AudHz / 1000, 0)
|
||||
|
||||
while(AudioQueue.length && durationToRemove) {
|
||||
var amount = Math.min(durationToRemove, AudioQueue[0].left.length)
|
||||
@ -137,7 +140,7 @@
|
||||
text = text + k + ":" + (Math.floor(100 * Statistics[k].sum / Statistics[k].count) / 100) + ","
|
||||
}
|
||||
stats.innerText = text*/
|
||||
stats.innerHTML = (VideoQueue.length ? (VideoQueue[VideoQueue.length - 1].t - VideoQueue[0].t) : "0") + "v" + (AudioQueue.reduce(function(acc, obj) {return acc + obj.left.length / 48}, 0)|0) + "a"
|
||||
stats.innerHTML = (VideoQueue.length ? (VideoQueue[VideoQueue.length - 1].t - VideoQueue[0].t) : "0") + "v" + (AudioQueue.reduce(function(acc, obj) {return acc + obj.left.length * AudHz / 1000}, 0)|0) + "a"
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,7 +293,6 @@
|
||||
}
|
||||
|
||||
ondata(elID, data) {
|
||||
if(EBMLParser.vi_to_i(data) == 48000) debugger
|
||||
if(elID == 0xD7) {
|
||||
// Track Entry -> Track Number
|
||||
this.tracks[this.tracks.length - 1].id = EBMLParser.vi_to_i(data)
|
||||
|
Loading…
Reference in New Issue
Block a user