|
Post by holyartefact on Dec 8, 2006 2:16:38 GMT -5
Hello I have many troubles for converting binary to floating points values like e.g. the volume and the pan in the sound resources. How can I do that?
|
|
|
Post by IsmAvatar on Dec 8, 2006 3:05:09 GMT -5
What programming language are you using?
|
|
|
Post by holyartefact on Dec 8, 2006 8:50:13 GMT -5
I'm currently studying C# at college. (.NET 2.0) This is the language I use the most for now...
|
|
|
Doubles
Dec 8, 2006 22:11:15 GMT -5
Post by IsmAvatar on Dec 8, 2006 22:11:15 GMT -5
I am not fimiliar with C#, but my understanding is that C# is very similar to Java, which I use fluently. Check to see if whatever file reader you are using has a function for reading in doubles. If you are reading in bytes into arrays and then possibly swapping for endianness, then you should be able to convert your byte array into a double. Read this article and see if it helps you (copy and paste into your browser, I couldn't get the link to work): www.builderau.com.au/architect/webservices/soa/Read_binary_files_more_efficiently_using_C_/0,339024590,320277904,00.htm In Java, I have used this code for a little endian 64-bit IEEE Double: double readDouble(RandomAccessFile f) { byte w[] = new byte[8] f.readFully(w,0,8); long l = (long) (w[7]) << 56 | /* long cast needed or shift done modulo 32 */ (long) (w[6] & 0xff) << 48 | (long) (w[5] & 0xff) << 40 | (long) (w[4] & 0xff) << 32 | (long) (w[3] & 0xff) << 24 | (long) (w[2] & 0xff) << 16 | (long) (w[1] & 0xff) << 8 | (long) (w[0] & 0xff); return Double.longBitsToDouble(l); }
|
|
|
Doubles
Dec 9, 2006 15:04:41 GMT -5
Post by holyartefact on Dec 9, 2006 15:04:41 GMT -5
I found a class in C# which automatically makes all the convertions of bits in any type! Thank you for your help
|
|