From 94526a4ccb6faedcb410d30ea1b6c67d3d8f5e48 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Sat, 21 Jan 2023 21:58:22 -0500 Subject: Start implementing new song --- lambeat.scm | 4 +-- lib.scm | 3 +- music.scm | 91 +++++++++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 70 insertions(+), 28 deletions(-) diff --git a/lambeat.scm b/lambeat.scm index c6b506b..5214b56 100644 --- a/lambeat.scm +++ b/lambeat.scm @@ -2,7 +2,7 @@ (include "music.scm") ; Bitrate is the number time to sample the music function each second -(define bitrate 44100) +(define bitrate 8000) ; Get the music as a list sampled at the bitrate (define (play t end) @@ -14,4 +14,4 @@ (play (+ t (/ 1 bitrate)) end) '()))) -(play 0 100) +(play 6 100) diff --git a/lib.scm b/lib.scm index 0038c58..36a65c4 100644 --- a/lib.scm +++ b/lib.scm @@ -15,8 +15,7 @@ (lambda (t) ( if (or (< t start) (>= t (+ start len))) 0 - (* 1/4 (tri (* 1.5 t freq)))))) -; + (* 1/4 (tri (* t freq)))))) ; Gets the frequency of a particular pitch (define (getfreq octave pitch) diff --git a/music.scm b/music.scm index 3680c2a..b779eee 100644 --- a/music.scm +++ b/music.scm @@ -1,32 +1,75 @@ (include "lib.scm") +; https://musiclab.chromeexperiments.com/Song-Maker/song/6021372552937472 (define (music t) (apply + (map (lambda (x) - (apply (lambda (octave pitch start len) ((note (getfreq octave pitch) start len) t)) x)) + (apply (lambda (octave pitch start len) ((note (getfreq octave pitch) (/ start 2) (/ len 2)) t)) x)) '( ; opening notes - (2 2 0 .1) - (2 6 .1 .1) - (2 9 .2 .1) - (3 1 .3 1.2) - (2 0 2 .1) - (2 4 2.1 .1) - (2 7 2.2 .1) - (2 11 2.3 .6) - (1 10 3 .1) - (2 2 3.1 .1) - (2 5 3.2 .1) - (2 9 3.3 .6) - (1 7 4 .1) - (1 11 4.1 .1) - (2 2 4.2 .1) - (2 6 4.3 4.2) - - ; A melody - (2 6 9 2.5) - (2 7 11.5 .5) - (2 6 12 .5) - (2 2 12.5 .5) - (2 9 13 1) + (1 11 0 .2) + (2 3 .2 .2) + (2 6 .4 .2) + (2 10 .6 2) + (1 9 3 .2) + (2 1 3.2 .2) + (2 4 3.4 .2) + (2 8 3.6 1) + (1 7 5 .2) + (1 11 5.2 .2) + (2 2 5.4 .2) + (2 6 5.6 1) + (1 4 7 .2) + (1 8 7.2 .2) + (1 11 7.4 .2) + (2 3 7.6 4.4) + ; melody + (2 8 12 0.5) + (2 7 12.5 0.5) + (2 3 13 0.5) + (2 0 13.5 0.5) + (2 8 14 0.5) + (2 7 14.5 0.5) + (2 3 15 0.5) + (2 0 15.5 0.5) + (2 8 16 0.5) + (2 7 16.5 0.5) + (2 3 17 0.5) + (1 10 17.5 0.5) + (2 8 18 0.5) + (2 7 18.5 0.5) + (2 3 19 0.5) + (1 8 19.5 0.5) + (2 8 20 0.5) + (2 7 20.5 0.5) + (2 3 21 0.5) + (2 5 21.5 0.5) + (2 8 22 0.5) + (2 7 22.5 0.5) + (2 3 23 0.5) + (2 0 23.5 0.5) + (2 8 24 0.5) + (2 7 24.5 0.5) + (2 3 25 0.5) + (1 10 25.5 0.5) + (2 8 26 0.5) + (2 7 26.5 0.5) + (2 3 27 0.5) + (2 10 27.5 0.5) + (2 8 28 0.5) + (2 7 28.5 0.5) + (2 8 29 0.5) + (2 0 29.5 0.5) + (2 8 30 0.5) + (2 7 30.5 0.5) + (2 3 31 0.5) + (1 10 31.5 0.5) + (2 8 32 0.5) + (2 7 32.5 0.5) + (2 8 33 0.5) + (2 10 33.5 0.5) + (2 8 34 0.5) + (2 7 34.5 0.5) + (2 3 35 0.5) + (2 0 35.5 0.5) )))) -- cgit v1.2.3-70-g09d2