; Powershape.csd
; Iain McCurdy 2012
;
; Encapsulation of the powershape opcode used for wave distortion
;
; CONTROLS
; --------
; Test Tone -- a glissandoing test tone
; Amount -- amount of distortion
; Level -- output level
form caption("Powershape") size(300,260), pluginid("pshp") style("legacy")
image bounds(0, 0,300,160), colour("Brown"), shape("rounded"), outlinecolour("white"), outlinethickness(4)
checkbox bounds(10, 8,130, 12), channel("TestTone"), FontColour("white"), value(0), text("Sine Tone"), colour(yellow)
hslider bounds( 5, 18,290, 40), colour("white"), trackercolour("white"), channel("amount"), range(0.1, 1000, 1, 0.25,0.001)
label bounds(129, 50, 40, 11), text("Amount"), fontcolour("white")
nslider bounds(100, 65,100, 40), text("Amount [type]"), channel("amount"), range(0.1, 1000, 1,1,0.001), textcolour(white)
hslider bounds( 5,108,290, 40), colour("white"), trackercolour("white"), channel("level"), range(0, 50, 0.5, 0.25,0.000001)
label bounds(135,140, 27, 11), text("Level"), fontcolour("white")
}
keyboard bounds(8, 160, 381, 95)
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
;sr is set by the host
ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
0dbfs = 1
gisine ftgen 0,0,4096,10,1 ;,0,1/2,0,1/4,0,1/8,0,1/16,0,1/32,0,1/64
instr 1
kporttime linseg 0,0.001,0.05 ; portamento time ramps up from zero
gkshape chnget "amount" ; READ WIDGETS...
gkshape portk gkshape,kporttime
gklevel chnget "level" ;
gklevel portk gklevel,kporttime
gklevel portk gklevel,kporttime
gkTestTone chnget "TestTone"
kEnv madsr .1, .2, .6, .9
asigL vco2 p5*kEnv, p4 ; otherwise...
asigR = asigL
ifullscale = 0dbfs ;DEFINE FULLSCALE AMPLITUDE VALUE
aL powershape asigL, gkshape, ifullscale ;CREATE POWERSHAPED SIGNAL
aR powershape asigR, gkshape, ifullscale ;CREATE POWERSHAPED SIGNAL
alevel interp gklevel
outs aL * alevel, aR * alevel ;WAVESET OUTPUT ARE SENT TO THE SPEAKERS
endin
f0 z