MSP int to float mapping
I’m trying to build a patch that will randomly flip bits of single samples in a sound file. As I haven’t found a way of changing bits directly, I’m trying to convert sample values from peek~ to their binary states, do the process, then convert back. jasch’s bitlist external is taking care of this conversion.
However, I am getting confused as to the method a, say, 16-bit int representing a sample from a sound file is mapped on to MSP’s -1. to 1. scale. This int’s range is -32768 to 32767 (due to it using the two’s compliment system), so, if the zeroes map directly on to each other, surely the bottom half of the cycle has more resolution that the top half?
How does Max handle this?
if the one number which is "too much" is used as 0 and -0, or if the highest value is simply not used does not really matter.
the normal case is that the highest number isnt used.
also, max will handle the conversion from a LONG range to an MSP signal just as you programmed it – its you who decides what happen with a 0 and also with the -32768.
there are surely better ways to do what you want, but for now i´d say use a range of -32767 32768 and not -32768 32767, then leave the highest value unused. even if there would be a technical standard you could just ignore it.
btw, since all audio in max (and most other programs) is 32 bit floating point, there is no 100% perfect copnversion from an imaginary "16 bit int" value to the signal layer anyway.
of course a 16-bit precidse value will "fit" into a 24-bit precision system, that stops working as soon as you use wrong numbers.
There are lots of arguments on various dsp-related lists about the ‘right’ way to handle the difference between floating point symmetry and fixed point/integer asymmetry.
Before we worry too much about that, have you looked at bitxor~?
Thanks for the replies,
Forums > MaxMSP