Re: [PD] nearest power of 2

2008-12-18 Thread Mathieu Bouchard
On Fri, 12 Dec 2008, hard off wrote: what's the easiest way for pd to find the nearest power of 2 for any float? depends how you define «nearest». multiplication-wise, 92 is closer to 128 than to 64, because 92*92 64*128, whereas addition-wise, it's closer to 64 because 92+92 64+128.

Re: [PD] nearest power of 2

2008-12-12 Thread Si Mills
Hardoff* has actually :-) Uses bonk~ and works bloody well. *is there a link for that somewhere? On 12 Dec 2008, at 00:25, Kyle Klipowicz wrote: This is neat. Please share your continued research in this territory. Also, has anyone made a beat slicer that chops up a sound file based on

Re: [PD] nearest power of 2

2008-12-12 Thread hard off
http://puredata.hurleur.com/sujet-1953-sample-slicer-user-selectable-slices scroll down the page a bit to get the latest revised version. (oh, and you have to log in to the pd forum to be able to see and download the attachments) ___ Pd-list@iem.at

[PD] nearest power of 2

2008-12-11 Thread hard off
what's the easiest way for pd to find the nearest power of 2 for any float? so 10 would give a result of 8, 53 would give a result of 64, etc.. http://en.wikipedia.org/wiki/Power_of_two#Algorithm_to_convert_any_number_into_nearest_power_of_two_number

Re: [PD] nearest power of 2

2008-12-11 Thread hard off
ah don't worry. the bitwise operators in pd correspond exactly to the process in that wikipedia article. couldn't guess it would be that easy. ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -

Re: [PD] nearest power of 2

2008-12-11 Thread hard off
may as well post the patch i guess. actually it just gets the NEXT power of 2, not the nearest, but that is fine for my purpose - which is to decide how many slices to make in a sound file to cut it into individual beats. nextpow2.pd Description: application/extension-pd

Re: [PD] nearest power of 2

2008-12-11 Thread Thomas Grill
Hi, one could also use expr pow(2, int(log($f1)/log(2)+0.5)) which takes the dual log, rounds that to the nearest integer and calculates the dual power again. gr~~~ Am 11.12.2008 um 18:02 schrieb hard off: ah don't worry. the bitwise operators in pd correspond exactly to the process in

Re: [PD] nearest power of 2

2008-12-11 Thread Matt Barber
This might be silly, but here are three abstractions I made a couple years or so when I was learning... the nearest one defaults to the higher value for numbers halfway between. Matt Date: Fri, 12 Dec 2008 00:48:48 +0900 From: hard off hard@gmail.com Subject: [PD] nearest power of 2

Re: [PD] nearest power of 2

2008-12-11 Thread Kyle Klipowicz
This is neat. Please share your continued research in this territory. Also, has anyone made a beat slicer that chops up a sound file based on transients? ~Kyle On Thu, Dec 11, 2008 at 11:07 AM, hard off hard@gmail.com wrote: may as well post the patch i guess. actually it just gets the