Don't like ads? PRO users don't see any ads ;-)
Guest

music of pi

By: a guest on May 2nd, 2012  |  syntax: Lua  |  size: 1.03 KB  |  hits: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. notes := {0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21, 23 }
  2. chords := {
  3.   {1, 3, 5},  (* C  -> C E G *)
  4.   {2, 4, 6},  (* Dm -> D F A *)
  5.   {3, 5, 7},  (* Em -> E G B *)
  6.   {4, 6, 8},  (* F  -> F A C *)
  7.   {5, 7, 9},  (* G  -> G B D *)
  8.   {6, 8, 10},(*Am -> A C E *)
  9.   {7, 9, 11}   (* Bo -> B D E *)
  10.   }
  11. num := 126
  12. duration := 1/2
  13. dellay := 0.05
  14. instruments := {"Piano", "Piano", "Piano"}
  15. pi := RealDigits[Pi, 7, num][[1]]
  16. tau := RealDigits[2*Pi, 7, num][[1]]
  17. phi := RealDigits[(1 + Sqrt[5])/2, 7, num][[1]]
  18. rnd := RealDigits[Random[Real, 1.0, num], 7, num][[1]]
  19.  
  20. snd2Pi :=
  21.  Sound[Table[SoundNote[notes[[tau[[i]] + 1]], duration], {i, 1, num}]]
  22. sndPi := Sound[
  23.   Table[SoundNote[notes[[pi[[i]] + 1]], duration], {i, 1, num}]]
  24. sndPhi :=
  25.  Sound[Table[SoundNote[notes[[phi[[i]] + 1]], duration], {i, 1, num}]]
  26. sndRnd :=
  27.  Sound[Table[SoundNote[notes[[rnd[[i]] + 1]], duration], {i, 1, num}]]
  28.  
  29. Export["2pi base 7.mid", snd2Pi]
  30. Export["pi base 7.mid", sndPi]
  31. Export["phi base 7.mid", sndPhi]
  32. Export["rnd base 7.mid", sndRnd]