<Cabbage>
form caption("Primitive FM-synth") size(400, 300), guiMode("queue"), pluginId("def1")
keyboard bounds(12, 198, 381, 95)
rslider bounds(28, 16, 80, 80) channel("att") range(0.001, 0.25, 0.1, 1, 0.001) colour(255, 0, 0, 255) text("Attack") textColour(255, 245, 0, 255)
rslider bounds(116, 16, 80, 80) channel("dec") range(0.001, 0.25, 0.1, 1, 0.001) colour(255, 0, 0, 255) text("Decay") textColour(255, 245, 0, 255)
rslider bounds(212, 16, 80, 80) channel("sus") range(0, 1, 0.7, 1, 0.001) colour(255, 0, 0, 255) text("Sustain") textColour(255, 245, 0, 255)
rslider bounds(304, 18, 80, 80) channel("rel") range(0, 1, 0.1, 1, 0.001) colour(255, 0, 0, 255) text("Release") textColour(255, 245, 0, 255)
rslider bounds(28, 102, 80, 80) channel("ampcar") range(0, 1, 0.5, 1, 0.001) colour(255, 0, 0, 255) text("Volume") textColour(255, 255, 0, 255)
rslider bounds(114, 104, 80, 80) channel("ampmod") range(0, 1, 0.5, 1, 0.001) colour(255, 0, 0, 255) text("Amp of mod") textColour(255, 255, 0, 255)
rslider bounds(212, 104, 80, 80) channel("modind") range(0, 1000, 500, 1, 0.001) colour(255, 0, 0, 255) text("Mod index") textColour(255, 255, 0, 255)
rslider bounds(304, 104, 80, 80) channel("freqrat") range(0, 5, 1, 1, 0.001) colour(255, 0, 0, 255) text("Freq ratio") textColour(255, 255, 0, 255)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
iAtt chnget "att"
iDec chnget "dec"
iSus chnget "sus"
iRel chnget "rel"
iAmpc chnget "ampcar"
iAmpm chnget "ampmod"
iModi chnget "modind"
iFrat chnget "freqrat"
kres1 madsr iAtt, iDec, iSus, iRel
aModulator poscil p5, p4*iFrat
kres madsr iAtt, iDec, iSus, iRel
aCarrier poscil p5, kres*(p4 + iModi*(iAmpm*kres1*aModulator))
out kres*iAmpc*aCarrier, kres*iAmpc*aCarrier
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>