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. I never considered that the grid would have to be double the exponents + 1. Never occured to me. Wow, I kind of understand this.
Might it be less involved to have the possible values of the sliders determined by a prime to the power of -1 to 1 (maybe throwing 9 in as a "prime"), but this ratio being multiplied by all of the last 7 or 8 pitches, and the results being the available pitches? In that case, I can't imagine what would happen if you changed a note in the middle of the sequence. But this would allow endless modulation in small, rational steps.
Thanks. -Chuckk
On Mar 31, 2005 2:43 PM, Mathieu Bouchard matju@artengine.ca wrote:
On Tue, 29 Mar 2005, Chuckk Hubbard wrote:
For instance, with the prime limits: 3-4 5-1 7-1 11-1 13-0 17-0
The set of all possible fractions can be expressed as a six-dimensional 9-by-3-by-3-by-3-by-1-by-1 grid (in this example). If you have GridFlow then you could do this:
[9 3 3 3 1 1 6 # 3 5 7 11 13 17( <-- make many copies of prime list | | [#for (-4 5) (-1 2) (-1 2) (-1 2) (0 1) (0 1)] <-- make indices | | | [#cast f] <-- convert to float (from int) | | [# **] <-- raise primes to all possible power combinations | [#fold *, seed 1] <-- multiply prime powers together |
and then the next step is to make a sorted list of those values. It would involve [#ravel] and [#grade] and [#finished] and [#store].
at that point, half of your problem is solved, and the other half is to take any number and find the closest possible value in your list. For that job, you can use [#convolve (1 2 # 1 1)] [# >> 1] to find the boundaries of the centered intervals (which are averages of successive values in the previous list). Each interval is centered on an allowed fraction and encompasses all values for which the closest allowed fraction is that one.
If that list is any big, you'll have a hard time searching in it, but I guess you won't use big lists anyway because it'd make more pixel positions than are available on the actual slider...
You can do the same with plain Pd of course (plus maybe zl), it's just that it'd take many times more boxes. (I mean, it doesn't matter if you decide to not use GridFlow, i am just trying to communicate a few concepts to you)
.-----------------------------------------------------------------. / The Diagram is the Program (TM) ,--------------------------------} {----------------------------------" http://artengine.ca/matju / `-----------------------------------------------------------------'
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:
------------------8<--------cut-here--------8<------------------ require "rational" module Enumerable def mult(p,n) (-n..+n).map {|i| map{|x| x*Rational(p,1)**i }}.flatten end end [Rational(1,1)].mult(3,4).mult(5,1).mult(7,1).mult(11,1).sort.map {|x| puts "#{x} = #{x.to_f}" } ------------------8<--------cut-here--------8<------------------
.-----------------------------------------------------------------.
/ The Diagram is the Program (TM) ,--------------------------------} {----------------------------------" http://artengine.ca/matju / `-----------------------------------------------------------------'