Guest User

pg-seq.nb

a guest
Aug 21st, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1.  
  2. << Music`
  3. f2m[f_] := IntegerPart[Log[2, f/440.0]*12 + 69]; (* freq\[Rule]midi*)
  4.  
  5. freqs[notes_, scale_] := With[{
  6. cents =
  7. scale[[1 + Mod[#, Length[scale]]]] +
  8. 1200 Quotient[#, Length[scale]] & /@ notes},
  9. 440 (1 + cents/1200.0)
  10. ]; (* convert notes to freqs in a scale *)
  11. arp[s1_, s2_] :=
  12. s1 + # & /@ s2 //
  13. Flatten; (* repeat on seq of numbers on top of another *)
  14. playfreqs[freqs_, duration_] :=
  15. Sound[SoundNote[f2m[#] - 69, duration] & /@ freqs]; (* play notes *)
  16. seq = Table[{0, 2, 4, 2}, {i, 0, 2}] // Flatten;
  17. playfreqs[
  18. freqs[arp[{0, 2, 4}, seq], TemperedMajor]~Join~
  19. freqs[arp[{0, 2, 4}, seq], TemperedMinor]~Join~
  20. freqs[arp[{0, 2, 6}, seq], TemperedMajor]~Join~
  21. freqs[arp[{0, 2, 4}, seq], TemperedMinor],
  22. 0.125
  23. ]
Advertisement
Add Comment
Please, Sign In to add comment