WeiWeiXinNet/Games/game3/js/other/audioRunner.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
function AudioThread(NumChannels, SampleRate) {
this.NumChannels = NumChannels;
this.SampleRate = SampleRate;
this.BitsPerSample = (typeof arguments[2] == "number") ? arguments[2] : 16;
this.autoContinue = (typeof arguments[3] == "boolean" && arguments[3]) ? true : false;
this.type = 0; //0 - no support, 1 - WAVE PCM support
this.audioHandle;
this.waveHandle;
this.ended = false;
this.init = function () {
//Sanity Check
this.checkAudioSupport();
try {
switch (this.type) {
case 1:
//Note for canPlayType: WebKit *will* fail if it's not explicitly audio/wav (Tested w/ Safari 5)
//Another Note: WebKit used to reply "no" instead of an empty string as a response for non-support.
//Another Note: Google Chrome as of today writing this doesn't support WAV PCM through the data uri when injected into an audio object.
if (typeof this.audioHandle.canPlayType == "function") {
if (this.audioHandle.canPlayType("audio/wav") === "" || this.audioHandle.canPlayType("audio/wav") == "no") {
this.notSupported();
}
}
case 2:
this.waveHandle = new WAVEAudio(this.NumChannels, this.SampleRate, this.BitsPerSample);
break;
default:
this.notSupported();
}
}
catch (error) {
throw(new Error(error.message));
}
};
this.checkAudioSupport = function () {
try {
this.audioHandle = new Audio();
this.type = 1;
}
catch (error) {
throw(new Error("Could not find audio support."));
}
};
this.notSupported = function () {
this.type = 0;
throw(new Error("A generic audio error in AudioThread has been issued."));
};
this.init();
}
AudioThread.prototype.appendSample = function (sampleData) {
//Wrapped Buffer access
this.waveHandle.appendSample(sampleData, true);
}
AudioThread.prototype.appendBatch = function (sampleDataArray) {
//UNSAFE Batch array appending!
//You better know what you're doing!!!
var length = sampleDataArray.length;
var index = 0;
while (index < length) {
this.waveHandle.samples.push(this.waveHandle.convertRelativeUnits(sampleDataArray[index++]));
后面还有 35 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。