// // nitroAudio.js //-------------------- // Provides an interface for playing nds music and sound effects. // by RHY3756547 // window.AudioContext = window.AudioContext || window.webkitAudioContext; window.nitroAudio = new (function() { var t = this; var ctx; t.sounds = []; t.tick = tick; t.playSound = playSound; t.kill = kill; t.init = init; t.instaKill = instaKill; t.updateListener = updateListener; t.sdat = null; function init(sdat) { ctx = new AudioContext(); t.ctx = ctx; var listener = ctx.listener; listener.dopplerFactor = 1; listener.speedOfSound = 100/1024; //343.3 SSEQWaveCache.init(sdat, ctx); t.sdat = sdat; } function updateListener(pos, view) { var listener = ctx.listener; if (listener.positionX == null) { //use old setters. safari ios listener.setPosition(pos[0], pos[1], pos[2]); listener.setOrientation(view[8], -view[9], -view[10], view[4], view[5], view[6]); } else { listener.positionX.value = pos[0]; listener.positionY.value = pos[1]; listener.positionZ.value = pos[2]; listener.forwardX.value = view[8]; listener.forwardY.value = -view[9]; listener.forwardZ.value = -view[10]; listener.upX.value = view[4]; listener.upY.value = view[5]; listener.upZ.value = view[6]; } } function tick() { for (var i=0; i