如何通过蓝牙接收16位PCM音频进行FFT

时间:2016-02-23 19:39:36

标签: java android audio bluetooth pcm

我正在尝试通过蓝牙在android中发送音频,当在服务器中接收数据时,我希望看到代表音频数据的16位数字,但我收到了奇怪的符号。我无法发现问题出在哪里。我需要在服务器端执行FFT。

    int minBufferSize = AudioRecord.getMinBufferSize(44100,
            AudioFormat.CHANNEL_CONFIGURATION_MONO,
            AudioFormat.ENCODING_PCM_16BIT);

    short[] audioData = new short[minBufferSize];

   AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
            44100,
            AudioFormat.CHANNEL_CONFIGURATION_MONO,
            AudioFormat.ENCODING_PCM_16BIT,
            minBufferSize);

    while(recording){
        int numberOfShort = audioRecord.read(audioData, 0, minBufferSize);
        //convert from short to byte 
        byte[] data = ShortToByte_Twiddle_Method(audioData);
        //send through bluetooth
        blue.write(data);
    }

收件人代码:

    do {

       bytes = input.read(buffer);
       //writing data to a file
       fil.write(buffer, 0, bytes); 

       } while (true);

收到的数据:enter image description here

为什么我会在收到的数据中看到空值?

0 个答案:

没有答案