; More demonstrations of the phase distortion opcode ; pdclip ; new in Csound 5.08 ; by Anthony Kozar ; http://www.anthonykozar.net/ sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 giDblPhaseTbl ftgen 0, 0, 16385, 7, 0.0, 8193, 1.0, 0, 0.0, 8192, 1.0 giSqrOffsetTbl ftgen 0, 0, 16385, -7, 0.0, 8193, 0.0, 0, 0.5, 8192, 0.5 ; Shows how to obtain the "square" waveform ; of the Casio CZ-series synthesizers by doubling ; the frequency of the phasor, passing it through ; pdclip to shape it and then adding an offset to ; the second half before reading the cosine table. ; There is a glitch half-way through the phase ; output due to rounding errors (?). instr 4 idur = p3 iamp = p4 ifreq = p5 itable = p6 aenv linseg 0, .001, 1.0, idur - .051, 1.0, .05, 0 aosc phasor ifreq kamount linseg 1.0, 0.1, 0.9, 1.0, 0.0 adbl tablei aosc, giDblPhaseTbl, 1 ; double phasor apd pdclip adbl, kamount, -kamount, 0, 1.0 ; shape each half aoff tablei aosc, giSqrOffsetTbl, 1 ; get offset aphase = (0.5 * apd) + aoff ; calculate final phase aout tablei aphase, itable, 1 out aenv*aout*iamp endin f1 0 16385 10 1 f3 0 16385 9 1 1 270 ; inverted cosine ; descending "just blues" scale ; the CZ-series "square" waveform t 0 100 i4 0 .333 10000 512 3 i. + . . 448 i. + . . 384 i. + . . 360 i. + . . 341.33 i. + . . 298.67 i. + 2 . 256 e