MCPcopy Create free account
hub / github.com/dashnowords/imfe / floatTo16BitPCM

Function floatTo16BitPCM

chapter19/recorder-modified.js:177–182  ·  view source on GitHub ↗
(output, offset, input)

Source from the content-addressed store, hash-verified

175 }
176
177 function floatTo16BitPCM(output, offset, input) {
178 for (var i = 0; i < input.length; i++, offset += 2) {
179 var s = Math.max(-1, Math.min(1, input[i]));
180 output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true);
181 }
182 }
183
184 function writeString(view, offset, string) {
185 for (var i = 0; i < string.length; i++) {

Callers 1

encodeWAVFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected