Recording a wav file from the mic in Android - problems

后端 未结 4 1061
误落风尘
误落风尘 2021-02-03 15:33

I need to be able to create a WAV file using the mic in Android. Currently, I\'m having a lot of trouble. So far, this is my situation. I\'m using parts of the micDroid project

4条回答
  •  猫巷女王i
    2021-02-03 16:25

    I have a lot of theories:

    1. if you had a signal saturated of noise and you cannot understand anything or you can understand something. It can be that you have a problem with big endian and little endian. When you record 16bit (2bytes) can be stored like AB or like BA (where A and B it's a byte). In java all is big endian (http://mindprod.com/jgloss/endian.html) so you are storing a sample of 16 bit as short in big endian, then you try to construct a wav, but a wav need to have data stored on little endian (https://ccrma.stanford.edu/courses/422/projects/WaveFormat/). Well the result is clear and you have an screenshot. The solution is to use byte always, you had done and it probably all it's ok now

    if not check queue.put and queue.take I think you don't need them because you stored your audio in and array that's enough. In the first while I would replace queue.put by a function to store the buffer in a huge array of bytes with all the bytes. Then you can put the header of the wav.

    Remember a wav has the header and the bytes of the audio, maybe you have forgot the header and the program you are using is inventing a header to play it.

    The other option is: you have the problem on the wav header of 44 bytes. check your WaveWriter function. if you write bad code on it, you can heard a lot of different sounds of your voice.

    note: I had seen the function WaveWriter or similar on the source code of android but it had not been ready to use three months ago. Some new about waveheader?

提交回复
热议问题