[PD] Prime limit sliders

Mathieu Bouchard matju at artengine.ca
Mon Apr 4 10:09:54 CEST 2005

On Sun, 3 Apr 2005, Chuckk Hubbard wrote:

> Hi, Mathieu.  This sounds pretty intense, but maybe because I haven't 
> gotten that far into Pd.  That is dead on, though, to just have the 
> slider go smoothly decimal and use the closest value in the table. That 
> would work perfectly.

Now that I think of it, it's also possible to use a radiobutton or a 
slider or a numbox, that indexes into the table of all possible values, so 
that you access the ratios by their order in the table.

In the example you gave, the slider would have 9*3*3*3=243 positions.

> Might it be less involved to have the possible values of the sliders 
> determined by a prime to the power of -1 to 1

In Number Theory one would say that you are working with ratios of 
squarefree number. A squarefree number is one that is not divisible by a 
square number: in other words it's not divisible by a prime power beyond 
an exponent of just one.

> (maybe throwing 9 in as a "prime"),

This would cause duplicates because 3 is already there.

I don't think this would make things any easier unless I'm missing 
something not too obvious.

One can use an extension of the Euclidean GCD algorithm to find a sequence 
of rational approximations to a given float, and those approximations are 
especially high-quality (read about Continued Fractions). However I didn't 
really consider it in my last email because I'm not aware of any way to 
make it not use a prime more than a certain number of times, be it three 
times or even just one time.

BTW I just wrote a Ruby program that prepares a sorted list of ratios. It 
generates output like this:

7/495 = 0.0141414141414141
1/63 = 0.0158730158730159
5/297 = 0.0168350168350168
7/405 = 0.0172839506172839
1/55 = 0.0181818181818182
11/567 = 0.0194003527336861
5/231 = 0.0216450216450216
1/45 = 0.0222222222222222

You will need the Ruby interpreter.
It's cross-platform Linux/Win32/OSX/etc).
Here's the full source code:

require "rational"
module Enumerable
   def mult(p,n)
     (-n..+n).map {|i| map{|x| x*Rational(p,1)**i }}.flatten
[Rational(1,1)].mult(3,4).mult(5,1).mult(7,1).mult(11,1).sort.map {|x|
   puts "#{x} = #{x.to_f}"

   /  The Diagram is the Program (TM) ,--------------------------------}
  {----------------------------------"     http://artengine.ca/matju  /

More information about the Pd-list mailing list