语言

Menu
Sites
Language
Can we capture and manipulate audio data from TIZEN mic ?

Hi, everybody

Can we capture and manipulate audio data from TIZEN mic ? I tried as following:

 

--------------------------------------------------------------------------------

 

---- main.js ----

var g_soundmeter = null;

$(document).ready(function () {

    // webkit shim

    window.AudioContext = window.AudioContext || window.webkitAudioContext;

    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;

    window.URL = window.URL || window.webkitURL;

 

    g_soundmeter = new SoundMeter(onAudioProcess);

});

 

function onAudioProcess(e) {

   var i, s, v;

    var sdata = e.inputBuffer.getChannelData(0);

   for (i=0; i < len; i++) {

      s = sdata[i];

       if (s !=0 ) console.log("s = " + s);}

});

----- soundmeter.js ------

SoundMeter = function(cbAudioProcess) {

this._cbAudioProcess = cbAudioProcess;

this._isRecording = false;

this.context = null;

this.node = null;

    navigator.getUserMedia({audio: true}, this.startUserMedia.bind(this), function(e) {

        console.log('No live audio input: ' + e);

      });

}

 

SoundMeter.prototype.startUserMedia = function(stream) {

this._isRecording = true;

this.context = new AudioContext();

var input = this.context.createMediaStreamSource(stream);

    var bufferLen = 4096;

    this.node = this.context.createScriptProcessor(bufferLen, 2, 2);

    this.node.onaudioprocess = this._cbAudioProcess;

 

    input.connect(this.node);

    this.node.connect(this.context.destination);

}

 

--------------------------------------------------------------------------------

This steps into onAudioProcess callback function, but I can not see any log-string "s=....",   sdata array is full of zeros(0)

Is it right that TIZEN supports "Web Audio API" completely now ?

 

Urgently help me, please.

Regards.

Adal.

 

编辑者为: Brock Boland 17 3月, 2014 原因: Paragraph tags added automatically from tizen_format_fix module.

响应

5 回复
Raghavendra Reddy Shiva
Hello Adal, As per the Tizen 2.0 Magnolia release notes, the Web Audio API is Partially supported. And this 2.0 release has added "HTML Media Capture" support. (This HTML form extension enables users to access a device's media capture mechanism, such as a camera or microphone, from a file upload control) If you are on chrome (either Mac, Windows,Linux OS), you might need to enable live audio input, when using getUserMedia() and the Web Audio API. Please check if its enabled in "chrome://flags" (look for , Web Audio Input). Thanks
Raghavendra Reddy Shiva
Also suggest, to check for the microphone's sampling rate ( 48000 Hz for Wav).
Adal San
Thanks for you comment, Raghavendra. I am working with TIZEN Web , not TIZEN Native. I haven't yet experienced in TIZEN Native, but I will try.
Adal San
Thanks for your help, Raghavendra. It's fact - current TIZEN Web App programming does not support Web-Audio-API partially, so we can not measure the power of sound. Then, can we capture the sound from microphone and measure the power of sound ? TIZEN Native App programming supports these functions completely ? Looking forward to your reply asap. Regards.
Raghavendra Reddy Shiva
Sorry for the partial support of Web-Audio-API. ANd hope the full support should be provided soon. As of now , there are no specific Tizen api's supported for measuring the power of sound from web apps point of view. Please post your Query in "Native Application Development" section of Forum for Native side queries.