javascript - How can i play raw samples PCM_16 audio data record from Android in Web (using Web-Audio or other)? -


in app on android, use audiorecord , send continuouslly bytes array pcm_16 node.js server.

byte[] audiobuffer = new byte[maudiobuffersamplesize];     maudiorecord.startrecording();     int audiorecordingstate = maudiorecord.getrecordingstate();     if (audiorecordingstate != audiorecord.recordstate_recording) {         log.e(tag, "audiorecord not recording");         return;     } else {         log.v(tag, "audiorecord has started recording...");     }      while (inrecordmode) {         int samplesread = maudiorecord.read(audiobuffer, 0,                 maudiobuffersamplesize);         log.v(tag, "got samples: " + samplesread);         if (websocketmanager.roomsocket.isconnected()) {                         websocketmanager.roomsocket.send(audiobuffer);          }     } 

after that, can stream web browser in arraybuffer type , try convert float32array buffer instance of audiocontext. can't hear thing or loud noise.

    function onmessage(evt) {     var context = new audiocontext();     var source = context.createbuffersource();     source.connect(context.destination);      array = new int8array(evt.data);     abs = new float32array(evt.data);     arrays = new float32array(abs.length);      ab = context.createbuffer(1, array.length, 44100);     ab.getchanneldata(0).set(arrays);     source.buffer = ab;     source.start(0);         //      } 

so can give me advance, please? p/s: use decodeaudiodata give null error

sorry poor english

the array you're getting each sample 0-32k (range of uint16). each sample in audiobuffer's channel data float32 - nominal range of -1 +1.

you need convert data in each sample, not assign value , rely on conversion.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -