Using the event_i opcode to generate notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
event_i | |
Jacob Joaquin | |
November 15, 2010 | |
jacobjoaquin@gmail.com | |
csoundblog.com | |
<CsoundSynthesizer> | |
<CsInstruments> | |
sr = 44100 | |
kr = 4410 | |
ksmps = 10 | |
nchnls = 1 | |
0dbfs = 1.0 | |
instr 1 | |
idur = p3 ; Duration of each generated event | |
iamp = p4 ; Base amplitude | |
ipch = cpspch(p5) ; Pitch | |
idelay = p6 ; Delay time between notes, in seconds | |
; Generate 5 events for instrument 2 | |
event_i "i", 2, idelay * 0, idur, iamp, ipch | |
event_i "i", 2, idelay * 1, idur, iamp / 2, ipch * 2 ^ (3 / 12) | |
event_i "i", 2, idelay * 2, idur, iamp / 3, ipch * 2 ^ (7 / 12) | |
event_i "i", 2, idelay * 3, idur, iamp / 4, ipch * 2 ^ (5 / 12) | |
event_i "i", 2, idelay * 4, idur, iamp / 5, ipch * 2 ^ (10 / 12) | |
endin | |
instr 2 | |
idur = p3 ; Duration | |
iamp = p4 ; Amplitude | |
ifreq = p5 ; Frequency | |
aenv linseg 0, 0.01, 1, idur - 0.01, 0 ; Envelope | |
a1 vco2 iamp, ifreq, 12 ; Oscillator | |
out aenv * a1 ; Output | |
endin | |
</CsInstruments> | |
<CsScore> | |
i 1 0 1 0.5 8.00 0.5 | |
i 1 4 1 0.5 8.00 0.5 | |
i 1 8 1 0.5 8.07 0.5 | |
i 1 10 1 0.5 7.03 0.25 | |
i 1 12 1 0.25 9.07 0.333 | |
i 1 13 1 0.4 9.05 0.25 | |
i 1 13 1 0.4 8.07 0.5 | |
</CsScore> | |
</CsoundSynthesizer> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment