| Hi,
With some ideas from Matt (Matt's Shoddy Vocoder) and Jean Piche I have
rewritten a more flexible vocoder system. Note that tables are used to
specify the frequencies and the modulator frequencies can be mapped to
different carrier frequencies.
Have Fun,
Hans Mikelson
; ORCHESTRA
;-----------------------------------------------------------------
; Variable Vocoder
; Coded by Hans Mikelson 6/20/1998
;-----------------------------------------------------------------
sr=44100
kr=4410
ksmps=10
nchnls=2
zakinit 50, 50 ; Initialize the zak system
;---------------------------------------------------------------------------
-------
; Disk Input Stereo
;---------------------------------------------------------------------------
-------
instr 3
iamp = p4 ; Amplitude
irate = p5 ; Read rate
isndin = p6 ; Sound input file
ioutch1 = p7 ; Output channel 1
ioutch2 = p8 ; Output channel 2
ain1, ain2 diskin isndin, irate ; Read stereo input
zaw ain1, ioutch1 ; Output to audio channel 1
zaw ain2, ioutch2 ; Output to audio channel 2
endin
;---------------------------------------------------------------------------
------
; Sawtooth (Band Limited Impulse Train)
;---------------------------------------------------------------------------
------
instr 4
idur = p3 ; Duration
iamp = p4 ; Amplitude
ifqc = cpspch(p5) ; Note to frequency
ipanl = sqrt(p6) ; Pan left
ipanr = sqrt(1-p6) ; Pan Right
ioutch1 = p7 ; Output Channel 1
ioutch2 = p8 ; Output Channel 2
kdclik linseg 0, .002, iamp, idur-.004, iamp, .002, 0
apulse buzz 1,ifqc, sr/2/ifqc, 1 ; Avoid aliasing
asawdc integ apulse ; Integrating the pulses makes a saw
wave
axn = asawdc-.5 ; Shift DC offset
aoutl = kdclik*axn*ipanl ; De-click & pan
aoutr = kdclik*axn*ipanr
zawm aoutl, ioutch1 ; Write to output channels
zawm aoutr, ioutch2
endin
;---------------------------------------------------------------------------
------
; PWM (Band Limited Impulse Train)
;---------------------------------------------------------------------------
------
instr 5
idur = p3 ; Duration
iamp = p4 ; Amplitude
ifqc = cpspch(p5) ; Note to frequency
ipanl = sqrt(p6) ; Pan left
ipanr = sqrt(1-p6) ; Pan Right
ioutch1 = p7 ; Output Channel 1
ioutch2 = p8 ; Output Channel 2
imodrate = p9
imodepth = p10
kdclik linseg 0, .002, iamp, idur-.004, iamp, .002, 0
klfo oscili imodepth, imodrate, 1
kfqc = ifqc*(1+klfo)
apulse1 buzz 1,ifqc, sr/2/ifqc, 1 ; Avoid aliasing
apulse2 vdelay apulse1, 1000/kfqc/2, 1000/ifqc
avpw = apulse1 - apulse2 ; two inverted pulses at variable
distance
apwmdc integ avpw
axn butterhp apwmdc, 10 ; remove DC offset caused by
integ
aoutl = kdclik*axn*ipanl ; De-click & pan
aoutr = kdclik*axn*ipanr
zawm aoutl, ioutch1 ; Write to output channels
zawm aoutr, ioutch2
; outs aoutl, aoutr
endin
;---------------------------------------------------------------------------
-------
; 8 Band Vocoder
;---------------------------------------------------------------------------
-------
instr 11
iamp = p4 ; Amplitude
asigm zar p5 ; Modulator
asigc zar p6 ; Carrier
ipan = p7 ; Pan
ifqmtab = p8 ; Modular Frequency Table
ifqctab = p9 ; Carrier Frequency Table
ibw = p10 ; Bandwidth factor
; Compute the center frequency for each band.
ifqm1 table 0, ifqmtab
ifqm2 table 1, ifqmtab
ifqm3 table 2, ifqmtab
ifqm4 table 3, ifqmtab
ifqm5 table 4, ifqmtab
ifqm6 table 5, ifqmtab
ifqm7 table 6, ifqmtab
ifqm8 table 7, ifqmtab
; Compute center frequency for each carrier band.
; Note that you can rebuild based on different frequencies
ifqc1 table 0, ifqctab
ifqc2 table 1, ifqctab
ifqc3 table 2, ifqctab
ifqc4 table 3, ifqctab
ifqc5 table 4, ifqctab
ifqc6 table 5, ifqctab
ifqc7 table 6, ifqctab
ifqc8 table 7, ifqctab
; Bandpass filter the modulator
am1 butterbp asigm, ifqm1, ifqm1/20*ibw
am2 butterbp asigm, ifqm2, ifqm2/20*ibw
am3 butterbp asigm, ifqm3, ifqm3/20*ibw
am4 butterbp asigm, ifqm4, ifqm4/20*ibw
am5 butterbp asigm, ifqm5, ifqm5/20*ibw
am6 butterbp asigm, ifqm6, ifqm6/20*ibw
am7 butterbp asigm, ifqm7, ifqm7/20*ibw
am8 butterbp asigm, ifqm8, ifqm8/20*ibw
; Bandpass filter the carrier
ac1 butterbp asigc, ifqc1, ifqc1/20*ibw
ac2 butterbp asigc, ifqc2, ifqc2/20*ibw
ac3 butterbp asigc, ifqc3, ifqc3/20*ibw
ac4 butterbp asigc, ifqc4, ifqc4/20*ibw
ac5 butterbp asigc, ifqc5, ifqc5/20*ibw
ac6 butterbp asigc, ifqc6, ifqc6/20*ibw
ac7 butterbp asigc, ifqc7, ifqc7/20*ibw
ac8 butterbp asigc, ifqc8, ifqc8/20*ibw
; Balance carrier level to modulator level.
ao1 balance ac1, am1
ao2 balance ac2, am2
ao3 balance ac3, am3
ao4 balance ac4, am4
ao5 balance ac5, am5
ao6 balance ac6, am6
ao7 balance ac7, am7
ao8 balance ac8, am8
; Add up the carriers and output with panning.
aout = (ao1+ao2+ao3+ao4+ao5+ao6+ao7+ao8)*iamp/ibw
outs aout*sqrt(ipan), aout*sqrt(1-ipan)
endin
;---------------------------------------------------------------------------
; Zak Clear
;---------------------------------------------------------------------------
instr 99
zacl 0, 50
zkcl 0, 50
endin
; SCORE
f1 0 65536 10 1
; Sta Dur Amp Rate In Out1 Out2
i3 0 8.69 1 1 11 1 2
; Sta Dur Amp Fqc Pan Out1 Out2 ModRate ModDepth
i5 0 4.1 10000 7.04 .5 3 4 1 .4
i5 0 4.1 10000 7.07 .8 3 4 1 .4
i5 0 4.1 10000 8.00 .5 3 4 1 .4
i5 0 4.1 10000 8.05 .1 3 4 1 .4
i5 4 4.59 10000 6.10 .5 3 4 1 .4
i5 4 4.59 10000 7.03 .2 3 4 1 .4
i5 4 4.59 10000 8.07 .5 3 4 1 .4
i5 4 4.59 10000 9.00 .9 3 4 1 .4
f10 0 8 -5 100 8 400
f11 0 8 -8 100 3 400 2 200 3 600
f12 0 8 -5 400 8 1600
f13 0 8 -7 400 8 1600
f14 0 8 -5 1600 8 6400
f15 0 8 -5 6400 8 1600
; Sta Dur Amp InM InC Pan ModTable CarTable Width
i11 0 8.69 1.0 1 3 1 10 15 .5
i11 0 8.69 1.0 2 4 0 10 15 .5
i11 0 8.69 1.0 1 3 1 12 11 .5
i11 0 8.69 1.0 2 4 0 12 11 .5
i11 0 8.69 1.0 1 3 1 14 13 .5
i11 0 8.69 1.0 2 4 0 14 13 .5
; Sta Dur
i99 0 8.69
|