توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : ?How many melodies are there in the universe

Sunday 19 October 2008, 11:52 AM
After writing "Is music written or discovered? (You can see links before reply F)" I started thinking a little bit harder about how one might go about searching for new musical discoveries. specifically, short little melodies.
So I started wondering how many melodies of a given length are out there. Clearly it is a finite (You can see links before reply) number. So I have set out to try to count them, or at least put an upper bound (You can see links before reply) on their number.
First we have to limit things in some way, we can't allow infinitely long melodies. So, I'll arbitrarily (You can see links before reply) draw the line at 32 note (You can see links before reply)s, or rather, 1 measure (You can see links before reply)'s worth of 1/32 notes.
There are 12 notes total (in the Western scale (You can see links before reply), which for some very good reasons which I can't actually recall (You can see links before reply %2520can%2527t%2520actually%2520recall), has been shown to be the "best" scale, overall. There are other scales, but they all suffer from more problems than the 12 note scale does. The math (You can see links before reply) seems to end up favoring the 12 note scale (You can see links before reply).) I will also ignore interval (You can see links before reply)s larger than 1 octave (You can see links before reply), just because.
Further, each note may transition to the next note in a number of ways, "normally" (separately plucked and fretted), by sliding, by hammer-on (You can see links before reply) by pull-off (You can see links before reply). I will allow for the possibility of sliding from a note to itself which enables 1/16th notes, 1/8th notes, (and even 3/8th notes).
So what does that leave?
Choose 1 note from 12, 32 times, and choose one of four methods of transitioning to the next note, 31 times.
Damn that's a big number.
1232 x 431:
% bc -l4^31 * 12^32157637523953697211105908171958186454333476434 685722624

I can probably divide that number by twelve because it would count each riff played in each key, and I would really only want to count each riff in one key. (Yeah, that helps).
12^31 * 4^311313646032947476759215901432984887119445636955 7143552

Hmm, I still don't feel like I've accomplished anything. What is stil missing is a way to toss out even some proportion (You can see links before reply) of the riffs as being "non-musical", I know there are plenty of non-musical riffs counted in there, but I have no idea how to toss them out.
Hmm, lets say I only allow two methods of transitioning between notes. After all, riffs that differ only by using a pull-off (You can see links before reply) or a hammer-on (You can see links before reply) vs. an ordinary pluck (You can see links before reply)ing style aren't really all that different, it's more a matter of how well the riff is performed than a matter of it being a different riff altogether. I still have to allow for sliding though, to allow for the possibility of different time values for the notes and still have everything add up to just one measure.
So that would be:
12^31 * 2^316117141027690268863066571918245810640257024

A little better, but still a freakin' huge number (You can see links before reply), and I'm still counting too many duplicate riffs that differ only by "sliding" vs. normal plucking.
So thinking about it a little differently, for the first note, there, are 12 choices. For the remaining 31 notes, you really have 13 choices, you can just allow the previous note to continue uninterupted, or you can start new note, from a choice of 12. And once again, I can divide by 12 to limit each riff to one key.
So that gives us:
12 * 13^31 / 1234059943367449284484947168626829637

One problem I still see, most music has whole notes, half notes, quarter notes, eighth notes, sixteenth notes, and 32nd notes, which I have allowed for, but I have also allowed for 3/8th notes, 7/8th notes, etc... Well those would typically be written as a quarter note note tied to an eighth note, or a half note tied to a quarter note tied to an eighth note respectively, so I suppose I have to allow them.
But, suppose we limit things so that notes can only be 32nds, 16ths, 8ths, 4ths, halves, or whole notes, that is, no "3/8th" notes, no triplets (You can see links before reply), or other weird Chopin-esque (You can see links before reply) stuff. (Chopin would do weird things like have the left hand play 17 notes in one measure while the right hand had to play 13 in the same amount of time, 17 against 13. What a bastard.)
Anyway, what would that kind of convenient blindness leave?
I imagined a measure, which you chop up in a number of pieces (at most 32 pieces) and as you cut it up, you could make as many as 31 cuts, or as few as zero, and each cut would have to slice one of the remaining pieces exactly in half. Being rather bad at combinatorics (You can see links before reply) and discrete math (You can see links before reply) I wrote a little brute force C program:
#include < stdio.h>struct measure{ int length; struct measure *left, *right;};longways_to_cut(struct measure *m, int cuts){ long ways_cut = 0; long left_cut; long right_cut; struct measure m1, m2; int i; if (m->length length >> 1); m2.length = (m->length >> 1); m->left = &m1; m->right = &m2; cuts--; for (i=0;ileft, i); right_cut = ways_to_cut(m->right, cuts-i); ways_cut += left_cut * right_cut; } return(ways_cut);}int main(int argc, char **argv){ long wtc; struct measure m; int i; long total=0L; m.left = NULL; m.right = NULL; m.length = 32; for (i=0;i < 32;i++) { wtc = ways_to_cut(&m, i); total += wtc; printf("ways to make %d cuts = %ld\n", i, wtc); } printf("Total ways to cut: %ld\n", total);}

And the output:
ways to make 0 cuts = 1ways to make 1 cuts = 1ways to make 2 cuts = 2ways to make 3 cuts = 5ways to make 4 cuts = 14ways to make 5 cuts = 42ways to make 6 cuts = 100ways to make 7 cuts = 221ways to make 8 cuts = 470ways to make 9 cuts = 958ways to make 10 cuts = 1860ways to make 11 cuts = 3434ways to make 12 cuts = 6036ways to make 13 cuts = 10068ways to make 14 cuts = 15864ways to make 15 cuts = 23461ways to make 16 cuts = 32398ways to make 17 cuts = 41658ways to make 18 cuts = 49700ways to make 19 cuts = 54746ways to make 20 cuts = 55308ways to make 21 cuts = 50788ways to make 22 cuts = 41944ways to make 23 cuts = 30782ways to make 24 cuts = 19788ways to make 25 cuts = 10948ways to make 26 cuts = 5096ways to make 27 cuts = 1932ways to make 28 cuts = 568ways to make 29 cuts = 120ways to make 30 cuts = 16ways to make 31 cuts = 1Total ways to cut: 458330
Pipe that through a short filter:
./cuts | awk '/ways to make/ { printf("%d * 12 ^ (%d+1)\n", $7, $4 );}' | bc -l

which yields a very pretty sequence:
12144345610368034836481254113283583180800950259548 16242509676544059316834926592138199556947968030617 88893931110464581098766807859212926491101077962752 24441699025923814195243375695979364493557767187856 26361766776668161109074817815117490552832158781559 68719959464345600209883024546529473038647296254445 11719474194486877224962803809635948482077673075507 22778679799249187971944226488322447071950614776964 11559736115218877003349528376284550493372416125327 73357831210646650018280243270004033282617299366454 32205639683184798876813578234913416410038272112358 12186522437499570313794420736284851576559723767594 74034971770880455762522495558028151584559548334083 4182189187166852111368841966125056
the sum of which is some kind of answer:
./cuts | awk '/ways to make/ { printf("%d * 12 ^ (%d+1)\n", $7, $4 );}' |\ bc -l | ( awk 'BEGIN { printf("0 ");} { printf(" + %s ", $0); }' ;\ echo ) | bc -l

Ok, so if you listened to one measure per second, how long could you go without repeating a measure?
% bc -l123511210975209861511554928715787036/3600/24/3653916514807686766283344588049

That's 3916514807686766283344588049 YEARS folks!
Jebus (You can see links before reply) help me!
So there you have it. Boy was this node a waste of time or what? But it does demonstrate how cool awk (You can see links before reply) and bc (You can see links before reply) are

created by ferrouslepidoptera (You can see links before reply)

Sunday 19 October 2008, 12:53 PM
wow.. so interesting..... but who knows that it`s true?......lol

Tuesday 28 October 2008, 09:57 PM
A fine attempt, but let us not forget that you've left out at least two possibilities
Use of rests/durations: Rests (You can see links before reply) and durations (You can see links before reply) are important in melody making, otherwise, you'll end up sounding like some weird electronic music or a Steve Reich (You can see links before reply) piece. This significantly increases the number of melodies you can get, each note can be held out from anywhere from the 32 or so quavers you define your melody to last, and that is a combinatorial problem my brain is too tired to figure out right now exactly. I think it's something along the lines of (32 * 13) permute 32: This you get from pretending all your possible notes were hand-painted balls in a big vat, which makes ((12notes + space)* 32max), and then you select 32 of these and include the permutations. I think I'm right. Anyway, it's a larger number.

Melodies don't always stay within an octave: Think, let's say, OK, a slightly obscure example - Prokofiev (You can see links before reply)'s piano sonata no. 6, 3rd movement. The arpegiated a-minor melody comes in, mucks around a bit, does it's thing, and then all of a sudden the tail end of the melody gets carried upwards in ribbons and ends up getting placed in the same spot an octave higher. Sure, while the release dates of the next recording of the Prokofiev sonata no. 6 does not exactly have Justin Timberlake (You can see links before reply) crossing out squares in his calendar, that doesn't mean this happens rarely. For instance, you know that bit in a pop song, where everything goes higher? Think Mariah Carey (You can see links before reply)'s "Can't live", or most Celine Dion (You can see links before reply) songs. It's a modulation (You can see links before reply) upwards, I think by a perfect fifth in most cases. I don't think you couldn't call that entire stretch a melody, and I think the lowest and highest notes in that set will probably poke outside the 1 octave range.

Melody is a hard thing to define, even definitions that seem academic come up in real music, see brain-liquefying modern compositions (You can see links before reply). In my estimation, for all practical purposes there are probably an infinite number of melodies. A friend said that there are more chess games possible than atoms in the universe, and I have another friend that made music out of chess games. Monophonic (You can see links before reply) mostly, I think. Ergo, there are at least as many 'melodies' as there are atoms in the universe.