; Select audio/midi flags here according to platform
; Audio out Audio in No messages
-odac -iadc -d ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o hilbert_barberpole.wav -W ;;; for file output any platform
; Initialize the global variables.
sr = 44100
; kr must equal sr for the barberpole effect to work.
kr = 44100
ksmps = 1
nchnls = 2
; Instrument #1
instr 1
idur = p3
ibegshift = p4
iendshift = p5
; sawtooth wave, not bandlimited
asaw phasor 100
; add offset to center phasor amplitude between -.5 and .5
asaw = asaw - .5
; sawtooth wave, with amplitude of 10000
ain = asaw * 20000
; The envelope of the frequency shift.
kfreq linseg ibegshift, idur, iendshift
; Phase quadrature output derived from input signal.
areal, aimag hilbert ain
; The quadrature oscillator.
asin oscili 1, kfreq, 1
acos oscili 1, kfreq, 1, .25
; Based on trignometric identities.
amod1 = areal * acos
amod2 = aimag * asin
; Calculate the up-shift and down-shift.
aupshift = (amod1 + amod2) * 0.7
adownshift = (amod1 - amod2) * 0.7
; Mix in the original signal to achieve the barberpole effect.
amix1 = aupshift + ain
amix2 = aupshift + ain
; Make sure the output doesn't get louder than the original signal.
aout1 balance amix1, ain
aout2 balance amix2, ain
outs aout1, aout2
endin
; Table 1: A sine wave for the quadrature oscillator.
f 1 0 16384 10 1
; The score.
; p4 = frequency shifter, starting frequency.
; p5 = frequency shifter, ending frequency.
i 1 0 6 -10 10
e