# Math PI represented musically

I'm creating a program to output the values of pi as sound. I've seen a few videos and some other representations, and want to try to make my own for fun, except i'm unsure how to proceed.

There are the notes A,B,C,D,E,F, and G.

Unfortunately, there are 10 possible values for a digit, 1,2,3,4,5,6,7,8,9, or 0. I read something about a rule of fifths, but I am unsure how I would map the 10 numbers to sound. I'm not sure if this is the right place to ask this question.

How would you go about mapping a sound to numbers 0-9? I'd like to keep the spread as even as possible, so if every possible sound was on a line, 0-9 would be evenly distributed, if that makes sense.

Sorry if this is in the wrong location.

• It's pretty irrelevant, but I just had to post this, as I love it: m.youtube.com/watch?v=BDMBtQjS1bQ – Bob Broadley Aug 28 '14 at 23:00
• I'm rather surprised this got so many upvotes. As both a musician and a mathematician, I'd reject this question for vapidity! If you want to encode $\pi$ into tones, then map each digit to a note. If you want to create a piece which is representative of $\pi$ , then write something evocative of circles, spheres, and radiuses. – Carl Witthoft Aug 29 '14 at 11:58
• I know little of music, but if you have seven notes, just use pi in base 7 mathematically... turner.faculty.swau.edu/mathematics/materialslibrary/pi/… – Mark Aug 29 '14 at 13:12
• @CarlWitthoft: I agree. Alternatively, one might use a π/4 time signature, or use intervals with frequency ratio π:3 as the melodic step size. But using the digits of π is basically just like using a random stream of numbers. – leftaroundabout Aug 29 '14 at 14:18

One option if you're primarily interested in representing the individual digits of pi is to use a representation in a base other than 10. For example pi base 12 would have an individual digital for each chromatic note.

Here's a website that might help get you started: http://www.virtuescience.com/pi-in-other-bases.html

The number 10 doesn't necessarily map well to values in traditional musical theory. (For instance, there are 12 chromatic pitches per octave, using conventional divisions of the octave; diatonic scales have seven pitches; note durations are related as powers or negative powers of 2). So, for this reason, the world is your oyster! I guess you can choose any 10 values to map to the 10 digits.

This does mean that you are unlikely to get a definitive answer (and so some may consider this post to be off-topic), but here are some of my own suggestions for suitable mappings:

1. Divide an octave by ten (i.e. use 10-TET) although this youtube clip suggests somebody may have beaten you to it…!
2. Use 10 different chords.
3. Use 10 different note durations (which could be either related by powers of 2, or as tenths of a particular value).
4. Use a pair of interlocking pentatonic scales (I like this idea, maybe stereo separated, but it's not my project…)
5. Use a combination of the ideas above, eg. different frequencies each also have their own related duration (and stereo positioning…)

In the end, I came up with these ideas very quickly, the possibilities are vast, and experimentation is the key.

ADDITIONAL INFO: If you are trying to find the frequencies in 10-TET tuning you would multiply a starting frequency by 2 to the power of n/10, where n is integer values in the range 0-9.

• You could use pi in base 7 or base 12. – Cole Johnson Aug 29 '14 at 6:17

Pi can also be expressed through various infinite series. I like François Viète series discovered in 1593:

Square root from 2 is half octave distance. Maybe it is possible to represent the series as some sequence of sounds? Or maybe some other series would fit better? This might reproduce the spirit of Pi even better than replaying its decimal representation.

One Idea I haven't seen mentioned is rhythm. Perhaps you can use some of the spare digits as a change in pace (f.e. switch from eights to quavers). Or you could map the spare digits to pre-conceived rhythmic motives.

Another idea would be to use the digits that are not mapped to a note to switch instrument.

HTH.

Why use base 10? You have to make some compromise somewhere, and since π is already transcendental, there is no rational radix that will accurately represent π. If you use heptary, π ≈ 3.0663651432036134110263402244652226643520650240155443215426431025161154565220002622436103301443233631. These digits map perfectly to the seven pitches in an octave. Using octal would add in either a b3, b7, or #4. Quintary would yield a perfect pentatonic scale.

If you want to make a nice piece of music (which I presume you do, simply encoding pi would seem a bit wasteful), I'd avoid trying to generate the music mechanically, and instead use pieces of pi as inspiration.

For instance:

• Writing it in 22/7 (an approximation of pi)
• Using the first 5 or so digits as a motif in some way, and using the others not as much. You could then have another 50 or so digits as a fast cadenza type section.
• Using cyclical chord progressions (pi being about circles)

There's no reason you have to stay within one octave. You can use, for instance, C-D-E-F-G-A-B-c-d-e for your digits. So the first five notes are E-C-F-C-G-d, for example This has the advantage of being extremely intuitive to any musician, since you'd just be referring to scale degrees in C major (with 10 being 0). I can personally just sit there and read the notes and play them without thinking about it.

With the minor key you are using, you could also borrow from the major, ala the harmonic minor. Then you could use A-B-C-D-E-F-F#-G-G#-a. This isn't as intuitive, but it produces some interesting effects, without seeming completely chromatic. The first few notes become C-A-D-A-E-G#-B-F-E-C-E G-G#-F#-G#-C-B-C-G-D-F B-F-D-C-C-G-C-B-F#-G#-E-a. That last bit sounds like an actual cadence.

As a programmer, I love this idea and of course I thought about this as well already but didn't have any time yet to try this out :).

Basically, I believe your line with notes is incorrect. You should start by choosing a key in which you want to write it. I believe your key would be Am, or is it a coincidence? I would work with something like this:

    char notes[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
String pi = String.valueOf(Math.PI);
for(int i = 0; i < pi.length(); i++) {
char currentChar = pi.charAt(i);
if(currentChar != '.') {//negate the decimal didigt
System.out.println(currentChar);
char currentNote = notes[(Integer.parseInt(currentChar + "") - 1) % notes.length];
System.out.println(currentNote);
}
}


Note that this is Java.

EDIT: This code is designed so that if you have a number that is larger than the amount of notes provided, it will start from the first note again. So 8 would be back note 0 (A).

Other answers have suggested using different bases. For an event in the Physics department, I did play pi in quintal, and there is a video. The sheet was generated using a script and Lilypond.

Bonus: also in octal, but this one is not annotated.

An option which no one has really mentioned is to use those extra digits for special purposes (ie Change tempo, another instrument). If the primary instrument is a piano, I'd imagine that simply assigning a digit to the snare, bass and cymbal would add a lot of flair to your final music.

In fact, adding new instruments will open you up to a bunch of new ways to do this. You could let each digit represent an operation. Each operation could represent an instrument, tempo, or effect change, etc... Also, each operation would then read in as many more digits as it needed in order to satisfy it's parameter count. This will allow for your beats to have things like sustain, accent, etc... for your notes.

This will actually make the problem of having more data space than note space even more of a problem except for the fact that it was never really a problem to begin with. Just pad the extra space with the next higher and lower octaves. This will result in a slight imbalance of notes but we don't really want a balance anyway...

Which does lead us to another problem. I think your best bet is to use patterns found in popular music to ensure that your note dispersion is pleasant. I found this site which has the data we'd want for determining that:

Your application will be more likely to sound better when it produces notes with a similar dispersion pattern to this. You may find that some instruments may work vastly differently though so (as with all of this) experimentation will be important.

Once you have this system working, I'd suggest trying to think of another song which it sounds similar to what you have and doing a more exact note dispersion graph which actually matches a song in the same key. Read the page at the link above to see what I mean.

If you wanted to step it up another notch, you'll have the ability to add as many functions as you want. You just need to decide how large an op code is (1,2,3 chars) depending on how many different functions you have and handle them all (even if large blocks of them do the same thing). If you really want this to be a complex symphony, I would suggest that you separate the processing step from the playback step to eliminate any timing issues you'll have due to the variable data rate inherent to such a design. Fortunately, there are standards. One popular standard is called MusicXML. If you make your program to simply generate those files. Then you can later play those files back using a MusicXML player.

Update: If you'd like to see my experiments with this you may get them here.

• hooktheory.com/blog/… It says nothing about "instruments sounding better" in a specific key. It just presents the data as "there is a general trend favoring key signatures with less sharps and flats but this is not universal." – Von Huffman Aug 29 '14 at 19:57
• That's not how it works, at all. That's now what the article claims, at all. The Garage Band application (the "smart instruments" app) shows and uses the diatonic chords of the harmony you select, you can select any key. It sounds good because of the diatonicism of the possible chord progressions, not because it is in a specific key. Your understanding of the article is completely broken, distorted, misleading, and completely wrong. You and the article are claiming and talking about very different things. It's evident that you don't know about what you are talking about. – Von Huffman Aug 30 '14 at 0:18
• I've got to back @JCPedroza up on this one. Unless you have perfect pitch you won't know the difference between C major and Db major when you listen to piece. It's completely wrong to think that this half step accounts for a 20% drop in popularity because C major sounds better. C major is popular because it's all natural notes (i.e. white keys on the piano) which are easier to play and write, especially for people without formal training. Your'e 100% wrong, krowe, in the conclusions you've drawn from this article. – MarkM Aug 31 '14 at 3:56
• @krowe, fine, but if you don't care WHY a key is more popular why do you keep asserting things like: "At the end of the day these keys are the most common because they sound better." That is a (unsupported) answer to the question WHY the key is more popular that you say you don't care about. – MarkM Sep 1 '14 at 18:59
• @krowe - I'm definitely on the side of JC and Mark. Those keys are most common because they are easier to read and write. A lot of instruments were designed around these keys, as early music was Modal and the use of #/b were not common or necessary. Other instruments are transposed and have certain tendencies, such as music written for horns having more b's than #'s. So more Jazz stuff is in flat keys and more rock stuff is in # keys (due to guitars). The piece of your argument (specific to the topic of keys) that is agreeable is that certain keys are more common but I'd say that is all. – Basstickler Sep 2 '14 at 12:49

Here's another idea, bizarre even by my standards. For those not familiar w/ the 12-tone composition rule (as originally stated; probably changed many times), it says you cannot repeat any tone until the other 11 have been played. Serially or in chords is allowed.

So here's the "12-tone pi" composition rule: For each digit of pi, you're allowed to skip that many tones in the next 12-cycle. E.g., first cycle only needs 9 (12-3) tones before repeating; the next cycle needs 11 (12-1) tones, and so on.

Bonus points if you can make the piece NOT sound like Webern or Berio :-)

• Dudes: downvoting sans reason is considered poor form. Other than perhaps allowing too much interpretability by the composer, what's wrong with this approach? – Carl Witthoft Sep 2 '14 at 14:47