[chuck-users] How to Invert Phase of a Signal

Atte André Jensen atte.jensen at gmail.com
Tue May 27 01:18:50 EDT 2008


Rich Caloggero wrote:
> OK, I'm a total beginner at all this dsp stuff, so forgive ...
> 
> One way of subjectively "widening" a stereo image is to do the following:
> feed the left channel back to the right with a short delay, inverted;
> feed the right channel back to the left with a short delay, inverted;
> 
> By inverted, I mean change the sign of each sample (assuming we have 
> floating point samples).
> 
> So now the newbie question: how do you invert the signal? I have the 
> rest of the algorithm here:
> 
> // note: sndbuf only seems to read in one channel of the source, so use 
> one file for each channel of stereo source

Use "1 => r.channel" to read the second channel of a stereofile...

Here's a modified example that inverts the phase of one channel. I threw 
away the SndBuf (sine is good for testing) and delay to be able to hear 
what's going on more clearly. So the trick is (thanks Kassen for 
enlighting me last week) is the blackhole sample sucker + the last() for 
reading and next for writing sample values. I think you should fairly 
easily be able to use my inverter() function in your code...

Hope that helps.
------------------------------
SinOsc l => dac.left;
SinOsc r => blackhole;
Step inverted => dac.right;
l => dac.left;
r => blackhole;

spork ~ inverter(r,inverted);

while(true) {
    1::second => now;
}

fun void inverter(UGen in, Step out){
     while(true){
         - in.last() => out.next;
         1::samp => now;
     }
}
----------------------------------

-- 
peace, love & harmony
Atte

http://atte.dk       | http://myspace.com/attejensen
http://anagrammer.dk | http://modlys.dk


More information about the chuck-users mailing list