@@ -30,6 +30,7 @@ import { IEncryptedFile } from "matrix-js-sdk/src/@types/event";
3030import { uploadFile } from "../ContentMessages" ;
3131import { FixedRollingArray } from "../utils/FixedRollingArray" ;
3232import { clamp } from "../utils/numbers" ;
33+ import mxRecorderWorkletPath from "./RecorderWorklet" ;
3334
3435const CHANNELS = 1 ; // stereo isn't important
3536export const SAMPLE_RATE = 48000 ; // 48khz is what WebRTC uses. 12khz is where we lose quality.
@@ -113,16 +114,10 @@ export class VoiceRecording extends EventEmitter implements IDestroyable {
113114 } ) ;
114115 this . recorderSource = this . recorderContext . createMediaStreamSource ( this . recorderStream ) ;
115116
116- // Set up our worklet. We use this for timing information and waveform analysis: the
117- // web audio API prefers this be done async to avoid holding the main thread with math.
118- const mxRecorderWorkletPath = document . body . dataset . vectorRecorderWorkletScript ;
119- if ( ! mxRecorderWorkletPath ) {
120- // noinspection ExceptionCaughtLocallyJS
121- throw new Error ( "Unable to create recorder: no worklet script registered" ) ;
122- }
123-
124117 // Connect our inputs and outputs
125118 if ( this . recorderContext . audioWorklet ) {
119+ // Set up our worklet. We use this for timing information and waveform analysis: the
120+ // web audio API prefers this be done async to avoid holding the main thread with math.
126121 await this . recorderContext . audioWorklet . addModule ( mxRecorderWorkletPath ) ;
127122 this . recorderWorklet = new AudioWorkletNode ( this . recorderContext , WORKLET_NAME ) ;
128123 this . recorderSource . connect ( this . recorderWorklet ) ;
0 commit comments