This is an already well-solved problem - I suggest looking at some of the modem standards. In addition, you will need need to take care of signal levels - RS232 is potentially signalled at 12v. The sender transmit clock and the receiver's sample clock are not synchronous - that is to say that the clock edges aren't aligned. You are attempting to sample a signal without clock recovery. You might consider using the MSB of each byte to signal framing, and only encode payload in the remaining 7-bits of each byte) In particular, both 0x0a and 0x0d might reasonably be expected elsewhere in the message body. You currently seem to have no way of framing your message to indicate a message start or end amongst a stream of bytes.
![use android as microphone 3.5mm use android as microphone 3.5mm](https://ae01.alicdn.com/kf/HTB1nV.JbhTI8KJjSspixh6M4FXaA/LEORY-Mini-3-5mm-Jack-Cellphone-Flexible-Microphone-Mic-Mono-Stereo-Microphones-For-iPhone-Android-Smartphone.jpeg)
Your system bandwidth needs to be at least twice the bitrate. You are violating the Nyquist sampling theory by sampling your incoming signal at the line rate. Whilst not a detailed answer to your problem, there are a number of problems with your current approach * Frees the thread's resources after the loop completes so that it can be run again Log.w("Audio", "Error reading voice audio", x) N = recorder.read(buffer,0,buffer.length) Log.i("Map", "Writing new data to buffer") * Reads the data from the recorder and writes it to the audio track for playback. * Loops until something outside of this thread stops it. Track = new AudioTrack(AudioManager.STREAM_MUSIC, 1200,ĪudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, N*10, AudioTrack.MODE_STREAM) Recorder = new AudioRecord(AudioSource.MIC, 1200, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, N*10) Int N = AudioRecord.getMinBufferSize(8000,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT)
#Use android as microphone 3.5mm serial
But how do I write serial input from audio jack into a buffer?Įdit3: Maybe something like this will work: try The payload is transmitted in 9 byte packets: 1: command byte as ASCII character ('I','A','S','L','R','C' or ' ')Įdit2: I also think I have to store the input into a buffer and then read the signals from the buffer. Maybe something like this: Android: Need to record mic input I found this but it dosn't help me very much: Android serial port via audio jack
#Use android as microphone 3.5mm how to
I know exactly what to do with it after I thave the databits in variables but I have no idea on how to do the basic input / stream / read from audio jack thing.
![use android as microphone 3.5mm use android as microphone 3.5mm](https://ikancorp.com/prod1/wp-content/uploads/2020/04/1-CVM-SPX-TCM.jpg)
I want to store every data bit into a variable, display or calculate something and when the next bits come in, it should override the variable. This output comes in to my android phone via the 3.5mm audio jack. I have a device, which gives me an output of essentially just a RS232 serial signal (1200 baud, 8 databits, no parity bits, one stop bit). Hi and first thank you for reading my question!