Cの行方 #1

0

Cの行方
https://youtu.be/2yYRQTq7sPI

レガシーな言語の代表「COBOL」で作る音楽。

中央ド(note.no=60)から始まる512個の音符を作り、これを演奏させてみます。それぞれの音は直前の音から長三度の範囲で上下させます。音域は中央ドの上下4オクターブ。

program-id. mus03.

data division.
working-storage section.
01 i pic 999.
01 j pic 999.
01 r pic 9(6).
01 l pic 9(6).
01 h pic 9(6).
01 n pic s999.
01 u pic 9.
01 p pic 999.
01 note pic 99.

procedure division.
display 'C whereabouts of' upon syserr
compute r = function random(2014)
display 'Tempo=120'
perform varying i from 1 by 1 until i > 2
compute p = 64 * i - 32
display 'TR=' i ' P=' p ' @Marimba v.Random(32) l16'
compute note= 60
perform varying j from 1 by 1 until j > (8 * 64)
display 'n(' note ') '
compute l = 1 compute h = 4 perform randomn compute n = r
compute l = 1 compute h = 2 perform randomn compute u = r
if u = 1 compute n = n * -1 end-if
compute note = note + n
if note > 84 compute note = 84 end-if
if note < 48 compute note = 48 end-if
end-perform
end-perform
exit program.

randomn.
compute r = function rem(function random * 123456789 (h - l + 1)) + l.

Default