Bug 251350

Summary: The PCM data that get from audioWorklet is less than the SampleRate i set
Product: WebKit Reporter: 294434941
Component: Web AudioAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Major CC: cdumez, jer.noble, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: iPhone / iPad   
OS: iOS 16   
Attachments:
Description Flags
the pcmdata i record,sanplerate is 8000, channels is 1, type is 16bitInt
none
test demo none

294434941
Reported 2023-01-30 01:09:18 PST
if I get PCM data by AudioWorkletNode in ios, i find the actual PCM data is less than i set. For example, if i set SampleRate 8000, but Per second i get the PCM data is 6016. Especially, if i set 16000, i get 12032. #Step# Firstly, I use MediaDevices.getUserMedia() to get MediaStream; Secondly, I using new window.AudioContext() to creat AudioContext instance and set the SampleRate of AudioContext; Thirdly, I use AudioContext.createMediaStreamSource() to creat audioInputNode by MediaStream and AudioContext; Fourthly, I use AudioWorkletNode() and audioWorklet to creat AudioWorkletNode, in AudioWorkletNode i use this.port.postMessage() to post PCM data. #Hardware and Version# I test my demo in Safari on ipone with IOS 15.6, 16.1 and 16.2 all find this bug, then in safari16.2 on MacOs is ok. #Code# //audioPcmProces.js class VoiceDataGet extends AudioWorkletProcessor { constructor() { super(); } process (inputList, outputList, parameters) { const output = outputList[0]; const input = inputList[0]; if(inputList.length>0&&inputList[0].length>0){ this.port.postMessage(inputList[0]); } return true; } } registerProcessor('audioPcmProces', VoiceDataGet) /**************************************************************************************/ //auidoprocess.js this.aduiocontext = new (window.AudioContext || window.webkitAudioContext)({sampleRate:this.config.outputSampleRate}); //set sampleRate this.audioInputNode = this.aduiocontext.createMediaStreamSource(this.stream); await this.aduiocontext.audioWorklet.addModule('audioPcmProces.js'); this.workNode = new AudioWorkletNode(this.aduiocontext, 'audioPcmProces'); var messagePort = this.workNode.port; messagePort.onmessage = (e) => { var channelData = e.data; transPcm(channelData); } this.audioInputNode.connect(this.workNode);
Attachments
the pcmdata i record,sanplerate is 8000, channels is 1, type is 16bitInt (1.53 MB, application/octet-stream)
2023-01-30 19:40 PST, 294434941
no flags
test demo (27.37 KB, application/x-zip-compressed)
2023-01-30 23:07 PST, 294434941
no flags
294434941
Comment 1 2023-01-30 19:40:59 PST
Created attachment 464773 [details] the pcmdata i record,sanplerate is 8000, channels is 1, type is 16bitInt the pcmdata i post in attachment, the data is cut off when i get
294434941
Comment 2 2023-01-30 23:07:42 PST
Created attachment 464777 [details] test demo getting and recording PCM data which is 8000 samplerate and Float32Array
Radar WebKit Bug Importer
Comment 3 2023-02-06 01:10:16 PST
Note You need to log in before you can comment on or make changes to this bug.