casting void* to float* creates only zeros

Posted by Paperflyer on Stack Overflow See other posts from Stack Overflow or by Paperflyer
Published on 2010-03-19T17:04:10Z Indexed on 2010/03/19 17:11 UTC
Read the original article Hit count: 343

Filed under:
|
|
|

I am reading an audio file using CoreAudio (Extended Audio File Read Services). The audio data gets converted to 4-byte float and handed to me as a void* buffer. It can be played with Audio Queue Services, so its content is correct.

Next, I want to draw a waveform and thus need access to the actual samples. So, I cast void* audioData to float*:

Float32 *floatData = (Float32 *)audioData;

When accessing this data however, I only get 0.0 regardless of the index.

Float32 value = floatData[index]; // Is always zero for any index

Am I doing something wrong with the cast?

© Stack Overflow or respective owner

Related posts about c

    Related posts about casting