| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
; Audio out Audio in No messages |
| 5 |
-odac -iadc -d ;;;RT audio I/O |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o syncphasor-CZresonance.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
; by Anthony Kozar. February 2008 |
| 11 |
; http://www.anthonykozar.net/ |
| 12 |
|
| 13 |
; Imitation of the Casio CZ-series synthesizer's "Resonance" waveforms |
| 14 |
; using a synced phasor to read a sinusoid table. The jumps at the sync |
| 15 |
; points are smoothed by multiplying with a windowing function controlled |
| 16 |
; by the master phasor. |
| 17 |
|
| 18 |
; Based on information from the Wikipedia article on phase distortion: |
| 19 |
; http://en.wikipedia.org/wiki/Phase_distortion_synthesis |
| 20 |
|
| 21 |
; Sawtooth Resonance waveform. Smoothing function is just the inverted |
| 22 |
; master phasor. |
| 23 |
|
| 24 |
; The Wikipedia article shows an inverted cosine as the stored waveform, |
| 25 |
; which implies that it must be unipolar for the smoothing to work. |
| 26 |
; I have substituted a sine wave in the first phrase to keep the output |
| 27 |
; bipolar. The second phrase demonstrates the much "rezzier" sound of the |
| 28 |
; bipolar cosine due to discontinuities. |
| 29 |
|
| 30 |
instr 1 |
| 31 |
ifreq = cpspch(p4) |
| 32 |
initReson = p5 |
| 33 |
itable = p6 |
| 34 |
imaxamp = 10000 |
| 35 |
anosync init 0.0 |
| 36 |
|
| 37 |
kslavecps line ifreq * initReson, p3, ifreq |
| 38 |
amaster, async syncphasor ifreq, anosync ; pair of phasors |
| 39 |
aslave, async2 syncphasor kslavecps, async ; slave synced to master |
| 40 |
aosc tablei aslave, itable, 1 ; use slave phasor to read a (co)sine table |
| 41 |
aout = aosc * (1.0 - amaster) ; inverted master smoothes jumps |
| 42 |
adeclick linseg 0.0, 0.05, 1.0, p3 - 0.1, 1.0, 0.05, 0.0 |
| 43 |
|
| 44 |
out aout * adeclick * imaxamp |
| 45 |
endin |
| 46 |
|
| 47 |
; Triangle or Trapezoidal Resonance waveform. Uses a second table to change |
| 48 |
; the shape of the smoothing function. (This is my best guess so far as to |
| 49 |
; how these worked). The cosine table works fine with the triangular smoothing |
| 50 |
; but we once again need to use a sine table with the trapezoidal smoothing. |
| 51 |
|
| 52 |
; (It might be interesting to be able to vary the "width" of the trapezoid. |
| 53 |
; This could be done with the pdhalf opcode). |
| 54 |
|
| 55 |
instr 2 |
| 56 |
ifreq = cpspch(p4) |
| 57 |
initReson = p5 |
| 58 |
itable = p6 |
| 59 |
ismoothtbl = p7 |
| 60 |
imaxamp = 10000 |
| 61 |
anosync init 0.0 |
| 62 |
|
| 63 |
kslavecps line ifreq * initReson, p3, ifreq |
| 64 |
amaster, async syncphasor ifreq, anosync ; pair of phasors |
| 65 |
aslave, async2 syncphasor kslavecps, async ; slave synced to master |
| 66 |
aosc tablei aslave, itable, 1 ; use slave phasor to read a (co)sine table |
| 67 |
asmooth tablei amaster, ismoothtbl, 1 ; use master phasor to read smoothing table |
| 68 |
aout = aosc * asmooth |
| 69 |
adeclick linseg 0.0, 0.05, 1.0, p3 - 0.1, 1.0, 0.05, 0.0 |
| 70 |
|
| 71 |
out aout * adeclick * imaxamp |
| 72 |
endin |
| 73 |
|
| 74 |
</CsInstruments> |
| 75 |
<CsScore> |
| 76 |
f1 0 16385 10 1 |
| 77 |
f3 0 16385 9 1 1 270 ; inverted cosine |
| 78 |
f5 0 4097 7 0.0 2048 1.0 2049 0.0 ; unipolar triangle |
| 79 |
f6 0 4097 7 1.0 2048 1.0 2049 0.0 ; "trapezoid" |
| 80 |
|
| 81 |
; Sawtooth resonance with a sine table |
| 82 |
i1 0 1 7.00 5.0 1 |
| 83 |
i. + 0.5 7.02 4.0 |
| 84 |
i. + . 7.05 3.0 |
| 85 |
i. + . 7.07 2.0 |
| 86 |
i. + . 7.09 1.0 |
| 87 |
i. + 2 7.06 12.0 |
| 88 |
f0 6 |
| 89 |
s |
| 90 |
|
| 91 |
; Sawtooth resonance with a cosine table |
| 92 |
i1 0 1 7.00 5.0 3 |
| 93 |
i. + 0.5 7.02 4.0 |
| 94 |
i. + . 7.05 3.0 |
| 95 |
i. + . 7.07 2.0 |
| 96 |
i. + . 7.09 1.0 |
| 97 |
i. + 2 7.06 12.0 |
| 98 |
f0 6 |
| 99 |
s |
| 100 |
|
| 101 |
; Triangle resonance with a cosine table |
| 102 |
i2 0 1 7.00 5.0 3 5 |
| 103 |
i. + 0.5 7.02 4.0 |
| 104 |
i. + . 7.05 3.0 |
| 105 |
i. + . 7.07 2.0 |
| 106 |
i. + . 7.09 1.0 |
| 107 |
i. + 2 7.06 12.0 |
| 108 |
f0 6 |
| 109 |
s |
| 110 |
|
| 111 |
; Trapezoidal resonance with a sine table |
| 112 |
i2 0 1 7.00 5.0 1 6 |
| 113 |
i. + 0.5 7.02 4.0 |
| 114 |
i. + . 7.05 3.0 |
| 115 |
i. + . 7.07 2.0 |
| 116 |
i. + . 7.09 1.0 |
| 117 |
i. + 2 7.06 12.0 |
| 118 |
|
| 119 |
e |
| 120 |
|
| 121 |
</CsScore> |
| 122 |
</CsoundSynthesizer> |