07-26-2012 12:15 PM
Hi, a little help here, on my project I'm recording an audio signal that I need to decode in my software, however for that I need the double value of each point of the signal, this value is in fact a number smaller that 0, since I already build this on Android, and there I can use the ByteArray.readFloat() method,
However since javaME does not have a ByteArray class I'm using the byte that I get from the recorder _output.toByteArray() and to read the double values from I'm using
floatValue = ( ( pcm[i++] & 0xff ) << 24 ) | ( ( pcm[i++] & 0xff ) << 16 ) | ( ( pcm[i++] & 0xff ) << 8 ) | ( pcm[i++] & 0xff );
however I get really large numbers in the floatValue, like 5.85279E9, and I know for a fact that the float representation for these bytes are numbers between 1 and -1,
any thoughts on why is this wrong??
many thanks in advance
07-26-2012 08:32 PM
I suspect that you think this code is recreating the internal bit pattern used by a float and then the assignment will overlay it bit at a time. In fact, I think the compiler will see the right hand side as an int, and then convert the int to a float.
floatvalue = Float.intBitToFloat(.....);