[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Frequency shift to alleviate acoustic feedback

Hi All,

I don't know if this will help or confuse things, but here is a pretty smooth frequency-shifting implementation in SuperCollider:

// Frequency-Shifting Example 5: Add phase-correction
//   MouseX = amplitude
//   MouseY = frequency shift (400 * (2 ** MouseY(-1,1)) in [200,800])
//   MouseButton = clear frequency shift
x = {
var in, out, amp, f0=400, fftSize=8192, winLen=2048, hopFrac=0.5,
chain, mexp, fScaled, df, binShift, phaseShift,
inWinType=0, outWinType=0;
amp = MouseX.kr(-60,10).dbamp;
in = SinOsc.ar(f0,0,amp);
chain = FFT(LocalBuf(fftSize), in, hopFrac, inWinType, 1, winLen);
mexp = MouseY.kr(-1.0,1.0);
mexp = mexp*(1-MouseButton.kr);
fScaled = f0 * (2.0 ** mexp);
df = fScaled - f0;
binShift = fftSize * (df / s.sampleRate);
chain = PV_BinShift(chain, stretch:1, shift:binShift, interp:1);
phaseShift = 2 * pi * binShift * hopFrac * (winLen/fftSize);
chain = PV_PhaseShift(chain, phaseShift, integrate:1);
out = IFFT(chain,outWinType,winLen);
Out.ar(0, out.dup);

- Julius

At 04:48 AM 1/25/2013, Steve Beet wrote:
Dear Siping,

I'd agree with Dick's simplification, except to note that *if* you can assume that the listeners are not sensitive to phase, then frequency shifting is actually very easy - you merely have to ensure phase continuity at block boundaries, or (my preferred approach) do the processing sample-by-sample using a direct analogue of the traditional EE approach: heterodyning followed by linear filtering.

I've also just remembered one reference which is relevant to this, and should give you some idea of the issues involved in manipulating an audio signal in terms of the frequencies, amplitudes and phases of its components:

R.J. McAulay, T. F. Quartieri; "Speech analysis/synthesis based on a sinusoidal representation"; IEEE Trans. on Acoust., Speech and Signal Proc., vol ASSP-34, pp. 744-754, 1986.

Good luck,


On Thu, 24 Jan 2013 22:41:05 -0800
"Richard F. Lyon" <dicklyon@xxxxxxx> wrote:

> To put it more simply, the original assumption that frequency shifting
> would be "the simplest method" was unfounded.
> Frequency shifting is actually quite complicated, subtle, error prone, and
> not so well defined.
> Dick

Julius O. Smith III <jos@xxxxxxxxxxxxxxxxxx>
Prof. of Music and Assoc. Prof. (by courtesy) of Electrical Engineering
CCRMA, Stanford University