Re: [Audacity-nyquist] read-int issue
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
|
From: Sami J. <sam...@gm...> - 2005-07-01 10:21:06
|
Ah, I went a bit off because I thought you were reading audio data. Well. > here's my C code: > fread(&header->width, 2, 1, inputFile); > fread(&header->height, 2, 1, inputFile); >=20 > here's my nyquist code: > (setq tempWidth (read-int filePointer 2)) > (setq tempHeight (read-int filePointer 2)) >=20 > In C everything works great, but in nyquist, I get > crazy numbers. Does the Lisp example above read 2 INTEGERS instead of two bytes? I don't know the syntax nor the targa file format, but that would explain the crazy numbers. =20 > Oh, I also read something about turning off boundary > alignment in a C compiler, because that might cause a > misinterpretation of the bytes... might something like > that be occurring here? I think (I'm not C expert either... so why am I writing here!!?) that relates to way structures are stored. For example in Delphi 5 (Object Pascal) there is a compiler directive "Aligned record fields" and that is explained in the help: "Aligns elements in structures to 32-bit boundaries." When reading/handling structures, this is a very important issue, and good to keep in mind generally when reading data from files not written by yourself. Remeber also related keyword: padding. --=20 Sami "Some-E" Jumppanen sam...@gm... http://netti.nic.fi/~some-e/ |