[java-dev] Bug in AudioFileBuffer with different sample sizes?
volker böhm
vboehm at gmx.ch
Sun Mar 23 12:28:36 MDT 2008
- Previous message: [java-dev] Bug in AudioFileBuffer with different sample sizes?
- Next message: [java-dev] Bug in AudioFileBuffer with different sample sizes?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 22 Mar 2008, at 18:44, topher lafata wrote: > i dont think you have overlooked anything. it is very possible > there are bugs with those bit depths. > Regardless here is the source for the class. You could copy it and > make your own. hi topher, thanks for the class file - interesting to look inside. i think i found the reason, why the conversion didn't work correctly, although i don't fully understand it... it seems that the fact it works for 16bit files is rather a fortunate coincidence, but which concealed why the others don't work. in fill_buf() you do: si = (int)( ((tmp[i+ch_offset] & 0xff) << 16) | ((tmp[i+ch_offset+1] & 0xff) << 8) | (tmp[i+ch_offset+2] & 0xff)); where i found that the MSB needs to stay a signed byte in order for the two's complement to work. so omitting '& 0xff' in the MSB fixes the 24bit inconsistencies for me. si = (int)( ((tmp[i+ch_offset]) << 16) | ((tmp[i+ch_offset+1] & 0xff) << 8) | (tmp[i+ch_offset+2] & 0xff)); i also found that this is the same for the other bit depths. the 16bit case simply worked because of the explicit cast to short. aha, and the division of the 8bit values should of course be 128 (or 127). there is no handling for 32 bit files. for the sake of completeness, this should be added, i think. i have fixed this in my own class for now, but it would certainly be nice to have a fix in AudioFileBuffer some time in the future. thanks, volker.
- Previous message: [java-dev] Bug in AudioFileBuffer with different sample sizes?
- Next message: [java-dev] Bug in AudioFileBuffer with different sample sizes?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
