Home > front end >  How to realize createScriptProcessor AudioWorkletNode and AudioWorkletProcessor transition
How to realize createScriptProcessor AudioWorkletNode and AudioWorkletProcessor transition

Time:05-13

Ladies and gentlemen, the previous project with createScriptProcessor to deal with audio,
But now find that it is disabled, the web has reminded,
Switch to
AudioWorkletProcessor AudioWorkletNode
After previous createScriptProcessor events, obtain data, access to, immediately can deal directly with,
AudioWorkletProcessor now, just a process, no events,
Excuse me, how can I put the inside of the sample data export to use under the framework of before,
Good understanding before: register event inside the main thread,
Recorder. Onaudioprocess=function (e) {
Save (e.i nputBuffer. GetChannelData (0));
};
AudioWorkletProcessor inside, however, only one process, someone out the data? Thank you,
The process (inputs, outputs, the parameters) {
Const input=inputs [0];
Const output=outputs [0];
Const gain=parameters. Gain;

For (let channel=0; The channel & lt; Input. Length; + + channel) {
Const inputChannel=input [channel].
Const outputChannel=output [channel].
If (gain. The length===1) {
For (the let I=0; i *=inputChannel outputChannel [I] [I] gain [0].
//this. Cb (inputChannel [I]);
Window. The recorder. AudioData. Input (inputChannel [I]);
}
} else {
For (the let I=0; i *=inputChannel outputChannel [I] [I] gain [I];
}
}

return true;
}
  • Related