diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2013-03-13 17:18:47 -0400 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-15 11:53:15 -0700 |
commit | 316e63d84eda32cf99e62dc9d02de6e287ca8761 (patch) | |
tree | e5feb6d29d8f7648166c14842e40561a4bc340c1 /src/library_openal.js | |
parent | 85e45383d9d275f8726c7008639cbdefa5586bd9 (diff) |
Finish alSourcei, implement alSourcef and alSourceQueueBuffers
Diffstat (limited to 'src/library_openal.js')
-rw-r--r-- | src/library_openal.js | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/library_openal.js b/src/library_openal.js index 437c9f6f..9b2fde54 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -102,16 +102,60 @@ var LibraryOpenAL = { } switch (param) { case 0x1007 /* AL_LOOPING */: - AL.currentContext.src[source - 1].src.loop = (value != 0 /* AL_FALSE */); + AL.currentContext.src[source].src.loop = (value != 0 /* AL_FALSE */); break; case 0x1009 /* AL_BUFFER */: - AL.currentContext.src[source - 1].src.buffer = AL.currentContext.buf[value].buf; + AL.currentContext.src[source].src.buffer = AL.currentContext.buf[value].buf; break; default: console.log("alSourcei with param " + param + " not implemented yet"); break; } - // TODO: fill in the rest! + }, + + alSourcef: function(source, param, value) { + if (!AL.currentContext) { + consoue.error("alSourcef called without a valid context"); + return; + } + if (source >= AL.currentContext.src.length) { + console.error("alSourcef called with an invalid source"); + return; + } + switch (param) { + case 0x100A /* AL_GAIN */: + AL.currentContext.src[source].gain.gain.value = value; + break; + case 0x1003 /* AL_PITCH */: + console.log("alSourcef was called with AL_PITCH, but Web Audio does not support static pitch changes"); + break; + default: + console.log("alSourcef with param " + param + " not implemented yet"); + break; + } + }, + + alSourceQueueBuffers: function(source, count, buffers) { + if (!AL.currentContext) { + console.error("alSourceQueueBuffers called without a valid context"); + return; + } + if (source >= AL.currentContext.src.length) { + console.error("alSourceQueueBuffers called with an invalid source"); + return; + } + if (count != 1) { + console.error("Queuing multiple buffers using alSourceQueueBuffers is not supported yet"); + return; + } + for (var i = 0; i < count; ++i) { + var buffer = {{{ makeGetValue('buffers', 'i', 'i32') }}}; + if (buffer >= AL.currentContext.buf.length) { + console.error("alSourceQueueBuffers called with an invalid buffer"); + return; + } + AL.currentCOntext.src[source].src.buffer = AL.currentContext.buf[buffer].buf; + } }, alGenBuffers: function(count, buffers) { |