| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
; Audio out Audio in |
| 5 |
;-odac -iadc ;;;RT audio I/O |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
-o vosim.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
sr = 44100 |
| 11 |
ksmps = 100 |
| 12 |
nchnls = 1 |
| 13 |
|
| 14 |
;################################################# |
| 15 |
; By Rasmus Ekman 2008 |
| 16 |
|
| 17 |
; Square each point in table #p4. This should only be run once in the performance. |
| 18 |
instr 10 |
| 19 |
|
| 20 |
index tableng p4 |
| 21 |
index = index - 1 ; start from last point |
| 22 |
loop: |
| 23 |
ival table index, p4 |
| 24 |
ival = ival * ival |
| 25 |
tableiw ival, index, p4 |
| 26 |
index = index - 1 |
| 27 |
if index < 0 igoto endloop |
| 28 |
igoto loop |
| 29 |
endloop: |
| 30 |
endin |
| 31 |
|
| 32 |
;################################################# |
| 33 |
|
| 34 |
; vosim instrument. Sweeps kfund and kform between start-end values. |
| 35 |
; Attempts to smooth spectral transitions as pulse count changes |
| 36 |
; p4: amp |
| 37 |
; p5, p6: fund beg-end |
| 38 |
; p7, p8: form beg-end |
| 39 |
; p9: amp decay (ignored) |
| 40 |
; p10: pulse count (ignored - calc internally) |
| 41 |
; p11: pulse length mod |
| 42 |
; p12: skip (for tied events) |
| 43 |
; p13: don't fade out (if followed by tied note) |
| 44 |
instr 1 |
| 45 |
kamp init p4 |
| 46 |
; freq start, end |
| 47 |
kfund line p5, p3, p6 |
| 48 |
; formant start, end |
| 49 |
kform line p7, p3, p8 |
| 50 |
|
| 51 |
; Get many pulses as we can fit |
| 52 |
kPulseCount = (kform / kfund) ;init p10 |
| 53 |
|
| 54 |
; Attempt to smooth steps between formant bandwidth, |
| 55 |
; matching decay to the current pulse count and remaining silent part |
| 56 |
kPulseREM = kPulseCount - int(kPulseCount) ; Pulse remainder (empty samples after last pulse) |
| 57 |
kDroprate = kPulseREM / (kPulseCount-1) ; Decay per pulse (after the 1st) |
| 58 |
kDecay = kamp - kDroprate |
| 59 |
; Guard against kamp going negative (since kDecay is subtracted from each pulse) |
| 60 |
if (kDecay * (kPulseCount-1)) > kamp then |
| 61 |
kDecay = kamp / kPulseCount |
| 62 |
endif |
| 63 |
|
| 64 |
; Try this to get more bumpy spectral changes when pulse count changes |
| 65 |
;kDecay = p9 |
| 66 |
|
| 67 |
kPulseFactor init p11 |
| 68 |
|
| 69 |
; ar vosim kamp, kFund, kForm, kDecay, kPulseCount, kPulseFactor, ifn [, iskip] |
| 70 |
ar1 vosim kamp, kfund, kform, kDecay, kPulseCount, kPulseFactor, 17, p12 |
| 71 |
|
| 72 |
; scale amplitude for 16-bit files, with quick fade out |
| 73 |
amp init 20000 |
| 74 |
if (p13 != 0) goto nofade |
| 75 |
amp linseg 20000, p3-.02, 20000, .02, 0 |
| 76 |
nofade: |
| 77 |
out ar1 * amp |
| 78 |
endin |
| 79 |
|
| 80 |
|
| 81 |
</CsInstruments> |
| 82 |
<CsScore> |
| 83 |
|
| 84 |
f1 0 32768 9 1 1 0 ; sine wave |
| 85 |
f17 0 32768 9 0.5 1 0 ; half sine wave |
| 86 |
i10 0 0 17 ; init run only, square table 17 |
| 87 |
|
| 88 |
; Vosim score |
| 89 |
|
| 90 |
; Picking some formants from the table in Csound manual |
| 91 |
|
| 92 |
; p4=amp fund form decay pulses pulsemod [skip] nofade |
| 93 |
; tenor a -> e |
| 94 |
i1 0 .5 .5 280 240 650 400 .03 5 1 0 0 |
| 95 |
i1 . . .3 . . 1080 1700 .03 5 . . . |
| 96 |
i1 . . .2 . . 2650 2600 .03 5 . . . |
| 97 |
i1 . . .15 . . 2900 3200 .03 5 . . . |
| 98 |
|
| 99 |
; tenor a -> o |
| 100 |
i1 0.6 .2 .5 300 210 650 400 .03 5 1 0 1 |
| 101 |
i1 . . .3 . . 1080 800 .03 5 . . . |
| 102 |
i1 . . .2 . . 2650 2600 .03 5 . . . |
| 103 |
i1 . . .15 . . 2900 2800 .03 5 . . . |
| 104 |
; tenor o -> aah |
| 105 |
i1 .8 .3 .5 210 180 400 650 .03 5 1 1 1 |
| 106 |
i1 . . .3 . . 800 1080 .03 5 . . . |
| 107 |
i1 . . .2 . . 2600 2650 .03 5 . . . |
| 108 |
i1 . . .15 . . 2800 2900 .03 5 . . . |
| 109 |
; tenor aa -> i |
| 110 |
i1 1.1 .2 .5 180 250 650 290 .03 5 1 1 1 |
| 111 |
i1 . . .3 . . 1080 1870 .03 5 . . . |
| 112 |
i1 . . .2 . . 2650 2800 .03 5 . . . |
| 113 |
i1 . . .15 . . 2900 3250 .03 5 . . . |
| 114 |
; tenor i -> u |
| 115 |
i1 1.3 .3 .5 250 270 290 350 .03 5 1 1 0 |
| 116 |
i1 . . .3 . . 1870 600 .03 5 . . . |
| 117 |
i1 . . .2 . . 2800 2700 .03 5 . . . |
| 118 |
i1 . . .15 . . 3250 2900 .03 5 . . . |
| 119 |
|
| 120 |
e |
| 121 |
|
| 122 |
</CsScore> |
| 123 |
</CsoundSynthesizer> |
| 124 |
|