Reading audio buffer data with AudioQueue

后端 未结 1 861
半阙折子戏
半阙折子戏 2021-01-12 23:06

I am attempting to read audio data via AudioQueue. When I do so, I can verify that the bit depth of the file is 16-bit. But when I get the actual sample data, I\'m only seei

相关标签:
1条回答
  • 2021-01-12 23:36
    char *buffer= NULL;
    

    That's the reason. You're iterating over signed bytes, not 16-bit samples.

    Declare the variable as holding a pointer to two-byte values instead:

    SInt16 *buffer = NULL;
    

    Then, iterate over half as many samples as bytes:

    for(int i=0;i < (BUFFER_SIZE / sizeof(*buffer));i++){
      NSLog(@"%i", buffer[i]);
    }
    

    I would rename BUFFER_SIZE to BUFFER_SIZE_BYTES to clarify it.

    0 讨论(0)
提交回复
热议问题