| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-odac ;;;realtime audio out |
| 5 |
;-iadc ;;;uncomment -iadc if realtime audio input is needed too |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o hilbert.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 |
instr 1 |
| 17 |
idur = p3 |
| 18 |
; Initial amount of frequency shift. |
| 19 |
; It can be positive or negative. |
| 20 |
ibegshift = p4 |
| 21 |
; Final amount of frequency shift. |
| 22 |
; It can be positive or negative. |
| 23 |
iendshift = p5 |
| 24 |
|
| 25 |
; A simple envelope for determining the |
| 26 |
; amount of frequency shift. |
| 27 |
kfreq linseg ibegshift, idur, iendshift |
| 28 |
|
| 29 |
; Use the sound of your choice. |
| 30 |
ain diskin2 "drumsMlp.wav", 1, 0, 1 |
| 31 |
|
| 32 |
; Phase quadrature output derived from input signal. |
| 33 |
areal, aimag hilbert ain |
| 34 |
|
| 35 |
; Quadrature oscillator. |
| 36 |
asin oscili 1, kfreq, 1 |
| 37 |
acos oscili 1, kfreq, 1, .25 |
| 38 |
|
| 39 |
; Use a trigonometric identity. |
| 40 |
; See the references for further details. |
| 41 |
amod1 = areal * acos |
| 42 |
amod2 = aimag * asin |
| 43 |
|
| 44 |
; Both sum and difference frequencies can be |
| 45 |
; output at once. |
| 46 |
; aupshift corresponds to the sum frequencies. |
| 47 |
aupshift = (amod1 - amod2) * 0.7 |
| 48 |
; adownshift corresponds to the difference frequencies. |
| 49 |
adownshift = (amod1 + amod2) * 0.7 |
| 50 |
|
| 51 |
; Notice that the adding of the two together is |
| 52 |
; identical to the output of ring modulation. |
| 53 |
|
| 54 |
outs aupshift, aupshift |
| 55 |
endin |
| 56 |
|
| 57 |
|
| 58 |
</CsInstruments> |
| 59 |
<CsScore> |
| 60 |
|
| 61 |
; Sine table for quadrature oscillator. |
| 62 |
f 1 0 16384 10 1 |
| 63 |
|
| 64 |
; Starting with no shift, ending with all |
| 65 |
; frequencies shifted up by 2000 Hz. |
| 66 |
i 1 0 6 0 2000 |
| 67 |
|
| 68 |
; Starting with no shift, ending with all |
| 69 |
; frequencies shifted down by 250 Hz. |
| 70 |
i 1 7 6 0 -250 |
| 71 |
e |
| 72 |
|
| 73 |
|
| 74 |
</CsScore> |
| 75 |
</CsoundSynthesizer> |