# Musical algorithm

## Main Question or Discussion Point

I have heard that it is possible to convert music notes into mathematical numbers. To create an algorithm, can you use musical notes, or patterns?

Related Linear and Abstract Algebra News on Phys.org
I suppose you could assign musical notes to symbols and then use the symbols to encode an algorithm.

I don't know how pleasant the tune would be, though. I guess it depends on the encoding scheme, the distribution of notes, and the algorithm being used.

CRGreathouse
Homework Helper
Sloane's OEIS has the option to play a given sequence as music.

Musical notes are actually just frequencies. For example vibrations at 440 Hz are an "A" note. You move up and down the musical scale by multiplying the frequency against fixed constants. For example multiplying the frequency by 2 moves your tone up one octave, dividing the frequency by 2 moves it down one octave. The difference between what we think of as "notes", i.e. semitones, is achieved by multiplying or dividing by the 12th root of two (there are twelve semitones per octave). Multiply by the 12th root of 2 twelve times, of course, and that is equal to one octave. You have to stay within the range of about 20 hz to 20,000 hz or the human ear will no longer be able to hear your notes.

Combinations of notes, i.e. chords, that we think of as "musical" or aesthetically pleasing are generally attained by combining notes whose frequencies fit some kind of simple ratio, like 3:2 or 4:3. If you look at music theory texts they talk about constructing chords via intervals; all vocabulary about intervals is just hiding underlying statements about frequency ratios. For example a "perfect fifth", the combination of one note and the note seven semitones up, sounds good because "seven semitones up" is really another way of saying "multiplied by (the 12th root of 2)^7", which if you type that in a calculator you'll find it is very very almost exactly equal to a frequency difference of 1.5, 3/2. To your ear, notes which are a perfect fifth apart sound like they're at a 3:2 ratio, so it sounds "good".

Note combinations that don't follow these simple ratios tend not to sound good. If you want your algorithm to sound good you're probably best off having your algorithm work by applying concepts from music theory as primitives on tones of specific frequencies. Or you can just say cat dataset.dat > /dev/audio , people will hold their ears but it will be a lot more entertaining.

Getting away from math for a moment there actually was in the 50s-70s a minor movement in avant-garde classical music toward sort of "algorithmic" music which had nothing to do with computers. Good examples here would include Terry Riley's "In C", a piece written on sheet music but constructed in such a way that the sheet music doesn't describe so much a single piece of music but instructions for constructing a piece of music-- the sheet music is sort of laid out like a choose-your-own-adventure book, with each individual musician getting to decide of their own free will how to move through the song. The idea is to get a bunch of musicians with various different instruments to perform the song all together; since each musician will wind up choosing to visit a different part of the song at different moments, complicated patterns emerge from the musicians' varying choices. John Cage also did a lot of work around this area, with one of the more interesting examples being his "Concerto for prepared piano". As I remember this was a piece in three movements: The first movement was composed by John Cage intentionally using normal principles of music composition; in the second movement, Cage actually performed I Ching throws, then used the hexagrams as effectively random-number-generator inputs to drive a sort of by-hand algorithm he'd come up with for constructing a piece of music; then in the third movement the notes were determined entirely by the random results of the I Ching. The effect was to sort of chart the composer gradually removing himself from any control over his own music over the course of the concerto...

atyy
Listen to the segment "Musical DNA".

Last edited by a moderator:
I have heard that it is possible to convert music notes into mathematical numbers. To create an algorithm, can you use musical notes, or patterns?

Only when one considers that the math of music is comprised of two seperate sets of time coordinates; simply stated: beats and rhythms.

They are "woven" into a harmonious ratio, defined as "time signatures".

JS Bach was the "master" of the mathematics in music.

His publication , the Well-Tempered Clavier (1722), is generally regarded as one of the most influential works in the history of Western classical music.

http://en.wikipedia.org/wiki/Well-Tempered_Clavier

The math you seek can be found in that book; but the ONLY way to "translate" the "math of music", into the "math of physics" is by adding another "clock" to the real world.

When considering a world of "two-times", Cumrun Vafa said: "F THAT!!"

http://en.wikipedia.org/wiki/F-theory

Michio Kaku considered these "two-times" here:

http://mkaku.org/home/?page_id=262

Is the End in Sight?
Vafa recently added a strange twist to this when he introduced yet another mega-theory, this time a 12 dimensional theory called F-theory (F for “father”) which explains the self-duality of the IIb string. (Unfortunately, this 12 dimensional theory is rather strange: it has two time co-ordinates, not one, and actually violates 12 dimensional relativity. Imagine trying to live in a world with two times! It would put an episode of Twilight Zone to shame.

Twilight zone?? Twi--light.....twine time!! How about a string theory based on TWINE!! Twi = TWICE !!

Lets awaken ole' JS Bach from the grave, and ask him what he thinks about a "two-time based string theory":

Two-timed string theory?? Is there ANY other way of doing it??

Last edited by a moderator:
Not only can you "see" these two-times on paper, you can "hear" them as well.

Now thats what I call science !!

atyy
Lets awaken ole' JS Bach from the grave, and ask him what he thinks about a "two-time based string theory":

Two-timed string theory?? Is there ANY other way of doing it??
Hemiola

Hemiola
As a "Mopar" fan,"Hemi" is "king" !!
http://www.authenticdodge.com/images/hemi.jpg

Great link !! Check out the term " three breves" in the above link.

...the word came to mean the use of three breves in a bar ..

"Breve" is synomanous with "brevis", and after a closer reading, it appears that "breve" or "brevis" is synomanous with "bravis" or the same concept as "bravis lattice".

http://en.wikipedia.org/wiki/Breve_(music [Broken])

http://en.wikipedia.org/wiki/Bravais_lattice

Mozart it seems, is a "two-timer" or even a "three-timer" as well.

Last edited by a moderator:
Ok, I got it.

First, we must state the two fields of Mathematics we will be analogizing: Trigonometry, and Calculus.

In life, there is what is "real", then there is the "score".

For example: in football, two exact same events can have different outcomes. A field goal and an extra point are identical, looked at as simply as the being ball kicked through the goal posts. However, the field goal is three, the extra point is one; when they are "scored".

The point: there is what is physically real, or Trigonometry; and the represented score, or Calculus.

However, there is the concept of the 'interval' in Trigonometry of pure counting: there are no "time-based" measures. Calculus has both an “interval count“, and a “time count“.

There is one additional “time count” that “harmonizes” the Trigonometry with the Calculus.

Now this ain’t “String Theory”; this is “String Fact” or “Six String Fact”.

There are physically six strings on a guitar. However, music is hard for non-musicians to understand. So I want to use another physically real situation to show how music works.

Two mathematics, two intervals, two times, six strings, and one performance.

But the strings need to “play”, so we split them in two teams: three strings each. Then we play football !!

Before we “score”, we must build:

There are 11 players or “tones”, that can be “active” on each team at a time; 22 on the field total.

There are three strings on each team, or 3 groups of 11. However, there is a total roster of 57 players on each team, or 114 total players: “114 possible places to make noise”. Some are never used or are “duplicates”, two can’t physically play at all; however, they physically have a “roster spot”.

The 114 “roster spots” is derived from the classic guitar specifications of 19 frets. Since there are 6 strings we get 114. (19 * 6 = 114).

Summary so far:

Two teams - three strings.

114 players - 57 on each team - but only 56 actually can make noise, or “play”.

112 physically existing sounds - 2 can’t physically “play“, but have a “physical position” on the teams.

Continuing:

On each team of 11: there are 7 down line-men or “notes”; and 4 backs or “tones”. The seven in football are: the center, two guards, two tackles, two ends. The 4 tones are: quarterback, two halfbacks, one full back.

Consider that arrangement identical for offense or defense. Consider the offense as the “point” and the defense as the “counter-point” terms in music.

The single field in football is the same as “two measures - two clefs” in music.

Consider the top measure as offense, the bottom measure as defense. Now the big difference between music and football, is that both “offences“, and both “defenses” are playing simultaneously.

The total field length is 120 yards: two end zones of 10 yards each, 100 yards of “playing field”.

Length wise: there are 4 “bars” for boundaries: 2 goal lines and 2 end lines.

The field is 53 and 1/3 yards wide.

Each “team” of 3 strings or “chord”: can score 3 different conditions going forward and 1 condition going backwards.

Forward: touchdown, or 6 points; extra point, "1 or 2 points" ; field goal or 3 points.
Backwards: safety, or 2 points.

Forward scoring: 6 + (1 or 2) + 3 = 10 or 11. Backwards scoring: - 2; or musically speaking for later: “a four point save”

Last edited:
Lets count elevens so far:

Each team has three strings: eleven players each, on offence and defense.

There are six total elevens here, but each group of eleven has to go in two directions.

It could be said there are 12 elevens here: 6 primary, 6 secondary.

This set is pure Trigonometry based.

The next set is the 22, or 2 groups of 11, playing “in the game” at a time. These 2 groups of eleven are Calculus based on time and intervals, and always tied to the Trigonometry they were “built with”.

So far we have 14 “sets” of elevens; or 12 sets of 11, and 1 set of 22.

There are two more sets of 11: the combined total for each teams forward scores. However, each set only has 4 members: (6, 3, 2, 1).

16 total sets of elevens.

Less obvious but other sets elevens

Each team has 56 players who can physically play. Subtract the number of string players: 33 on each team leaves the 23 reserve players.

The 23rd hour is also 11 pm.

56 can be “summed” as 5 + 6 = 11

These make 4 additional sets or groups of 11

I had a go at turning the 'music of the primes' into piece a while ago. It was in 6/8 time (6 quavers in the bar), with each quaver representing a number. Multiples of two were assigned Sound A, multiples of 3 were assigned Sound B. This sets up a backbeat. The first quaver in the bar will be at 6n. There will be a rest on the second and last quaver - which is where the primes and their mutliples go.

To hear this backbeat clap the rhythn of the words 'nice cup of tea' repeatedly, using your hands - Together, Right, Left, Right,, T,R,L,R, ... Now your left hand is playing twos against your left hand's threes. Where either of 6n+/-1 is a not prime there is a rest, where it is a prime a triangle chimes.

Didn't work as music but it was fun trying to programme the sequencer.