buffer~ value range

tommi's icon

hi everyone,
this may be a very silly question, so I hope the answer will come very soon... and very easy!

the fact is that I assumed the buffer~ object could contain only values ranging from 0. to 1. divided in a number of floating point values depending on the bit-rate...
I am now developing a patch where values to be stored in buffer~ are the "amplitudes" of fft bins and after worrying for some time about how to rescale the outcome of pfft~ "nofft" outlet into a 0. to 1. range I found out (thanks to the peek~ object) that values get stored in a buffer~ even if they exceed such range (the highest value I stored is 32766.246094).

so, is there any range limitation to values stored in a buffer~?
if there is any, how can it be calculated?

thanks
tom

jvkr's icon

Yes, there is a maximum to it: the highest number (and lowest as well) you can express in 32 bit floating point. Numbers exceeding this maximum will not be generated by your max patch, so basically, you are safe. Saving the content of the buffer to file is another story.

_
johan

tommi's icon

thank you, johan!
so there is no way of saving such high values?

I will keep on looking for the best rescaling factor... but, you know, it would be so much better if I could store the original values for comparison purpouses...

cheers
tom

Emmanuel Jourdan's icon

Have a look to the samptype message of buffer. If you save the file as an AIFF float32 for instance, you'll be able to save and reload your data with the full range.

tommi's icon

thank you Emmanuel, now it all seem to make sense!

cheers
tom