extendable-media-recorder-wav-encoder-worker
Version:
The worker which is used by the extendable-media-recorder-wav-encoder package.
26 lines (18 loc) • 844 B
text/typescript
import { TCreateOrUpdateRecordingFactory } from '../types';
export const createCreateOrUpdateRecording: TCreateOrUpdateRecordingFactory = (recordings) => {
return (recordingId, sampleRate, typedArrays) => {
const recording = recordings.get(recordingId);
if (recording === undefined) {
const newRecording = {
channelDataArrays: typedArrays.map((typedArray) => [typedArray]),
isComplete: true,
sampleRate
};
recordings.set(recordingId, newRecording);
return newRecording;
}
// @todo Check if the given sampleRate is the same as the one of the recording.
recording.channelDataArrays.forEach((channelDataArray, index) => channelDataArray.push(typedArrays[index]));
return recording;
};
};