How to record Audio on android(2.3) from pc? -


i have single board computer android 2.3 (max version board). , audio input/output(3.5mm) interfaces. need stream audio pc in real time via audio interface (not usb, or wi-fi). first of all, it`s possible?

i have simple app, using audiorecorder , audiotrack classes. , app car record data, data different. also, got data, when cable disconnected.

main part of app:

int samplerate = 8000;     int channelconfig = audioformat.channel_in_mono;     int audioformat = audioformat.encoding_pcm_16bit;      int mininternalbuffersize = audiorecord.getminbuffersize(samplerate,             channelconfig, audioformat);     int internalbuffersize = mininternalbuffersize * 4;     log.d(tag, "mininternalbuffersize = " + mininternalbuffersize             + ", internalbuffersize = " + internalbuffersize             + ", mybuffersize = " + mybuffersize);      audiorecord = new audiorecord(mediarecorder.audiosource.default,             samplerate, channelconfig, audioformat, internalbuffersize);     track = new audiotrack(audiomanager.stream_music, 8000,             audioformat.channel_out_mono, audioformat.encoding_pcm_16bit, internalbuffersize*4, audiotrack.mode_stream);     log.d(tag, "init state = " + audiorecord.getstate());     log.d(tag, "record start");     audiorecord.startrecording();     track.play();     int recordingstate = audiorecord.getrecordingstate();     log.d(tag, "recordingstate = " + recordingstate);      log.d(tag, "read start");     isreading = true;     new thread(new runnable() {         @override         public void run() {             if (audiorecord == null)                 return;              byte[] mybuffer = new byte[mybuffersize];             int readcount = 0;             int totalcount = 0;             int h = 0;             while (isreading) {                 readcount = audiorecord.read(mybuffer, 0, mybuffersize);                 totalcount += readcount;                 mybuffer2 = mybuffer;                 track.write(mybuffer, 0, mybuffer.length);                   log.d(tag, "readcount = " + readcount + ", totalcount = "+ totalcount);                 if (h<5){                     (int i=0;i<mybuffer.length;i+=100){                         log.d(tag, "mybuffer index = " + + ", value = "                                 + mybuffer[i] + " , iter = " + h);                     }                     h++;                 }               }         }     }).start(); 

board can work audiorecorder config: 8000 - samplerate, mono_channel, encoding_pcm_16bit.

what data recieved? i`m not sure, pc.

while track.play(); can hear noise, likes system noise.

any great.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -