MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / getReadFunction

Function getReadFunction

src/audio_data.ts:379–394  ·  view source on GitHub ↗
(format: AudioSampleFormat)

Source from the content-addressed store, hash-verified

377};
378
379const getReadFunction = (format: AudioSampleFormat): (view: DataView, offset: number) => number => {
380 switch (format) {
381 case 'u8':
382 case 'u8-planar':
383 return (view, offset) => (view.getUint8(offset) - 128) / 128;
384 case 's16':
385 case 's16-planar':
386 return (view, offset) => view.getInt16(offset, true) / 32768;
387 case 's32':
388 case 's32-planar':
389 return (view, offset) => view.getInt32(offset, true) / 2147483648;
390 case 'f32':
391 case 'f32-planar':
392 return (view, offset) => view.getFloat32(offset, true);
393 }
394};
395
396const getWriteFunction = (format: AudioSampleFormat): (view: DataView, offset: number, value: number) => void => {
397 switch (format) {

Callers 1

copyToMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected