Dr.Godfried-Willem RAES
Kursus Experimentele Muziek: Boekdeel 1: Algoritmische Kompositie
Hogeschool Gent
Departement Muziek en Drama
<Vorig hoofdstuk> (Sinus funktie)
<Volgend hoofstuk (Beta funktie)
1111:
In december -10 schreef Dr.Jan Kruger in opdracht van Stichting Logos een muziekteaterstuk ter gelegenheid van de opening van de tetraederzaal in gent. Voor dat stuk, gesteund op 'bioritmes' (wiskundig gezien zijn dit zuivere sinus-funkties) maakte hij gebruik van 3 AT (80286) komputers met kleurschermen, die ook elk zorgden voor de generatie van muziek vanuit sinusfunkties. Omdat het programma -hoewel soms wat omslachtig, vooral in de synthesizer besturing- enkele interessante aanpakken bevat, willen ik het hier graag als voorbeeld tonen.
CODE:
'programma BIORITMN.BAS - version using pixels
'visual part
'***********
'initial parameters:
DEFINT A-O
DEFINT S-Z
pi = 3.1415926#: screenmode = 9
' screenmode was 2 voor CGA-machines - 10 voor EGA kaart
maxhorpixel = 640: maxverpixel = 350: amplitude = 100
thickness = 18
n = 0 'n = number of periods
col0 = 15: col1 = 0: ' colors
r = 1 ' random parameter
CLS :
INPUT "change parameters y(es)/n(o)? ", change$
IF change$ = "n" THEN GOTO curve
INPUT "screenmode ? ", screenmode
INPUT "maximum horizontal pixels ? ", maxhorpixel
INPUT "maximum vertical pixels ? ", maxverpixel
INPUT "amplitude (0-100) ? ", amplitude
INPUT "thickness curve in pixels (7-15) ? ", thickness
INPUT "color foreground ? ", col0
INPUT "color background ? ", col1
curve:
INPUT "i(intelligence), e(emotion) or p(physical) ? ", curve$
IF curve$ = "i" THEN LET c = 1: LET col1 = 2: LET col0 = 10
IF curve$ = "e" THEN LET c = 2: LET col1 = 3: LET col0 = 11
IF curve$ = "p" THEN LET c = 3: LET col1 = 4: LET col0 = 12
SCREEN screenmode
COLOR 15, 0
LET t1 = CINT((thickness - 1) / 2): LET t2 = CINT((thickness - 5) / 2)
DIM thick2(1 TO 200) AS INTEGER: DIM thick1(1 TO 200) AS INTEGER
LINE (0, 0)-(0, thickness), col0
GET (0, 0)-(1, thickness), thick1: CLS
LINE (0, 0)-(0, thickness - 10), col0
GET (0, 0)-(1, thickness - 10), thick2: CLS
LET th = 1:
GOSUB parameterssound
'calculation arrays:
DIM y(3, maxhorpixel - 1): DIM maxx(3): DIM periode(3): DIM x(3)
LET maxx(1) = maxhorpixel - 1
LET maxx(2) = CINT(maxhorpixel * 28 / 33)
LET maxx(3) = CINT(maxhorpixel * 23 / 33)
LET middle = CINT(maxverpixel / 2) - 1
LET ampli = .9 * amplitude * middle / 100
FOR k = 1 TO 3: 'k=curve
LOCATE 9 + k, 25: PRINT "Wait: calculation array"; k; "!"
LET periode(k) = 2 * pi / maxx(k)
FOR x = 1 TO maxx(k)
LET y(k, x) = CINT(ampli * SIN(periode(k) * x))
NEXT x
NEXT k
'---------------------------------------------------------------
'preparation:
CLS
LOCATE 11, 25: PRINT "preparation:press any key"
LOCATE 12, 25: PRINT "start: press any key"
LOCATE 13, 25: PRINT "change: press bar "
LOCATE 14, 25: PRINT "stop: press s "
DO UNTIL INKEY$ <> "": LOOP
DIM x1(3): DIM x2(3)
FOR k = 1 TO 3
x1(k) = (maxx(1) - maxx(k)) / 2
x2(k) = maxx(1) - x1(k)
NEXT k
CLS :
LINE (x1(c), middle)-(x2(c), middle), col0
DO UNTIL INKEY$ <> "": LOOP
chcol = 0: GOTO routineprintandsnd
'--------------------------------------------------------------
changecolors0:
IF chcol = 0 THEN LET col = col1
IF chcol = 1 THEN LET col = col0
LINE (x1(c), 0)-(x2(c), maxverpixel), col, BF 'gans scherm verandert
IF chcol = 0 THEN LET col = col0
IF chcol = 1 THEN LET col = col1
LINE (x1(c), middle)-(x2(c), middle), col 'trekt lijn
RETURN
'-------------------------------------------------------------
changecolorsx:
IF chcol = 0 THEN LET col = col1
IF chcol = 1 THEN LET col = col0
LINE (xc + x1(c), 0)-(x2(c), maxverpixel), col, BF 'scherm > x verandert
IF chcol = 0 THEN LET col = col0
IF chcol = 1 THEN LET col = col1
LINE (xc + x1(c), middle)-(x2(c), middle), col 'trekt lijn
RETURN
'----------------------------------------------------------
changethicknessandr:
IF nn = 2 THEN LET th = 2: RETURN
IF nn = 3 THEN LET th = 2: RETURN
LET rchoice = RND
IF rchoice < .9 THEN nn = 0: th = 1: r = .15 + .85 * RND: RETURN nn = 1: th = 1: r = .2 + .8 * RND: RETURN
'---------------------------------------------------------------
routineprintandsnd:
FOR x = 1 TO 21253
FOR k = 1 TO 3
GOSUB glissandos
IF k = c THEN
GOSUB test: xc = x MOD maxx(c)
IF chcolbegin <> chcolend THEN GOSUB changecolors0
IF xc = 1 THEN LET chcolbegin = chcol
IF th = 1 THEN
PUT (xc + x1(c), middle - t1 - CINT(r * y(c, xc))), thick1, XOR
ELSE
PUT (xc + x1(c), middle - t2 - CINT(r * y(c, xc))), thick2, XOR
END IF
END IF
IF xc = maxx(c) - 2 THEN
LET n = n + 1: chcolend = chcol:
IF nn <> 0 THEN LET nn = nn + 1:
GOSUB changethicknessandr:
END IF
NEXT k
NEXT x
GOTO routineprintandsnd
'--------------------------------------------------------------
test:
LET x2mod = x MOD maxx(2)
IF y(2, x2mod) = 10 AND chcol = 0 AND n > CINT(RND * 2) THEN
LET chcol = 1 - chcol: LET n = 0: GOSUB changecolorsx
END IF
IF y(2, x2mod) = 60 AND chcol = 1 AND n > 12 + CINT(RND * 3) THEN
LET chcol = 1 - chcol: LET n = 0: GOSUB changecolorsx
END IF
k$ = INKEY$
IF k$ = " " THEN LET chcol = 1 - chcol: LET n = 0: GOSUB changecolorsx
IF k$ = "s" THEN
FOR k = 1 TO 3
GOSUB noteoff
NEXT k
END
END IF
RETURN
'part sound
'----------------------------------------------------------------
parameterssound:
DIM note%(3)
' hardware-specific data:
' T1000 e.d. DP=&H378
' AT-GWR DP=&H330 AT-KMC DP=&H338
' Hercules/printer card combinations DP=&H3BC
DP% = &H330: CP% = DP% + 1: SP% = DP% + 2: SH% = INP(SP%):
'T1000-prn adress
' Yamaha FB01 Synthesizer initialisation :
parameter = &H9: 'panning
gegevens = 0
I = 0: GOSUB sysex I = 2: GOSUB sysex
gegevens = 127
I = 1: GOSUB sysex
I = 3: GOSUB sysex
parameter = &HB
gegevens = 127
GOSUB sysex
parameter = &HC
gegevens = 12
GOSUB sysex
RETURN
'---------------------------------------------------------------
'routine for system-exclusives on FB01
sysex:
B = &HF0: GOSUB snd
B = &H43: GOSUB snd
B = 16 + I: GOSUB snd
B = &H15: GOSUB snd
B = parameter: GOSUB snd
B = gegevens: GOSUB snd
RETURN
'---------------------------------------------------------------
snd:
OUT DP%, B: OUT SP%, 0: Z$ = "_": OUT SP%, 1
WHILE INP(CP%) AND 128 = 0: WEND
RETURN
'---------------------------------------------------------------
glissandos:
vn% = note%(k): ' vn% is de vorige gespeelde noot
amplisnd = (1 + r) / 2 ' * (1 - (EXP(x) - EXP(-x)) / (EXP(x) + EXP(-x)))
note%(k) = (64 + 24 * amplisnd * y(k, x MOD maxx(k)) / middle) MOD 128
IF note%(k) <> vn% THEN GOSUB noteon
RETURN
'---------------------------------------------------------------
noteon:
SELECT CASE chcol
CASE 1
vol = 1
CASE 0
vol = 127
END SELECT
B = 143 + k: GOSUB snd
B = note%(k): GOSUB snd
B = vol: GOSUB snd
RETURN
'---------------------------------------------------------------
noteoff:
B = 143 + k: GOSUB snd
B = note%(k): GOSUB snd
B = 0: GOSUB snd
RETURN
'----------------------------------------------------------------
voice:
B = 191 + k
B = CINT(RND * 47) MOD 47
Filedate: 901113 - 1111