yue

Programmatic music library

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
(include "lib.scm")

; https://musiclab.chromeexperiments.com/Song-Maker/song/5761928473608192
; https://musiclab.chromeexperiments.com/Song-Maker/song/6414430911070208
(define (melody t)
	(apply + (map (lambda (x)
	(apply (lambda (octave pitch start len) ((note (getfreq octave pitch) start len) (- t 32))) x))
		'(
			; (2 5 0 1/4)
			; (3 0 1 1/2)
			; (2 8 3 1/4)
			; (2 7 4 1/2)
			; (2 5 6 1/4)
			; (3 1 7 1/4)
			; (3 0 8 1/4)

			; (2 5 0 4)
			; (3 0 8 4)
			; (2 3 18 1)
			; (2 10 20 1)
			; (3 0 22 1)
			; (3 1 24 1)
			; (3 0 26 1)
			; (2 10 27 1)
			; (2 5 28 1)
			; (3 0 30 1)
			; (2 5 32 4)
			; (3 0 38 4)
			; (2 3 42 1)
			; (3 1 44 1)
			; (3 1 48 1)
			; (2 10 49 1)
			; (3 0 50 1)
			; (3 1 51 1)
			; (2 10 52 1)
			; (2 8 53 1)
			; (2 10 54 1)
			; (3 0 56 1)
			; (3 1 58 1)
			; (3 0 60 1)
			; (2 8 62 1)
			(2 5 1 2)
			(3 0 7 2)
			(2 10 15 2)
			(3 1 19 2)
			(3 0 21 2)
			(2 10 29 1)
			(3 0 30 2)
		))))

(define (base t)
	(apply + (map (lambda (x)
		(apply (lambda (octave pitch start len) ((note (getfreq octave pitch) start len) t)) x))
		'(
			(1 5 1 1)
			(1 8 4 1)
			(2 5 7 1)
			(2 0 9 1)
			(1 10 10 1)
			(1 8 12 1)
			(1 7 15 1)
			(1 8 17 1)
			(1 7 18 1)
			(2 3 19 1)
			(1 8 21 1)
			(2 0 22 1)
			(2 3 23 1)
			(2 5 25 1)
			(2 5 29 1)
			(2 0 30 1)
			(2 3 31 1)))))

(define (music t)
	(+ (* 1/2 (tri (* t (melody (floor-remainder (* t 8) 64)))))
		(* 1/4 (tri (* t (base (floor-remainder (* t 8) 32)))))))