This commit is contained in:
2026-01-18 11:23:20 -06:00
parent 52da94c951
commit 9d722c59c2

View File

@@ -97,7 +97,7 @@ soundwave.create = function(opts) {
}
// Calculate frames
var bytes = pcm.length / 8 // blob.length is in bits
var bytes = length(pcm) / 8 // length(blob) is in bits
var frames = bytes / (player.channels * BYTES_PER_SAMPLE)
return {
@@ -186,7 +186,7 @@ soundwave.create = function(opts) {
// Remove finished voices
player.cleanup = function() {
var active = []
for (var i = 0; i < player.voices.length; i++) {
for (var i = 0; i < length(player.voices); i++) {
var v = player.voices[i]
var done = v.stopped || (!v.loop && v.pos >= v.source.frames)
if (!done) {
@@ -228,7 +228,7 @@ soundwave.create = function(opts) {
var blobs = []
var vols = []
for (var i = 0; i < player.voices.length; i++) {
for (var i = 0; i < length(player.voices); i++) {
var v = player.voices[i]
if (v.stopped) continue
var chunk = pull_voice_chunk(v, frames)
@@ -239,7 +239,7 @@ soundwave.create = function(opts) {
}
var mixed
if (blobs.length == 0) {
if (length(blobs) == 0) {
mixed = dsp.silence(frames, player.channels)
} else {
mixed = dsp.mix_blobs(blobs, vols)
@@ -251,7 +251,7 @@ soundwave.create = function(opts) {
// Convenience: get number of active voices
player.voice_count = function() {
return player.voices.length
return length(player.voices)
}
return player