[Webkit-unassigned] [Bug 251350] New: The PCM data that get from audioWorklet is less than the SampleRate i set

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jan 30 01:09:18 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=251350

            Bug ID: 251350
           Summary: The  PCM data that get from audioWorklet is less than
                    the SampleRate  i set
           Product: WebKit
           Version: Safari 16
          Hardware: iPhone / iPad
                OS: iOS 16
            Status: NEW
          Severity: Major
          Priority: P2
         Component: Web Audio
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: 294434941 at qq.com
                CC: cdumez at apple.com

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);

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230130/bf2c1c7a/attachment.htm>


More information about the webkit-unassigned mailing list