Csound Csound-dev Csound-tekno Search About

[Csnd] Cross-correlation of two signals

Date2012-01-15 20:19
FromAlex Weiss
Subject[Csnd] Cross-correlation of two signals
Hi all

My signal processing background is not too strong, so maybe someone could clarify this for me: if I have two (equally long) sections of two sound files, and I'd like to measure how similar those two sections are, I need to calculate their cross-correlation, correct? Is there a way to do this in csound? I've skimmed the manual but couldn't find anything.

Thanks,
Alex

Date2012-01-15 23:52
FromTito Latini
SubjectRe: [Csnd] Cross-correlation of two signals
AttachmentsNone  

Date2012-01-16 07:09
FromAndres Cabrera
SubjectRe: [Csnd] Cross-correlation of two signals
Hi,

Nice one Tito!

I just wanted to point out that cross-correlation will give you
similarity in purely statistical terms: how well a waveform matches
another, but it won't really tell you whether one sounds like the
other one. Because it is done in the time domain, things like phase
changes from filters can result in low correlation even though it
might sound very similar.

Cheers,
Andrés

On Sun, Jan 15, 2012 at 11:52 PM, Tito Latini  wrote:
>> My signal processing background is not too strong, so maybe someone could
>> clarify this for me: if I have two (equally long) sections of two sound
>> files, and I'd like to measure how similar those two sections are, I need
>> to calculate their cross-correlation, correct? Is there a way to do this in
>> csound? I've skimmed the manual but couldn't find anything.
>
> I don't know if this tool is useful for your purpose, however you
> make your experience. In the time domain
>
>  sig1 `corr' sig2  =  time-reversal of sig1 `conv' sig2
>
> The autocorrelation
>
>  sig `corr` sig
>
> is useful for pitch detection; if sig is periodic, you see periodic
> peaks in the autocorr func.
>
> A simple example of corr with mono soundfiles is
>
> 
> 
> sr     = 44100
> ksmps  = 64
> nchnls = 1
>
> instr 1
>  Sig1 = "foo.wav"
>  Sig2 = "bar.wav"
>  ilen1  filelen Sig1
>  ilen2  filelen Sig2
>  p3 = ilen1+ilen2
>  ;; sig1 reversed
>  ain  diskin2 Sig1, -1, ilen1
>  aout pconvolve ain, Sig2
>  out aout*0.0003
> endin
> 
> 
> i1 0 1
> 
> 
>
> tito
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2012-01-16 08:32
FromVictor
SubjectRe: [Csnd] Cross-correlation of two signals
It should also be possible to write a "streaming" autocorrelation instrument with dconv and a table writer, although I have not tried it yet.

Sent from my iPad

On 15 Jan 2012, at 23:52, Tito Latini  wrote:

>> My signal processing background is not too strong, so maybe someone could
>> clarify this for me: if I have two (equally long) sections of two sound
>> files, and I'd like to measure how similar those two sections are, I need
>> to calculate their cross-correlation, correct? Is there a way to do this in
>> csound? I've skimmed the manual but couldn't find anything.
> 
> I don't know if this tool is useful for your purpose, however you
> make your experience. In the time domain
> 
>  sig1 `corr' sig2  =  time-reversal of sig1 `conv' sig2
> 
> The autocorrelation
> 
>  sig `corr` sig
> 
> is useful for pitch detection; if sig is periodic, you see periodic
> peaks in the autocorr func.
> 
> A simple example of corr with mono soundfiles is
> 
> 
> 
> sr     = 44100
> ksmps  = 64
> nchnls = 1
> 
> instr 1
>  Sig1 = "foo.wav"
>  Sig2 = "bar.wav"
>  ilen1  filelen Sig1
>  ilen2  filelen Sig2
>  p3 = ilen1+ilen2
>  ;; sig1 reversed
>  ain  diskin2 Sig1, -1, ilen1
>  aout pconvolve ain, Sig2
>  out aout*0.0003
> endin
> 
> 
> i1 0 1
> 
> 
> 
> tito
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"