Charles Turner
8/21/2008 2:03:00 PM
On Thu, 21 Aug 2008 13:11:38 +0900, Charles Turner wrote:
> I'm trying to hookup Erik de Castro Lopo's libsndfile with Ruby via
> Ruby/DL:
OK, responding to my own question because I think I've got it:
buffer = DL::CPtr.malloc(40)
frames = SndFile.sf_readf_int( sndfile, buffer, 10 )
frames # => 10
buffer[0,40] # =>
"qs\xDB\x8F`\x906\x8C\xF1\x16\x06\x89\x1C:M\x86X\xB5\x0E\x84\x9E\xC9L\x82\xE8:\t\x81\xB4OE\x80\x7F\xCA\x01\x80\xC7\xF1>\x80"
Seems to work fine. It appears that Ruby/DL isn't too happy with
libsndfile's sf_readf_short() function, and in that case, my buffer
seems to contain only the two MSBs of each 32-bit address. But I may
still be doing something wrong.
Changing my audio file format to 32-bit integer data from 16-bit shows
everything to be OK.
Best, Charles