Csound Csound-dev Csound-tekno Search About

[Csnd] Tracking the Frequency of an Acoustic Instrument

Date2022-12-12 19:42
FromPhilipp Neumann
Subject[Csnd] Tracking the Frequency of an Acoustic Instrument
Hello Everybody!

Today i tried to track the live input of an acoustic guitar and to control a k-Var with it. I want to replicate the incoming fundamental frequency as good as it could be.
I analyzed it with ‚pvsanal‘ and tried some different stuff. Mostly i used ‚pvstrace‘ and ‚pvscent‘. 

The results were not that good i wanted them to be. 
Maybe you have some advice for me?

This was my setting:

iFFTsize = 2048 ; 1024
iOverlap = iFFTsize/16 ; /8
iWinsize = iFFTsize
iWintype = 1 ; Hann
fIn pvsanal aMic, iFFTsize, iOverlap, iWinsize, iWintype
fTrace pvstrace fIn, 15 
kfftFreq pvscent fTrace
kfftFreq port kfftFreq, 0.01
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-12-12 19:58
From"Jeanette C."
SubjectRe: [Csnd] Tracking the Frequency of an Acoustic Instrument
Hello Philipp!

Dec 12 2022, Philipp Neumann has written:

> Hello Everybody!
>
> Today i tried to track the live input of an acoustic guitar and to control a k-Var with it. I want to replicate the incoming fundamental frequency as good as it could be.
...
I think pvspitch is the better opcode to calculate the pitch of an
instrument. There are other opcodes with built-in FFT to also do it for
you.

I found I got better results, if I compressed the signal going into the
pitch analysis, especially with dynamic things like voice - and possibly
guitar.

Other opcodes you might try are: pitch, pitchamdf, plltrack or ptrack. I
don't know enough about pitch analysis to suggest which of these is
particularly good for a certain purpose. But IIRC they are well
documented in the manual, including caveats.

Best wishes and good luck,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

And when you say those words
It's the sweetest thing I've ever heard <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-12-13 00:06
FromRichard Knight
SubjectRe: [Csnd] Tracking the Frequency of an Acoustic Instrument
Hi
It also may be useful (depending on use case) to round the pitch 
tracking frequency to the nearest note (eg if using 12tet, and you want 
the exact note), and if not to be used in realtime, maybe even 
time-average (mode) the frequencies - I've had some good results with 
those.

Didn't know about plltrack, thanks!
Richard


On 2022-12-12 19:58, Jeanette C. wrote:
> Hello Philipp!
> 
> Dec 12 2022, Philipp Neumann has written:
> 
>> Hello Everybody!
>> 
>> Today i tried to track the live input of an acoustic guitar and to 
>> control a k-Var with it. I want to replicate the incoming fundamental 
>> frequency as good as it could be.
> ...
> I think pvspitch is the better opcode to calculate the pitch of an
> instrument. There are other opcodes with built-in FFT to also do it for
> you.
> 
> I found I got better results, if I compressed the signal going into the
> pitch analysis, especially with dynamic things like voice - and 
> possibly
> guitar.
> 
> Other opcodes you might try are: pitch, pitchamdf, plltrack or ptrack. 
> I
> don't know enough about pitch analysis to suggest which of these is
> particularly good for a certain purpose. But IIRC they are well
> documented in the manual, including caveats.
> 
> Best wishes and good luck,
> 
> Jeanette
> 
> --
>  * Website: http://juliencoder.de - for summer is a state of sound
>  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
>  * GitHub: https://github.com/jeanette-c
> 
> And when you say those words
> It's the sweetest thing I've ever heard <3
> (Britney Spears)
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2022-12-13 00:27
FromGiovanni Bedetti
SubjectRe: [Csnd] Tracking the Frequency of an Acoustic Instrument
Hi Philipp, 

The first thing you should do is to low pass filter your audio signal, since high frequencies and harmonics can lead to very jittery behaviours.
I got good results also with the pitch opcode, but you need to define the expected range with a fair amount of confidence.
Also be aware that low sounds are harder to be detected, and that complex textures (like chords or multiple voices) could lead to unexpected results (so the most powerful harmonic should be picked, but that can vary a lot depending on the material).
There's no easy solution when analysing those kinds of signals.


Il giorno mar 13 dic 2022 alle ore 00:07 Richard Knight <richard@1bpm.net> ha scritto:
Hi
It also may be useful (depending on use case) to round the pitch
tracking frequency to the nearest note (eg if using 12tet, and you want
the exact note), and if not to be used in realtime, maybe even
time-average (mode) the frequencies - I've had some good results with
those.

Didn't know about plltrack, thanks!
Richard


On 2022-12-12 19:58, Jeanette C. wrote:
> Hello Philipp!
>
> Dec 12 2022, Philipp Neumann has written:
>
>> Hello Everybody!
>>
>> Today i tried to track the live input of an acoustic guitar and to
>> control a k-Var with it. I want to replicate the incoming fundamental
>> frequency as good as it could be.
> ...
> I think pvspitch is the better opcode to calculate the pitch of an
> instrument. There are other opcodes with built-in FFT to also do it for
> you.
>
> I found I got better results, if I compressed the signal going into the
> pitch analysis, especially with dynamic things like voice - and
> possibly
> guitar.
>
> Other opcodes you might try are: pitch, pitchamdf, plltrack or ptrack.
> I
> don't know enough about pitch analysis to suggest which of these is
> particularly good for a certain purpose. But IIRC they are well
> documented in the manual, including caveats.
>
> Best wishes and good luck,
>
> Jeanette
>
> --
>  * Website: http://juliencoder.de - for summer is a state of sound
>  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
>  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
>  * GitHub: https://github.com/jeanette-c
>
> And when you say those words
> It's the sweetest thing I've ever heard <3
> (Britney Spears)
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here