core audio: how can one packet = one byte when clearly one packet = 4 bytes

前端 未结 1 376
我寻月下人不归
我寻月下人不归 2020-12-19 23:05

I was going over core audio conversion services in the Learning Core Audio and I was struck by this example in their sample code:

while(1)
{
    //         


        
相关标签:
1条回答
  • 2020-12-19 23:33

    I think you're right, according to the definition in the AudioFile.h header file, AudioFileWritePackets should take the number of bytes of audio data being written as the third parameter, and in that Learning Core Audio example the framecount variable is defined as the number of packets, not the number of bytes.

    I tried the examples out and got the exact same output with (framecount * 4), 0 and even -1 as the third parameter of the AudioFileWritePackets function call. So for me it would seem that the function doesn't work exactly as defined in the .h file (does not require the third parameter), and that in that example the authors of the book have not noticed this error either - I might be wrong though.

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