arrays - Unpacking 3-byte/24-bit data chunks with Ruby -
I'm building a pure-ruby WAV file / writing library, I'm learning Ruby Ruby's functionality . It currently works well with 16-bit audio, because I use the string
As you used unpack ("s +")
, I believe that your sample is in large Andian. Here's a very fast but not practical solution.
& gt; & Gt; "ABCDEF" .scan (/.../) Map {| S | | (S.reverse + 0.chr). Unpack ("V")} Flatine = & gt; [4276803, 4474182] # = & gt; [0x414243, 0x444546]
Comments
Post a Comment