[PD] number to fractions external?

Mike Moser-Booth mmoserbooth at gmail.com
Sun Dec 18 02:24:55 CET 2011


Oops, the right inlet was connected to a [sel] when it should have
been connected to [> 1000]. I'll upload the fix here and on GitHub.

.mmb

On Sat, Dec 17, 2011 at 7:57 PM, Alexandre Torres Porres
<porres at gmail.com> wrote:
> when I "change the maximum denominator value" results are weird and Pd
> freezes.
>
> cheers
>
>
>
> 2011/12/17 Mike Moser-Booth <mmoserbooth at gmail.com>
>>
>> I just added it to my library on GitHub:
>>
>> https://github.com/dotmmb/mmb
>>
>> But, yeah, feel free to use it however you want.
>>
>> .mmb
>>
>> On Sat, Dec 17, 2011 at 2:07 PM, Alexandre Torres Porres
>> <porres at gmail.com> wrote:
>> > this looks great huh?
>> >
>> > I have this pd examples that deal with tuning theory, are you releasing
>> > this
>> > somewhere so i can use it?
>> >
>> > thanks
>> > alex
>> >
>> >
>> > 2011/12/17 Mike Moser-Booth <mmoserbooth at gmail.com>
>> >>
>> >> They're not working? Huh... Well, here's the text versions:
>> >>
>> >> dec2frac.mmb.pd:
>> >>
>> >> #N canvas 60 22 908 750 10;
>> >> #X obj 298 36 inlet;
>> >> #X obj 573 359 t l;
>> >> #X obj 240 574 list;
>> >> #X obj 198 415 sel 0;
>> >> #X obj 207 168 expr 1/$f1;
>> >> #X obj 478 359 list append;
>> >> #N canvas 203 22 687 744 simplify 0;
>> >> #X obj 144 28 inlet;
>> >> #X obj 198 155 list length;
>> >> #X obj 145 132 t l l;
>> >> #X obj 165 214 spigot;
>> >> #X obj 51 239 spigot;
>> >> #X obj 84 213 == 1;
>> >> #X obj 205 275 list split 2;
>> >> #X obj 98 423 pack f f;
>> >> #X obj 272 371 list split 1;
>> >> #X obj 237 340 list;
>> >> #X obj 198 188 > 1;
>> >> #X obj 98 377 expr $f2*$f1+1 \; $f1;
>> >> #X obj 305 513 list append;
>> >> #X obj 305 541 expr $f1*$f2+$f3 \; $f2;
>> >> #X obj 307 589 pack f f;
>> >> #X obj 229 423 t b l;
>> >> #X obj 226 631 list;
>> >> #X obj 97 448 t l l;
>> >> #X obj 102 687 outlet;
>> >> #X text 206 80 converts the continued fraction form into a simple
>> >> fraction
>> >> ;
>> >> #X connect 0 0 2 0;
>> >> #X connect 1 0 5 0;
>> >> #X connect 1 0 10 0;
>> >> #X connect 2 0 3 0;
>> >> #X connect 2 0 4 0;
>> >> #X connect 2 1 1 0;
>> >> #X connect 3 0 6 0;
>> >> #X connect 4 0 18 0;
>> >> #X connect 5 0 4 1;
>> >> #X connect 6 0 11 0;
>> >> #X connect 6 1 9 1;
>> >> #X connect 7 0 17 0;
>> >> #X connect 8 0 12 0;
>> >> #X connect 8 1 9 1;
>> >> #X connect 8 2 16 0;
>> >> #X connect 9 0 8 0;
>> >> #X connect 10 0 3 1;
>> >> #X connect 11 0 7 0;
>> >> #X connect 11 1 7 1;
>> >> #X connect 12 0 13 0;
>> >> #X connect 13 0 14 0;
>> >> #X connect 13 1 14 1;
>> >> #X connect 14 0 15 0;
>> >> #X connect 15 0 9 0;
>> >> #X connect 15 1 16 1;
>> >> #X connect 15 1 12 1;
>> >> #X connect 16 0 18 0;
>> >> #X connect 17 0 15 0;
>> >> #X connect 17 1 12 1;
>> >> #X restore 478 385 pd simplify;
>> >> #X obj 325 713 outlet;
>> >> #X obj 368 630 list;
>> >> #X obj 479 411 t l l;
>> >> #X obj 596 577 sel 1;
>> >> #X obj 281 348 spigot;
>> >> #X msg 336 349 0;
>> >> #X obj 281 372 t f b;
>> >> #X obj 505 438 list split 1;
>> >> #X obj 535 469 route bang;
>> >> #X msg 333 382 1;
>> >> #X text 41 573 This is just here for debugging;
>> >> #X obj 634 406 loadbang;
>> >> #X obj 634 427 f \$1;
>> >> #X text 612 683 .mmb;
>> >> #X text 638 625 TODO: implement decrementing rules;
>> >> #X obj 102 674 prepend set;
>> >> #X obj 300 210 expr if($f1<0 \, int($f1-1) \, int($f1)) \; $f1;
>> >> #X obj 310 268 expr $f2-$f1 \; $f1;
>> >> #X text 533 211 floor;
>> >> #X obj 628 36 inlet;
>> >> #X obj 628 123 max 1;
>> >> #X obj 596 556 > 1000;
>> >> #X obj 298 100 t b b f b;
>> >> #N canvas 0 22 450 300 test.if.integer 0;
>> >> #X obj 206 117 expr int($f1)==$f1;
>> >> #X obj 151 28 inlet;
>> >> #X obj 151 64 t f f;
>> >> #X obj 129 186 spigot;
>> >> #X obj 179 186 spigot;
>> >> #X obj 164 160 != 1;
>> >> #X obj 129 242 outlet;
>> >> #X obj 179 242 outlet;
>> >> #X msg 179 214 \$1 1;
>> >> #X connect 0 0 4 1;
>> >> #X connect 0 0 5 0;
>> >> #X connect 1 0 2 0;
>> >> #X connect 2 0 3 0;
>> >> #X connect 2 0 4 0;
>> >> #X connect 2 1 0 0;
>> >> #X connect 3 0 6 0;
>> >> #X connect 4 0 8 0;
>> >> #X connect 5 0 3 1;
>> >> #X connect 8 0 7 0;
>> >> #X restore 298 76 pd test.if.integer;
>> >> #X obj 403 111 s \$0-to.outlet;
>> >> #X obj 395 671 r \$0-to.outlet;
>> >> #X msg 101 698;
>> >> #X obj 634 452 max 1;
>> >> #X obj 306 157 until;
>> >> #X obj 335 134 r \$0-stop.until;
>> >> #X obj 306 183 f;
>> >> #X obj 127 483 s \$0-stop.until;
>> >> #X obj 595 604 s \$0-stop.until;
>> >> #X connect 0 0 30 0;
>> >> #X connect 1 0 5 1;
>> >> #X connect 2 0 22 0;
>> >> #X connect 3 0 8 0;
>> >> #X connect 3 0 38 0;
>> >> #X connect 3 1 4 0;
>> >> #X connect 4 0 23 0;
>> >> #X connect 5 0 1 0;
>> >> #X connect 5 0 2 1;
>> >> #X connect 5 0 6 0;
>> >> #X connect 6 0 9 0;
>> >> #X connect 8 0 7 0;
>> >> #X connect 9 0 8 1;
>> >> #X connect 9 1 14 0;
>> >> #X connect 10 0 8 0;
>> >> #X connect 10 0 39 0;
>> >> #X connect 10 1 16 0;
>> >> #X connect 11 0 13 0;
>> >> #X connect 12 0 11 1;
>> >> #X connect 13 0 3 0;
>> >> #X connect 13 1 12 0;
>> >> #X connect 14 1 15 0;
>> >> #X connect 15 0 16 0;
>> >> #X connect 15 1 28 0;
>> >> #X connect 16 0 11 1;
>> >> #X connect 18 0 19 0;
>> >> #X connect 19 0 34 0;
>> >> #X connect 22 0 33 0;
>> >> #X connect 23 0 24 0;
>> >> #X connect 23 1 24 1;
>> >> #X connect 24 0 11 0;
>> >> #X connect 24 1 5 0;
>> >> #X connect 26 0 27 0;
>> >> #X connect 27 0 10 1;
>> >> #X connect 28 0 10 0;
>> >> #X connect 29 0 2 0;
>> >> #X connect 29 1 35 0;
>> >> #X connect 29 2 37 1;
>> >> #X connect 29 3 5 1;
>> >> #X connect 29 3 8 1;
>> >> #X connect 30 0 29 0;
>> >> #X connect 30 1 31 0;
>> >> #X connect 32 0 7 0;
>> >> #X connect 34 0 28 1;
>> >> #X connect 35 0 37 0;
>> >> #X connect 36 0 35 1;
>> >> #X connect 37 0 23 0;
>> >>
>> >>
>> >>
>> >>
>> >> dec2frac.mmb-help.pd:
>> >>
>> >> #N canvas 431 22 944 500 10;
>> >> #X obj 25 12 cnv 15 400 35 empty empty dec2frac.mmb 20 12 0 14 -4160
>> >> -203904 0;
>> >> #X obj 25 48 cnv 15 400 70 empty empty empty 20 12 0 14 -203904 -66577
>> >> 0;
>> >> #X text 812 417 .mmb;
>> >> #X text 45 48 Converts a decimal number into its fractional form. The
>> >> accuracy is determined by the argument. Irrational numbers \, such
>> >> as pi \, don't have fractional representations. So you should make
>> >> the argument high enough for as accurate an approximation that suits
>> >> you.;
>> >> #X text 468 49 [dec2frac.mmb max_denominator];
>> >> #X msg 71 172 3.14159;
>> >> #X msg 136 199 3.75;
>> >> #X msg 149 245 -0.625;
>> >> #X obj 113 338 unpack f f;
>> >> #X floatatom 113 364 0 0 0 0 - - -;
>> >> #X floatatom 170 384 0 0 0 0 - - -;
>> >> #X obj 131 423 /;
>> >> #X floatatom 131 450 0 0 0 0 - - -;
>> >> #X floatatom 223 252 5 0 0 0 - - -;
>> >> #X text 263 252 change the maximum denominator value;
>> >> #X text 194 333 outputs a list of <numerator> <denominator>;
>> >> #X text 487 69 arg1 <optional>: the maximum size of the denominator.
>> >> Higher values result in more accurate estimations \, but more
>> >> computation.
>> >> Default is 1000;
>> >> #X floatatom 48 255 0 0 0 0 - - -;
>> >> #X obj 113 296 dec2frac.mmb 1000;
>> >> #X text 526 305 This algorithm is based on best rational approximation
>> >> using continued fractions. It currently does not implement rules for
>> >> decrementing the last value of the continued fraction form \, so it
>> >> is not as accurate as it could be.;
>> >> #X connect 5 0 18 0;
>> >> #X connect 6 0 18 0;
>> >> #X connect 7 0 18 0;
>> >> #X connect 8 0 9 0;
>> >> #X connect 8 1 10 0;
>> >> #X connect 9 0 11 0;
>> >> #X connect 10 0 11 1;
>> >> #X connect 11 0 12 0;
>> >> #X connect 13 0 18 1;
>> >> #X connect 17 0 18 0;
>> >> #X connect 18 0 8 0;
>> >>
>> >>
>> >>
>> >> On Sat, Dec 17, 2011 at 1:34 PM, Alexandre Torres Porres
>> >> <porres at gmail.com> wrote:
>> >> > hi there, how do i get the attachments you're sending to the list?
>> >> >
>> >> > thanks
>> >>
>> >>
>> >>
>> >> --
>> >> Mike Moser-Booth
>> >> mmoserbooth at gmail.com
>> >
>> >
>>
>>
>>
>> --
>> Mike Moser-Booth
>> mmoserbooth at gmail.com
>
>



-- 
Mike Moser-Booth
mmoserbooth at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dec2frac.mmb.pd
Type: application/octet-stream
Size: 3786 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20111217/bac8343c/attachment.obj>


More information about the Pd-list mailing list