RosettaCodeData/Task/Musical-scale/Lambdatalk/musical-scale.lambdatalk
2023-07-01 13:44:08 -04:00

28 lines
718 B
Text

Using the musicalScale() javascript function found in this wiki page, we build a lambdatalk interface to output the 8 notes of the C major diatonic scale, and more.
{def note
{lambda {:i}
{round {* 261.63 {pow 2 {/ :i 12}}}}}}
{def scale
{lambda {:notes}
[{S.map {lambda {:i} {note :i},} :notes}]}}
{def play
{lambda {:n}
{input {@ type="button"
value="Play :n"
onclick="musicalScale({scale :n});"}}}}
1) diatonic up
{play 0 2 4 5 7 9 11 12}
2) diatonic down
{play 12 11 9 7 5 4 2 0}
3) twelve notes of the octave plus one
{play {S.serie 0 12}}
4) one more ... from Fantasia (Disney Studios, 1940)
{play 0 2 3 5 7 3 7 7 6 2 6 6 7 3 7 7 0 2 3 5 7 3 7 12 10 7 3 7 10 10 10 10}
->