diff options
Diffstat (limited to 'examples/1-chord_sequence.csd')
-rw-r--r-- | examples/1-chord_sequence.csd | 73 |
1 files changed, 59 insertions, 14 deletions
diff --git a/examples/1-chord_sequence.csd b/examples/1-chord_sequence.csd index 38e0ed6..b45ee0f 100644 --- a/examples/1-chord_sequence.csd +++ b/examples/1-chord_sequence.csd @@ -3,6 +3,12 @@ -odac </CsOptions> <CsInstruments> +/* + csound-opl example 1 + Multiple channel chord sequence + + Richard Knight 2021 : examples are licensed as public domain equivalent : http://unlicense.org/ +*/ sr = 44100 kr = 4410 @@ -11,19 +17,17 @@ nchnls = 2 giopl init 0 -instr main - giopl, aL, aR opl - outs aL, aR - - oplpatchchange giopl, 0, 89 - oplpatchchange giopl, 1, 12 - oplpatchchange giopl, 2, 72 - oplpatchchange giopl, 3, 96 - - event_i "i", "sequencer", 0, p3 -endin +/* + Play notes with certain parameters: + kinstr : the instrument number to play + kduration : play duration + kbase : base MIDI note number + kintervals : intervals to form a chord with from kbase + ktimeinc : how much time to step with each interval + kreadmode : read intervals 0=forward, 1=reverse +*/ opcode playchord, 0, kkkk[]kk kinstr, kduration, kbase, kintervals[], ktimeinc, kreadmode xin ktime = 0 @@ -45,15 +49,40 @@ opcode playchord, 0, kkkk[]kk endif endop + +; audio output, voice setting and sequencer invocation +instr main + ; the synthesiser + giopl, aL, aR opl + outs aL, aR + + ; set the voices for four channels + oplpatchchange giopl, 0, 89 + oplpatchchange giopl, 1, 12 + oplpatchchange giopl, 2, 72 + oplpatchchange giopl, 3, 96 + oplpatchchange giopl, 4, 39 + + ; start the sequencer + event_i "i", "sequencer", 0, p3 +endin + + +; basic chord triggering pseudo-sequencer instr sequencer itempo = 120 ibeatduration = 60/itempo - kintervals[] fillarray 0, 4, 5, 9 - knotes[] fillarray 50, 54, 56, 48 + + ; intervals for chords, and notes for progression + kintervalsall[][] init 4, 4 + kintervalsall fillarray 0, 4, 5, 9, 4, 5, 7, 9, 0, 5, 7, 14, 0, 5, 7, 8 + knotes[] fillarray 50, 54, 56, 54 + knotedx init 0 kbeat metro itempo/60 kbar0 init 0 if (kbeat == 1) then + kintervals[] getrow kintervalsall, knotedx if (kbar0 == 0) then playchord 3, ibeatduration*4, knotes[knotedx], kintervals, 0, 0 elseif (kbar0 == 1) then @@ -64,6 +93,11 @@ instr sequencer playchord 4, ibeatduration, knotes[knotedx]+12, kintervals, ibeatduration/4, 1 endif + kbassnote = knotes[knotedx] + event "i", 5, 0, ibeatduration*0.2, kbassnote-24 + event "i", 5, ibeatduration*0.5, ibeatduration*0.16, kbassnote-12 + + if (kbar0 < 3) then kbar0 += 1 else @@ -78,24 +112,35 @@ instr sequencer endin +; play note on channel 0 instr 1 oplnote giopl, 0, p4, 120 endin + +; play note on channel 1 instr 2 oplnote giopl, 1, p4, 100 endin + +; play note on channel 2 instr 3 oplnote giopl, 2, p4, 100 endin + +; play note on channel 3 instr 4 oplnote giopl, 3, p4, 100 endin +; play note on channel 4 +instr 5 + oplnote giopl, 4, p4, 80 +endin + </CsInstruments> -; ============================================== <CsScore> i"main" 0 3600 |