| 58 | } |
| 59 | |
| 60 | getSamples(buffer, count) { // always returns signed 16-bit sample values |
| 61 | this.samples -= count; |
| 62 | if (this.samples < 0) |
| 63 | throw Error("out of samples"); |
| 64 | |
| 65 | count *= this.numChannels; |
| 66 | let i = 0; |
| 67 | if (16 === this.bitsPerSample) { |
| 68 | while (count--) |
| 69 | buffer[i++] = this.readInt16(); |
| 70 | } |
| 71 | else |
| 72 | if (8 === this.bitsPerSample) { |
| 73 | while (count--) { |
| 74 | let value = this.readInt8(); |
| 75 | buffer[i++] = value << 8; // write Uint8 representation of value into low bits |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | readFourCC() { |
| 81 | let result = String.fromCharCode(this.wav.getUint8(this.position), this.wav.getUint8(this.position + 1), |