| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-odac ;;;realtime audio |
| 5 |
;-iadc ;;;uncomment -iadc if realtime audio input is needed too |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o polynomial.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
sr = 44100 |
| 12 |
ksmps = 32 |
| 13 |
nchnls = 2 |
| 14 |
0dbfs = 1 |
| 15 |
|
| 16 |
; The polynomial y=x^n where n is odd always produces a curve |
| 17 |
; that traverses the range [-1, 1] when the input is within |
| 18 |
; the same range. Therefore, we can use one of these curves |
| 19 |
; to make a nonlinear phasor that repeatedly reads a table |
| 20 |
; from beginning to end like a linear phasor (maintaining |
| 21 |
; continuity) but that distorts the waveform in the table. |
| 22 |
|
| 23 |
instr 4 ; This instrument demonstrates phase distortion with x^3 |
| 24 |
|
| 25 |
idur = p3 |
| 26 |
iamp = p4 |
| 27 |
ifreq = p5 |
| 28 |
itable = p6 |
| 29 |
|
| 30 |
aenv linseg 0, .001, 1.0, idur - .051, 1.0, .05, 0 ; declicking envelope |
| 31 |
aosc phasor ifreq ; create a linear phasor |
| 32 |
apd polynomial aosc, 0, 0, 0, 1 ; distort the phasor with x^3 |
| 33 |
aout tablei apd, itable, 1 ; read a sine table with the nonlinear phasor |
| 34 |
outs aenv*aout*iamp, aenv*aout*iamp |
| 35 |
|
| 36 |
endin |
| 37 |
|
| 38 |
instr 5 ; This instrument demonstrates phase distortion with x^11 |
| 39 |
|
| 40 |
idur = p3 |
| 41 |
iamp = p4 |
| 42 |
ifreq = p5 |
| 43 |
itable = p6 |
| 44 |
|
| 45 |
aenv linseg 0, .001, 1.0, idur - .051, 1.0, .05, 0 ; declicking envelope |
| 46 |
aosc phasor ifreq ; create a linear phasor |
| 47 |
apd polynomial aosc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ; distort the phasor with x^11 |
| 48 |
aout tablei apd, itable, 1 ; read a sine table with the nonlinear phasor |
| 49 |
outs aenv*aout*iamp, aenv*aout*iamp |
| 50 |
|
| 51 |
endin |
| 52 |
|
| 53 |
instr 6 ; This instrument crossfades between a pure sine and one distorted with x^11 |
| 54 |
|
| 55 |
idur = p3 |
| 56 |
iamp = p4 |
| 57 |
ifreq = p5 |
| 58 |
itable = p6 |
| 59 |
|
| 60 |
aenv linseg 0, .001, 1.0, idur - .051, 1.0, .05, 0 ; declicking envelope |
| 61 |
aosc phasor ifreq ; create a linear phasor |
| 62 |
aout3 tablei aosc, itable, 1 ; read a sine table without the linear phasor |
| 63 |
apd11 polynomial aosc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ; distort the phasor with x^11 |
| 64 |
aout11 tablei apd11, itable, 1 ; read a sine table with the nonlinear phasor |
| 65 |
kamount linseg 1.0, 0.05, 0.9, 1.0, 0.0 ; crossfade between two outputs |
| 66 |
aout = aout3*kamount + aout11*(1.0 - kamount) |
| 67 |
outs aenv*aout*iamp, aenv*aout*iamp |
| 68 |
|
| 69 |
endin |
| 70 |
</CsInstruments> |
| 71 |
<CsScore> |
| 72 |
f1 0 16385 10 1 ; sine wave |
| 73 |
|
| 74 |
; descending "just blues" scale |
| 75 |
|
| 76 |
t 0 100 |
| 77 |
i4 0 .333 .7 512 1 |
| 78 |
i. + . . 448 |
| 79 |
i. + . . 384 |
| 80 |
i. + . . 360 |
| 81 |
i. + . . 341.33 |
| 82 |
i. + . . 298.67 |
| 83 |
i. + 2 . 256 |
| 84 |
s |
| 85 |
|
| 86 |
t 0 100 |
| 87 |
i5 0 .333 .7 512 1 |
| 88 |
i. + . . 448 |
| 89 |
i. + . . 384 |
| 90 |
i. + . . 360 |
| 91 |
i. + . . 341.33 |
| 92 |
i. + . . 298.67 |
| 93 |
i. + 2 . 256 |
| 94 |
s |
| 95 |
|
| 96 |
t 0 100 |
| 97 |
i6 0 .333 .7 512 1 |
| 98 |
i. + . . 448 |
| 99 |
i. + . . 384 |
| 100 |
i. + . . 360 |
| 101 |
i. + . . 341.33 |
| 102 |
i. + . . 298.67 |
| 103 |
i. + 2 . 256 |
| 104 |
|
| 105 |
e |
| 106 |
|
| 107 |
</CsScore> |
| 108 |
</CsoundSynthesizer> |