Created
October 5, 2010 20:28
-
-
Save jacobjoaquin/612271 to your computer and use it in GitHub Desktop.
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
Pulse Wave and PWM | |
Jacob Joaquin | |
October 5, 2010 | |
jacobjoaquin@gmail.com | |
csoundblog.com | |
<CsoundSynthesizer> | |
<CsInstruments> | |
sr = 44100 | |
kr = 4410 | |
ksmps = 10 | |
nchnls = 1 | |
0dbfs = 1.0 | |
instr 1 | |
iamp = p4 ; Amplitude | |
ipch = cpspch(p5) ; Pitch | |
ipw = p6 ; Pulse width | |
; Pulse wave oscillator | |
a1 vco2 iamp, ipch, 2, ipw | |
out a1 | |
endin | |
instr 2 | |
iamp = p4 ; Amplitude | |
ipch = cpspch(p5) ; Pitch | |
; LFO, for modulating the pulse width of vco2 | |
klfo lfo 0.475, 0.25, 1 | |
klfo = klfo + 0.5 | |
; Pulse wave oscillator | |
a1 vco2 iamp, ipch, 2, klfo | |
out a1 | |
endin | |
</CsInstruments> | |
<CsScore> | |
; Pulse waves of varying widths | |
i 1 0 1 0.5 8.00 0.5 ; Pulse width = 50%, Square wave | |
i 1 1.5 1 0.5 8.00 0.45 ; 45% | |
i 1 3 1 0.5 8.00 0.4 ; 40% | |
i 1 4.5 1 0.5 8.00 0.35 ; etc... | |
i 1 6 1 0.5 8.00 0.3 | |
i 1 7.5 1 0.5 8.00 0.25 | |
i 1 9 1 0.5 8.00 0.2 | |
i 1 10.5 1 0.5 8.00 0.15 | |
i 1 12 1 0.5 8.00 0.1 | |
i 1 13.5 1 0.5 8.00 0.05 | |
; Pulse width modulation | |
i 2 16 8 0.5 8.00 | |
</CsScore> | |
</CsoundSynthesizer> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment