'Titel: Omaggio 'Free projections, deel 2 '------------------------ 'Opgedragen aan: B.Valcke (vanuit afgesloten oogpunt) '------------------------ 'Debug: 'SetDlgItemText gh.cockpit, %GMT_msg1, [STR$()] 'warning "[]" '------------------------ 'Opmerkingen: 'de vertraging aan het begin van dit stuk is te wijten aan een fundamenteel vraagstuk: namelijk of het concept van het stuk ' moet worden aangepast aan het fenomeen algoritmische compositie, of anderzijds verschillende vormen van output achteraf ' moeten worden samengevoegd. Geopteerd werd voor het laatste. Daarmee zijn veel onoverkomelijkheden uit de weg gegaan. ' Na een tijdje werd dit concept echter onhoudbaar. Compositorisch gezien werd geopteerd, voor slechts het materiaal ' dat interessant genoeg leek over te houden en alles opnieuw als een puur algoritmisch stuk op te vatten, afgespeeld vanuit GMT. ' De laatste wijziging aan het stuk, was een kleine wijziging en een nieuwe sub, die legato mogelijk maken. 'Dit is het eerste stuk geschreven in B3. Later besliste ik dit als tweede deel van de "Free projections" te gebruiken. '------------------------ DECLARE SUB bv_taak DECLARE SUB a_tussen_b_en_c(a AS BYTE, b AS BYTE, c AS BYTE) DECLARE SUB rnd_a_met_b(a AS BYTE, b AS BYTE) DECLARE SUB verplaatsing_n_van_a_tot_b_tussen_c_en_d(n AS BYTE, a AS INTEGER, b AS INTEGER, c AS BYTE, d AS BYTE) DECLARE SUB welk_instrument_instr_a_noot_b_met_c(a AS BYTE, b AS BYTE, c AS BYTE) DECLARE SUB check_off(a AS BYTE, b AS BYTE) DECLARE SUB playnote(a AS BYTE, b AS BYTE, c AS BYTE) '------------------------ TYPE bv_type note(1 TO 10) AS BYTE vol(1 TO 10) AS BYTE freq AS SINGLE instrum(1 TO 5) AS BYTE schuif AS BYTE mo(1 TO 10) AS SINGLE onthou(1 TO 2) AS BYTE mem_a(1 TO 5) AS BYTE mem_b(1 TO 5) AS BYTE off_tog AS BYTE END TYPE GLOBAL bv AS bv_type GLOBAL result_instr AS DWORD GLOBAL result_noot AS BYTE GLOBAL result_ver AS BYTE GLOBAL result_oct AS BYTE GLOBAL result_rnd AS BYTE GLOBAL result_vel AS BYTE GLOBAL willekeur_tlr AS LONG '------------------------ SUB bv_taak STATIC time AS DWORD STATIC endtime AS DWORD STATIC phi AS DWORD STATIC starttime AS DWORD IF ISFALSE task(%bv).tog THEN mm_harma_off %mm_notes mm_bourdonola_on mm_qt_on controller bourdonola.channel, 1, 30 'winddruk controller qt.channel, 7, 20 'winddruk progchange qt.channel, 122 'vel lookup controller xy.channel, 66, 127 'aan progchange xy.channel, 122 'vel lookup controller tubi.channel, 66, 127 'aan progchange piano.channel, 123 'vel lookup progchange toypi.channel, 122 'vel lookup controller piano.channel, 64, 50 'pedaal starttime = timegettime endtime = 120000 phi = endtime/1.62 bv.onthou(1) = 24 'startnoot 'RH' bv.onthou(2) = 24 'startnoot 'LH' bv.vol(1) = 20 bv.vol(2) = 20 bv.freq = 0.75 bv.mo(1) = 1 'noot aan/uit bv.mo(4) = 1 'gebruikt voor check LH (pas 2 wanneer doorgaan = ok) task(%bv).tog = %true willekeur_tlr = 1 bv.off_tog = 1 END IF time = timegettime - starttime IF time <= phi THEN bv.schuif = (SIN(((time/400)/58.35)-1.6)+1)*50 ELSE bv.schuif = (SIN((((time/400)-70)/36.27)-1.6)+1)*50 bv.schuif = MAX(MIN(bv.schuif, 100), 0) IF bv.mo(1) = 1 THEN bv.note(1) = bv.onthou(1) verplaatsing_n_van_a_tot_b_tussen_c_en_d bv.note(1), -5, 5, MAX(MIN((24+(bv.schuif/(100/48))), 72), 24), MAX(MIN((48+(bv.schuif/(100/48))), 96), 48) bv.note(1) = result_ver bv.onthou(1) = bv.note(1) bv.note(2) = bv.onthou(2) DO verplaatsing_n_van_a_tot_b_tussen_c_en_d bv.note(2), -5, 5, MAX(MIN((24+(bv.schuif/(100/48))), 72), 24), MAX(MIN((48+(bv.schuif/(100/48))), 96), 48) bv.note(3) = result_ver 'bv.note(3) is tijdelijk voor test a_tussen_b_en_c bv.note(3), bv.note(1), bv.note(1)+11 : bv.note(3) = result_oct SELECT CASE bv.note(3) - bv.note(1) 'wanneer welke intervallen toegestaan zijn CASE 1 IF bv.schuif <= 50 THEN bv.mo(4) = 1 ELSE bv.mo(4) = 2 : bv.freq = 1.6 : bv.vol(1) = 19 CASE 2 bv.mo(4) = 2 : bv.freq = 1.3 : bv.vol(1) = 23 CASE 3 bv.mo(4) = 2 : bv.freq = 1.15 : bv.vol(1) = 24 CASE 4 bv.mo(4) = 2 : bv.freq = 1 : bv.vol(1) = 25 CASE 5 IF bv.schuif <= 25 THEN bv.mo(4) = 1 ELSE bv.mo(4) = 2 : bv.freq = 1.7 : bv.vol(1) = 18 CASE 6 bv.mo(4) = 1 CASE 7 IF bv.schuif <= 25 THEN bv.mo(4) = 1 ELSE bv.mo(4) = 2 : bv.freq = 1.7 : bv.vol(1) = 18 CASE 8 bv.mo(4) = 2 : bv.freq = 1.45 : bv.vol(1) = 22 CASE 9 bv.mo(4) = 2 : bv.freq = 1.6 : bv.vol(1) = 21 CASE 10 bv.mo(4) = 2 : bv.freq = 1.75 : bv.vol(1) = 20 CASE 11 IF bv.schuif <= 50 THEN bv.mo(4) = 1 ELSE bv.mo(4) = 2 : bv.freq = 1.7 : bv.vol(1) = 18 CASE ELSE bv.mo(4) = 1 'herberekenen END SELECT LOOP UNTIL bv.mo(4) = 2 bv.note(2) = result_ver bv.onthou(2) = bv.note(2) bv.freq = bv.freq + (bv.schuif/16) bv.vol(1) = bv.vol(1) + (bv.schuif/3) bv.note(5) = (MAX(MIN((bv.schuif/10), 7), 1)) 'samenstellende intervallen vergroten van kleine secunde tot kwint (exclusief tritonus) IF bv.note(5) = 6 THEN INCR bv.note(5) bv.note(5) = bv.note(1) + bv.note(5) bv.note(6) = (MAX(MIN((bv.schuif/10), 7), 1)) IF bv.note(6) = 6 THEN INCR bv.note(6) bv.note(6) = bv.note(2) + bv.note(6) rnd_a_met_b 6, bv.schuif : welk_instrument_instr_a_noot_b_met_c result_rnd, bv.note(1), bv.vol(1) : bv.instrum(1) = result_instr : bv.note(1) = result_noot playnote bv.instrum(1), bv.note(1), result_vel rnd_a_met_b 6, bv.schuif : welk_instrument_instr_a_noot_b_met_c result_rnd, bv.note(5), bv.vol(1) : bv.instrum(2) = result_instr : bv.note(5) = result_noot playnote bv.instrum(2), bv.note(5), result_vel rnd_a_met_b 6, bv.schuif : welk_instrument_instr_a_noot_b_met_c result_rnd, bv.note(2), bv.vol(1) : bv.instrum(3) = result_instr : bv.note(2) = result_noot playnote bv.instrum(3), bv.note(2), result_vel rnd_a_met_b 6, bv.schuif : welk_instrument_instr_a_noot_b_met_c result_rnd, bv.note(6), bv.vol(1) : bv.instrum(4) = result_instr : bv.note(6) = result_noot playnote bv.instrum(4), bv.note(6), result_vel bv.mo(5) = RND(1, ((bv.schuif)/20)+1) 'toypi's noot selecteren IF bv.mo(5) <> 1 THEN bv.mo(5) = RND(1, 4) SELECT CASE bv.mo(5) CASE 1 bv.note(7) = bv.note(1) CASE 2 bv.note(7) = bv.note(2) CASE 3 bv.note(7) = bv.note(5) CASE 4 bv.note(7) = bv.note(6) END SELECT a_tussen_b_en_c bv.note(7), 72, 107 result_vel = bv.vol(1) * 1.2 '### optionele bewerking invoegen voor vel scaling playnote 7, result_oct, result_vel ELSE bv.note(7) = 0 END IF task(%bv).freq = bv.freq ELSE mm_bourdonola_off %mm_notes mm_qt_off %mm_notes mm_piano_off %mm_notes IF bv.off_tog <> 1 THEN check_off bv.mem_a(1), bv.mem_b(1) 'alle noten terug uit mits legato (overlap 1 noot) check_off bv.mem_a(2), bv.mem_b(2) check_off bv.mem_a(3), bv.mem_b(3) check_off bv.mem_a(4), bv.mem_b(4) END IF bv.instrum(1)= bv.mem_a(1) : bv.note(1) = bv.mem_b(1) bv.instrum(2)= bv.mem_a(2) : bv.note(2) = bv.mem_b(2) bv.instrum(3)= bv.mem_a(3) : bv.note(5) = bv.mem_b(3) bv.instrum(4)= bv.mem_a(4) : bv.note(6) = bv.mem_b(4) task(%bv).freq = 40 bv.off_tog = 2 IF time => endtime THEN controller piano.channel, 64, 0 controller bourdonola.channel, 66, 0 controller qt.channel, 66, 0 stoptask %bv END IF END IF INCR bv.mo(1) IF bv.mo(1) => 3 THEN bv.mo(1) = 1 bv.mo(2) = 1 END SUB SUB check_off(a AS BYTE, b AS BYTE) EXPORT 'deze functie kijke welk instrument een noot heeft gespeeld (één noot terug, voor overlapping) 'indien het instrument in dit geval qt, bourdonola of de player piano was, wordt de noot uitgeschakeld a = MAX(MIN(a, 3), 1) b = MAX(MIN(b, 127), 0) IF a = 1 THEN noteoff bourdonola.channel, b IF a = 2 THEN noteoff qt.channel, b IF a = 3 THEN noteoff piano.channel, b END SUB SUB playnote(a AS BYTE, b AS BYTE, c AS BYTE) EXPORT 'deze functie speelt de gegeven noot met het juiste instrument a = MAX(MIN(a, 7), 1) b = MAX(MIN(b, 127), 0) c = MAX(MIN(c, 127), 0) IF a = 1 THEN play bourdonola.channel, b, c IF a = 2 THEN play qt.channel, b, c IF a = 3 THEN play piano.channel, b, MIN((c*1.3),120) IF a = 4 THEN play vibi.channel, b, c IF a = 5 THEN play tubi.channel, b, c IF a = 6 THEN play xy.channel, b, c IF a = 7 THEN play toypi.channel, b, c END SUB SUB a_tussen_b_en_c(a AS BYTE, b AS BYTE, c AS BYTE) EXPORT 'deze functie transponeert a in stappen van octaven tot a tussen b en c komt te liggen (b en c inclusief) 'wanneer a onmogelijk tussen b en c kan liggen, wordt het resultaat 0 STATIC temp_b AS BYTE STATIC temp_c AS BYTE STATIC times AS BYTE IF b = c THEN a = b IF b > c THEN temp_b = b : temp_c = c : b = temp_c : c = temp_b IF a < b THEN IF c < b+11 THEN c = c+12 times = 0 DO IF times => 11 THEN a = 0 EXIT LOOP END IF a = a+12 INCR times LOOP UNTIL a => b END IF IF a > c THEN times = 0 DO IF times => 11 THEN a = 0 EXIT LOOP END IF a = a-12 INCR times LOOP UNTIL a <= c END IF a = MAX(MIN(a, 127), 0) result_oct = a END SUB SUB rnd_a_met_b(a AS BYTE, b AS BYTE) EXPORT 'deze functie genereerd een willekeurige waarde (tussen 0 en a, 0 exclusief) wanneer a gelijk is aan 1, is het resultaat 1 'de waarschijnlijkheid is uitgedrukt in % (b = 1 tot 100) wanneer b = 0, wordt b 'afgerond' naar 1 'waarbij 0 staat voor bijna alleen de kleinste waarde (dus 1) en 100 staat voor bijna alleen de grootste waarde (dus a) STATIC c AS BYTE b = MAX(MIN(b, 100), 1) c = RND(1, a) c = MAX(MIN(c, a), 1) result_rnd = c END SUB SUB verplaatsing_n_van_a_tot_b_tussen_c_en_d(n AS BYTE, a AS INTEGER, b AS INTEGER, c AS BYTE, d AS BYTE) EXPORT 'deze functie doet ongeveer hetzelfde als rnd_a_met_b maar is "gespecialiseerd" in het genereren van een verplaasting, naar boven of onder 'tussen het midi_bereik; met op te geven bereik en grootst mogelijke stap (naar boven of onder) STATIC temp AS INTEGER STATIC result_cat AS BYTE STATIC temp_a AS INTEGER STATIC temp_b AS INTEGER STATIC temp_c AS BYTE STATIC temp_d AS BYTE result_cat = 0 IF a = b THEN result_cat = 1 IF a > b THEN temp_a = a : temp_b = b : a = temp_b : b = temp_a IF c = d THEN result_cat = 2 IF c > d THEN temp_c = c : temp_d = d : c = temp_d : d = temp_c c = MAX(MIN(c, 127), 0) d = MAX(MIN(d, 127), 0) IF result_cat = 0 THEN DO DO temp = RND(a, b) LOOP UNTIL temp <> 0 LOOP UNTIL n + temp <= d AND n + temp => c result_ver = n + temp END IF IF result_cat = 1 THEN result_ver = n + a IF result_cat = 2 THEN result_ver = c result_ver = MAX(MIN(result_ver, 127), 0) END SUB SUB welk_instrument_instr_a_noot_b_met_c(a AS BYTE, b AS BYTE, c AS BYTE) EXPORT 'deze functie stelt in welk instrument welke toon speelt. 'De octaafligging wordt aan het instrument aangepast 'C is de velocity, deze kan hier worden aangepast indien nodig. STATIC noot AS BYTE a = MAX(MIN(a, 6), 1) b = MAX(MIN(b, 127), 0) c = MAX(MIN(c, 127), 0) noot = b IF bv.schuif < 38 THEN IF a => 5 THEN a = a-2 END IF IF bv.schuif > 62 THEN IF a < 2 THEN a = 3 END IF SELECT CASE a CASE 1'bourdonola result_instr = 1 a_tussen_b_en_c noot,36,62 result_noot = result_oct result_vel = 30 'bourdonola gebruikt geen vel voor kleppen controller bourdonola.channel, 1, c*1.1 '### optionele bewerking invoegen voor vel scaling CASE 2'qt result_instr = 2 a_tussen_b_en_c noot,36,108 result_noot = result_oct result_vel = 30 'kleppen controller qt.channel, 7, c*1.1 '### optionele bewerking invoegen voor vel scaling CASE 3'piano result_instr = 3 a_tussen_b_en_c noot,21,108 result_noot = result_oct result_vel = c '### optionele bewerking invoegen voor vel scaling result_vel = MAX(MIN(result_vel, 127), 30) CASE 4'vibi result_instr = 4 a_tussen_b_en_c noot,60,96 result_noot = result_oct result_vel = c *0.7 '### optionele bewerking invoegen voor vel scaling result_vel = MAX(MIN(result_vel, 127), 10) CASE 5'tubi result_instr = 5 a_tussen_b_en_c noot,72,108 result_noot = result_oct result_vel = c * 0.5 '### optionele bewerking invoegen voor vel scaling result_vel = MAX(MIN(result_vel, 127), 10) CASE 6'xy result_instr = 6 a_tussen_b_en_c noot,56,108 result_noot = result_oct result_vel = c '### optionele bewerking invoegen voor vel scaling result_vel = MAX(MIN(result_vel, 127), 10) CASE ELSE'+piano result_instr = 3 a_tussen_b_en_c noot,21,108 result_noot = result_oct result_vel = c '### optionele bewerking invoegen voor vel scaling END SELECT result_vel = MAX(MIN(result_vel, 127), 0) END SUB