

Ask HN: Math,how many unique melodies can be created? - Sharma

If number of musical notes are fixed how many unique melodies can be created?
======
CowboyRobot
I played with this idea when I was doing an algorithmic composition project. I
started with a Markov chain analysis of a simple Chopin etude, which gave me
parameters, such as: \- The distance between the lowest and highest note is 2
octaves \- The key won't change, so there are only 8 notes per octave and
given the first parameter, I only had 17 notes to choose from. \- The shortest
note was an 1/8th and the longest was a half. Most were quarters and there
were a few dotted quarters (if I recall) so there were 4 note lengths to
choose from. \- The main melody in the original was 4 measures (again, if I
recall) so my generated melodies were set to be that length, and always end on
the root

Given all of these parameters, there were still many thousands of
combinations. Applying the Markov chain limited that a lot, but that was only
to make it sound like Chopin (which it did, a little). However, most of the
thousands of combinations sound like crap, which is not an insignificant
point. If you're willing to call some random sequence of notes a melody, then
there are an infinite number

~~~
sunspeck
You may be interested in David Cope's work with his program Emily Howell. It
can create quite convincing (and beautiful) new works in the style of any
composer, given a sufficient input database.

------
DanBC
Mozart had a dice game to create minuets.

(<http://sunsite.univie.ac.at/Mozart/dice/>)

(<http://en.wikipedia.org/wiki/Musikalisches_W%C3%BCrfelspiel>)

Your question is tricky because you haven't mentioned anything about time
signatures or length of time for each note, nor how many octaves you want to
work with.

A regular piano has 88 keys.

So, 88 notes with a 32 note length sequence (with fixed times etc) means 88 ^
32 or 1.6728057e+62.

~~~
Sharma
Leave the octave and think about the 7 notes. Basic notes, A,B,C,D,E,F and G
and probably flats/sharps associated to those.

You said 88 keys = 88 notes but they are just same basic notes,one of those 7
+sharp/flat.

~~~
DanBC
12 ^ 32 = 3.4182189e+34

------
batista
More melodies need at most a 2 octave range (especially in pop), which limits
us to 24 choices for each melody note.

(Actually less, if you factor in the constrains of the specific key the tune
is in, but let's be maximalist and get an upper bound).

Now, a melody also comes with a rhythm / syncopation pattern, but let's just
count simple 8th notes in our test case (one can consider a whole note as 8
consecutive "legato" 8th notes of the same pitch for our purposes).

How many bars? 8 bars might be a good starting point (many pop verses are
that, eg: <http://en.wikipedia.org/wiki/Thirty-two-bar_form> ).

So, that would gives us: 8 bars * 8 eights with 24 notes for each eight, which
gives us roughly: (8*8)^24 different melodies.

Which is like, a lot, man (think 40-figure range).

In practice it could be from much less (considering key constraints which
limits the notes you could use) to much more (considering higher than 2
octaves Zappa or avant-guard like melodies, durations shorter than 8ths, etc).

Another major factor is the "melodic quality" of the melody, which is kinda
subjective. 8 bars of 8th C notes, for example, wouldn't be that interesting,
and many people would not even consider them a melody.

Still that would leave billions of quality melodies in the millions of
trillions of possible melodies.

