fix syntax
This commit is contained in:
21
sound.cm
21
sound.cm
@@ -35,16 +35,16 @@ var player = soundwave.create({
|
||||
|
||||
// Load and cache PCM data from a file path
|
||||
audio.pcm = function pcm(file) {
|
||||
file = res.find_sound(file)
|
||||
if (!file) return null
|
||||
|
||||
var path = res.find_sound(file)
|
||||
if (!path) return null
|
||||
|
||||
// Check player's cache first
|
||||
if (player.pcm_cache[file]) return player.pcm_cache[file]
|
||||
|
||||
var buf = io.slurp(file)
|
||||
if (player.pcm_cache[path]) return player.pcm_cache[path]
|
||||
|
||||
var buf = io.slurp(path)
|
||||
if (!buf) return null
|
||||
|
||||
return player.decode(buf, file)
|
||||
|
||||
return player.decode(buf, path)
|
||||
}
|
||||
|
||||
// Play a sound file, returns voice object
|
||||
@@ -73,11 +73,12 @@ feeder.resume_device()
|
||||
|
||||
// Audio pump - called periodically to fill the audio buffer
|
||||
function pump() {
|
||||
var mixed = null
|
||||
while (feeder.queued() < CHUNK_BYTES * 3) {
|
||||
var mixed = player.pull(FRAMES_PER_CHUNK)
|
||||
mixed = player.pull(FRAMES_PER_CHUNK)
|
||||
feeder.put(mixed)
|
||||
}
|
||||
|
||||
|
||||
$delay(pump, 1/240)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user