|
All,
In an attempt to do a better job than the standard open-source tools (azid,
BeSweet) with Dolby Pro Logic II 5.1-discrete-to-2-channel downmixing, I've
found myself in need of the ability to take a mono WAV input and phase-shift
it plus or minus 90 degrees (depending on which rear-channel input I'm
processing).
Knowing next to nothing about Csound except that it appears the only
command-line tool for the job, I've hacked up the manual example a bit and
come up with this (issues listed below):
; 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.wav -W ;;; for file output any platform
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
instr 1
idur = p3
; Initial amount of frequency shift.
; It can be positive or negative.
ibegshift = p4
; Final amount of frequency shift.
; It can be positive or negative.
iendshift = p5
; A simple envelope for determining the
; amount of frequency shift.
kfreq linseg ibegshift, idur, iendshift
; Use the sound of your choice.
ain soundin "mary.wav"
; Phase quadrature output derived from input signal.
areal, aimag hilbert ain
; Quadrature oscillator.
asin oscili 1, kfreq, 1
acos oscili 1, kfreq, 1, .25
; Use a trigonometric identity.
; See the references for further details.
amod1 = areal * acos
amod2 = aimag * asin
; Both sum and difference frequencies can be
; output at once.
; aupshift corresponds to the sum frequencies.
aupshift = (amod1 + amod2) * 0.7
; adownshift corresponds to the difference frequencies.
adownshift = (amod1 - amod2) * 0.7
; Notice that the adding of the two together is
; identical to the output of ring modulation.
out amod1
endin
; Sine table for quadrature oscillator.
f 1 0 16384 10 1
; Starting with no shift, ending with all
; frequencies shifted up by 200 Hz.
;i 1 0 2 0 200
; Starting with no shift, ending with all
; frequencies shifted down by 200 Hz.
;i 1 2 2 0 -200
i 1 0 99 0 0
e
Issues:
* Am I doing the right thing by making my out amod1 (or amod2) and
"short circuiting" the later logic from the example if in the end I simply
want the output to sound identical to the input wav except phase-shifted 90
degrees?
* Did I do the right thing in the score by eliminating the audible
frequency shift (in other words, am I still phase-shifting)?
* Is there a way to simplify kfreq since I don't want to shift the
audible frequencies up/down?
* How do I indicate to Csound that the score duration for instrument one
should be whatever the length of the input wav sample is?
Again, my end goal is to simply take a mono-channel, 48KHz/16 bit (I realize
mary.wav isn't, hence my script example isn't either) Microsoft WAV file and
output an identical-sounding 48KHz/16 bit WAV file that is phase-shifted
either + or - 90 degrees (depending on whether I go with amod1/amod2 as
out).
Can anyone shed some light for the clueless?
Rodney
--
View this message in context: http://www.nabble.com/%2B---90-degree-phase-shift-of-input-WAV--tf4197587.html#a11938504
Sent from the Csound - General mailing list archive at Nabble.com. |