Formatting and indentation fixes
This commit is contained in:
parent
73fdd4b7eb
commit
1a72b01b31
22 changed files with 690 additions and 691 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
var SoundDecoder = function(wavFileData) {
|
||||
this.scratchSound = null;
|
||||
|
||||
|
||||
this.soundData = null;
|
||||
this.startOffset = 0;
|
||||
this.endOffset = 0;
|
||||
|
@ -37,10 +37,10 @@ var SoundDecoder = function(wavFileData) {
|
|||
this.thisSample = 0;
|
||||
|
||||
// decoder state
|
||||
this.sample = 0;
|
||||
this.sample = 0;
|
||||
this.index = 0;
|
||||
this.lastByte = -1; // -1 indicates that there is no saved lastByte
|
||||
|
||||
|
||||
this.nextSample = 0;
|
||||
|
||||
this.info = null;
|
||||
|
@ -61,12 +61,12 @@ var SoundDecoder = function(wavFileData) {
|
|||
if (info.bitsPerSample == 16) this.getSample = this.getSample16Uncompressed;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SoundDecoder.prototype.noteFinished = function() {
|
||||
// Called by subclasses to force ending condition to be true in writeSampleData()
|
||||
this.bytePosition = this.endOffset;
|
||||
}
|
||||
};
|
||||
|
||||
// Used for Notes and Drums - Web Audio API ScriptProcessorNodes use this
|
||||
// as a callback function to fill the buffers with sample data.
|
||||
|
@ -78,7 +78,7 @@ SoundDecoder.prototype.writeSampleData = function(evt) {
|
|||
var n = this.interpolatedSample();
|
||||
output[i] = n;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// For pre-caching the samples of WAV sounds
|
||||
// Return a full list of samples generated by the decoder.
|
||||
|
@ -90,7 +90,7 @@ SoundDecoder.prototype.getAllSamples = function() {
|
|||
smp = this.interpolatedSample();
|
||||
}
|
||||
return samples;
|
||||
}
|
||||
};
|
||||
|
||||
// Provide the next sample for the buffer
|
||||
SoundDecoder.prototype.interpolatedSample = function() {
|
||||
|
@ -101,11 +101,9 @@ SoundDecoder.prototype.interpolatedSample = function() {
|
|||
this.fraction -= 1.0;
|
||||
}
|
||||
if (this.nextSample == null) { return null; }
|
||||
var out = (this.fraction == 0) ?
|
||||
this.thisSample :
|
||||
this.thisSample + (this.fraction * (this.nextSample - this.thisSample));
|
||||
return (out) / 32768.0;
|
||||
}
|
||||
var out = this.fraction == 0 ? this.thisSample : this.thisSample + this.fraction * (this.nextSample - this.thisSample);
|
||||
return out / 32768.0;
|
||||
};
|
||||
|
||||
// 16-bit samples, big-endian
|
||||
SoundDecoder.prototype.getSample16Uncompressed = function() {
|
||||
|
@ -119,13 +117,13 @@ SoundDecoder.prototype.getSample16Uncompressed = function() {
|
|||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
// 8-bit samples, uncompressed
|
||||
SoundDecoder.prototype.getSample8Uncompressed = function() {
|
||||
if (this.bytePosition >= this.info.sampleDataSize) return null;
|
||||
return (this.soundData[this.bytePosition++] - 128) << 8;
|
||||
}
|
||||
};
|
||||
|
||||
/*SoundDecoder.prototype.updateVolume = function() {
|
||||
if (this.client == null) {
|
||||
|
@ -149,13 +147,13 @@ SoundDecoder.stepTable = [
|
|||
12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
|
||||
];
|
||||
|
||||
SoundDecoder.prototype.getSampleADPCM = function() {
|
||||
SoundDecoder.prototype.getSampleADPCM = function() {
|
||||
// Decompress sample data using the IMA ADPCM algorithm.
|
||||
// Note: Handles only one channel, 4-bits/sample.
|
||||
// Note: Handles only one channel, 4-bits/sample.
|
||||
var step = 0, code = 0, delta = 0;
|
||||
|
||||
if (((this.bytePosition % this.adpcmBlockSize) == 0) && (this.lastByte < 0)) { // read block header
|
||||
if (this.bytePosition > (this.info.sampleDataSize - 4)) return null;
|
||||
|
||||
if (this.bytePosition % this.adpcmBlockSize == 0 && this.lastByte < 0) { // read block header
|
||||
if (this.bytePosition > this.info.sampleDataSize - 4) return null;
|
||||
this.sample = (this.soundData[this.bytePosition + 1] << 8) + this.soundData[this.bytePosition];
|
||||
if (this.sample > 32767) this.sample -= 65536;
|
||||
this.index = this.soundData[this.bytePosition + 2];
|
||||
|
@ -184,7 +182,7 @@ SoundDecoder.prototype.getSampleADPCM = function() {
|
|||
if (this.index > 88) this.index = 88;
|
||||
if (this.index < 0) this.index = 0;
|
||||
// compute and output sample
|
||||
this.sample += ((code & 8) ? -delta : delta);
|
||||
this.sample += code & 8 ? -delta : delta;
|
||||
if (this.sample > 32767) this.sample = 32767;
|
||||
if (this.sample < -32768) this.sample = -32768;
|
||||
return this.sample;
|
||||
|
|
Reference in a new issue