<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<div><br></div><div>I try to extract raw audio frames from an audio file, using the following example: <a href="http://ffmpeg.org/doxygen/3.4/decode_audio_8c-example.html">http://ffmpeg.org/doxygen/3.4/decode_audio_8c-example.html</a></div><div><br></div><div>As far as I understand, I get these frames in the <font face="monospace, monospace">decode()</font> function, in the <font face="monospace, monospace">frame->data</font> array.</div><div><br></div><div>That said, I need to convert the frames into floats between -1 and 1. Here is what I tried (in my test, <font face="monospace, monospace">dataSize == 4</font>):</div><div><br></div><div><font face="monospace, monospace">// here is where I want to get my frame:</font></div><div><font face="monospace, monospace">float myFrame;<br><br>// first try:</font></div><div><font face="monospace, monospace">memcpy(&myFrame, &frame->data[ch][i], dataSize * sizeof(uint8_t));<br></font></div><div><font face="monospace, monospace"><br class="gmail-Apple-interchange-newline">// second try:<br>myFrame = (frame->data[ch][i]<<0) | (frame->data[ch][i + 1]<<8) | (frame->data[ch][i + 2]<<16) | (frame->data[ch][i + 3]<<24);<br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">// third try:<br>myFrame = (frame->data[ch][i + 3]<<0) | (frame->data[ch][i + 2]<<8) | (frame->data[ch][i + 1]<<16) | (frame->data[ch][i]<<24);</font><br></div><div><br></div><div>But the problem is; it doesn't work, all I got so far is some kind of white noice.<br></div><div><br></div><div>So what is the proper way to extract audio frames and convert them to float amplitudes?</div><div><br></div><div>Thanks for your help.</div><div><br></div></div></div></div></div></div>