15
6
Yup, you read the title right. play the sound of pi.
More specifically, for every digit of pi in the first 1000, map it to a musical note and output the resulting melody to a file.
Basically, each digit turns to a note on the C Major scale (basically the normal scale). so 1 turns to Middle C, 2 turns to D4, 3 turns to E4, 9 turns to D5 and so on.
Rules
- Each note should be exactly 0.5 seconds long.
- The melody should contain the first 1000 digits of pi, including the starting 3.
- 1 to 7 represent Middle C to B4, 8 is C5, 9 is D5 and 0 is E5
- All well supported file formats are allowed, as long as they were created before this challenge.
- There may be no pauses anywhere in the file, including the start and end.
- The instrument played does not matter. It could be a piano, sine wave, anything really, as long as the correct sound is easily hearable.
- It must take no input and produce no output except for the file. Reading from other files is disallowed.
- Standard loopholes are forbidden.
Example mathematica code:
(*please forgive me for this horrible, horrible mess of code*)
digits = RealDigits[Pi, 10, 1000][[1]] /. {0 -> 10};
weights = {0, 2, 4, 5, 7, 9, 11, 12, 14, 16};
melody = {};
For[i = 1, i < 1001, i++, melody = {melody , Sound[SoundNote[weights[[digits[[i]]]], 0.5]]}]
final = Sound[Flatten[melody]];
Export["C:\\Mathematica Shenanigans\\pi.wav", final];
Example melody showing first 100 digits: http://vocaroo.com/i/s0cfEILwYb8M
For your sanity, A table of pitches for each note and what note does each digit represent:
Digit 1: C: 261.63 Hz
Digit 2: D: 293.66 Hz
Digit 3: E: 329.63 Hz
Digit 4: F: 349.23 Hz
Digit 5: G: 392.00 Hz
Digit 6: A: 440.00 Hz
Digit 7: B: 493.88 Hz
Digit 8: C5: 523.25 Hz
Digit 9: D5: 587.33 Hz
Digit 0: E5: 659.25 Hz
59 turns to D5 You should clarify that the other notes are in the
4
-th octave. Also, in your table does digit0
come last (E5
)? – Luis Mendo – 2017-01-17T22:11:30.3571@LuisMendo Yes it does. I'll make these too more clear. – sagiksp – 2017-01-18T04:57:38.127
1Can we assume 'well supported formats' to mean anything openable by vlc? – Pavel – 2017-01-18T06:14:17.960
@Pavel Pretty much – sagiksp – 2017-01-18T08:58:20.537
Can I output the note names (e.g. 3.14 --> ECF) if my language does not support sound or writing to sound files? – FinW – 2017-01-18T19:42:52.493
@Everyone someone post a TIO link already, I want to hear pi to the millionths place. – Magic Octopus Urn – 2017-01-18T20:52:48.900
Can I play the notes instead of writing them to a file? – BookOwl – 2017-01-18T21:03:48.297
@BookOwl As long as it's the same as a file, sure! – sagiksp – 2017-01-20T19:53:40.870
@FinW You can write to a midi file, which doesn't need a lot of complicated code and libraries. – sagiksp – 2017-01-20T19:54:49.903