Techno Classical (COBOLで音楽を生成 -2-)

初版 2019/08/18 00:21

改訂 2019/08/18 00:50

今となってはClassical なプログラミング言語「COBOL」で音楽を生成する実験。2つ目は、プログラムででMML(テキストデータ)を生成し、これをMIDIにコンパイルする方法で作成しました。


私が使っているCOBOL環境はOpenCOBOL(Windowsでもmacでも使えます)です。オープンソースのCOBOLコンパイラで、COBOLコードをCのコードに変換してGCCでコンパイルします。



汎用機でCOBOLを使い始めた頃は、コンパイラーが吐き出すアセンブラーのソースコードを見て、アセンブラーの勉強をしました。OpenCOBOLでもCのコートを作ってくれるので、これを眺めると、なるほどという感じでどんな仕掛けで動いているのかがわかります。


Techno Classical

https://yamazawa.bandcamp.com/album/techno-classical


Techno Classical | YAMAZAWA

Techno Classical by YAMAZAWA, released 29 July 2015 1. 未熟女 2. R31.415 3. 白と赤 4. ニッチマン unlimited 5. NON-STOP OSC

https://yamazawa.bandcamp.com/album/techno-classical


アルバム「Techno Classical 」の簡単な解説です。


Techno Classical (03 - 白と赤 ) by A_COMPANY | Free Listening on SoundCloud

Stream Techno Classical (03 - 白と赤 ) by A_COMPANY from desktop or your mobile device

https://soundcloud.com/a_company/techno-classical-03




[ソースプログラム]


program-id. otoiro2.

environment division.

input-output section.

file-control.

select txt-file assign txtf organization line sequential.

select prm-file assign prmf organization line sequential.

select mml-file assign mmlf organization line sequential.


data division.

file section.

fd txt-file label records standard.

01 txt-rec pic x(128).

fd prm-file label records standard.

01 prm-rec pic x(512).

fd mml-file label records standard.

01 mml-rec pic x(128).

working-storage section.

01 i pic 9(4).

01 j pic 9(4).

01 k pic 9(4).

01 x pic 9(4).

01 y pic 9(4).

01 t pic 9(4).

01 r pic 9(6).

01 l pic 9(6).

01 h pic 9(6).

01 n pic x(20).

01 msrn pic 9999.

01 seed pic 9999.

01 txtf pic x(20).

01 prmf pic x(20).

01 mmlf pic x(20).

01 inst pic x(60).

01 cmd pic x(40).

01 edw pic x(10).

01 ef pic x value low-value.

01 filler.

02 mhdr pic x(80).

02 occurs 8.

03 thdr pic x(80).

03 lc pic 99.

03 lg occurs 10 pic x(3).

03 pc pic 99.

03 pt occurs 17 pic x(20).

01 filler.

02 occurs 1024.

03 rgb occurs 3 pic 9(3).

01 ppm.

02 c occurs 15 pic x(4).

01 filler.

02 pml pic x(128).

02 pmn pic x(320).

01 filler.

02 filler occurs 3.

03 cc occurs 17 pic 9(4).


procedure division.

display "oto-iro 2" perform prm-set

display "txt :" txtf display "prm :" prmf display "mml :" mmlf display "seed:" seed

open input txt-file open output mml-file

read txt-file into txt-rec

read txt-file into txt-rec

read txt-file into txt-rec

unstring txt-rec delimited ' ' into x y

read txt-file into txt-rec


compute i = 0 move low-value to ef

perform until ef = high-value

read txt-file into txt-rec

end move high-value to ef

not end perform mml-set

end-read

end-perform

compute t = i

display 'Tone Number = ' t


perform varying i from 1 by 1 until i > t

perform varying j from 1 by 1 until j > 3

add 1 to cc(j,rgb(i,j)) add 1 to cc(j,17)

end-perform

end-perform

perform varying i from 1 by 1 until i > 17

if i = 17

display '==== ' cc(1,i) ' ' pt(1,i) cc(2,i) ' ' pt(2,i) cc(3,i) ' ' pt(3,i)

else

display i ' - ' cc(1,i) ' ' pt(1,i) cc(2,i) ' ' pt(2,i) cc(3,i) ' ' pt(3,i)

end-if

end-perform


write mml-rec from mhdr display mhdr

perform varying j from 1 by 1 until j > 3

write mml-rec from thdr(j) display thdr(j)

perform varying i from 1 by 1 until i > t

compute l = 1 compute h = lc(j) perform randomn

move pt(j, rgb(i,j)) to n

move ' ' to mml-rec

string 'l' lg(j, r) n delimited size into mml-rec

write mml-rec

end-perform

end-perform


close txt-file mml-file

string 'cSakura -p ' mmlf '> nul' into cmd call 'SYSTEM' using cmd

stop run.


prm-set.

perform

display 1 upon argument-number accept txtf from argument-value

if txtf = " " move "tmp.ppm" to txtf end-if

display 2 upon argument-number accept prmf from argument-value

if prmf = " " move "prm.txt" to prmf end-if

display 3 upon argument-number accept mmlf from argument-value

if mmlf = " " move "tmp.mml" to mmlf end-if

display 4 upon argument-number accept seed from argument-value

compute r = function random(seed)


open input prm-file move low-value to ef

perform until ef = high-value

read prm-file into prm-rec

end move high-value to ef

not end perform trk-set

end-read

end-perform

close prm-file

end-perform

exit.


trk-set.

perform

evaluate prm-rec(1:1)

when "*"

continue

when other

evaluate prm-rec(1:2)

when "//"

move high-value to ef continue

when "Te"

move prm-rec to mhdr

when "TR"

unstring prm-rec delimited " " into edw

compute i = function numval(edw)

move prm-rec to thdr(i)

when other

unstring prm-rec delimited all ' ' into pml pmn move 0 to lc(i) pc(i)

unstring pml delimited '/' into

lg(i,01) lg(i,02) lg(i,03) lg(i,04) lg(i,05) lg(i,06) lg(i,07) lg(i,08) lg(i,09) lg(i,10)

tallying lc(i)

unstring pmn delimited '/' into

pt(i,01) pt(i,02) pt(i,03) pt(i,04) pt(i,05) pt(i,06) pt(i,07) pt(i,08) pt(i,09) pt(i,10)

pt(i,11) pt(i,12) pt(i,13) pt(i,14) pt(i,15) pt(i,16)

tallying pc(i)

end-evaluate

end-evaluate

end-perform

exit.


mml-set.

perform

move ' ' to ppm

unstring txt-rec delimited ' ' into

c(01) c(02) c(03) c(04) c(05) c(06) c(07) c(08) c(09) c(10)

c(11) c(12) c(13) c(14) c(15)

end-unstring

perform varying k from 0 by 1 until k > 4

if c(k * 3 + 1) not = ' '

compute i = i + 1

perform varying j from 1 by 1 until j > 3

compute rgb(i,j) = (function numval(c(k * 3 + j)) / 16 + 1) * 1.25

if rgb(i,j) > 16 compute rgb(i,j) = 16 end-if

end-perform

end-if

end-perform

end-perform

exit.


randomn.

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



#プログラミング  #COBOL

様々なプログラミング言語を使って、音楽を自動作曲しています。

使用している言語

・awk
・COBOL
・JavaScript
・R
・サクラ
・ドリトル
・なでしこ


山澤昭彦 音楽関係プロフィール

山形県鶴岡市出身。1946年生まれ。尺八を学生時代に青木静夫(二代青木鈴募)・横山勝也の各氏から学ぶ。退職後にリコーダーを細岡ゆきに師事。
ブログラム言語を使って音楽を生成する「Generative Music」のアルバムを多数制作、近年はコンビュータを使った映像作品と生成音楽を組み合わせた「実験音楽工房展」を東京などて開催したほか、尺八古典本曲の演奏や多ジャンルのミュージシャンやダンサーとのコラボレーションなど、複合的なアート活動にも取り組んている。

2011年「実験音楽工房 A・COMPANY」プログラムによる生成音楽 制作開始
2012年「音系・メディアミックス同人即売会 M3」出展(2012 - 2015年)
2015年「厚木リコーダーオーケストラ」入団(2019年退会)
2015年「実験音楽工房展 2015」東京・山形
2016年「実験音楽工房展 2016」東京・山形・鶴岡
2017年「実験音楽工房展 2017」東京・鶴岡
2018年「県立鶴岡南高等学校吹奏楽研究会 50周年記念コンサート」企画開催
2018年「大人のリコーダーアンサンブル」(NHK文化センター 庄内教室)講師
2019年「鶴岡水上の音楽祭」芸術監督
2019年「尺八と生成映像による 観音」ライブシリーズを開始
2020年「佳興の会」をプロデュース 現在も年4回の邦楽ライブを開催中
2020年「アンサンブル・チコーニア」結成 活動開始
2020年「K×I×Y 三人展 vol.1 - 時の断片 -」SoundScape 2020
2021年「酒井家庄内入部400年記念事業 七絃琴復興プロジェクト」代表
2022年「K×I×Y 三人展 vol.2 - 時の戯れ -」フラクタルの樹・家具の音楽
2022年「酒井家庄内入部400年記念事業 芸術祭参加」音楽絵巻 その2
2023年「K×I×Y 三人展 vol.3 - 時の覚醒 -」四字熟語・ピアノのための響
2023年「鈴木順子×山澤昭彦 二人展 MindScape」@ 鶴岡アートフォーラム
2023年「山澤昭彦とその界隈」@ TACTおとアート2023
2024年「鈴木順子×山澤昭彦 二人展 CosmicEgg」@ 御茶ノ水 Gallery 蔵
2024年「Sa・Kura Music Week 2024」@ 御茶ノ水 Gallery 蔵
2025年「祈りの残照:尺八古典本曲演奏会」@ 東京大学東洋文化研究所




https://yamazawa.bandcamp.com/

Default