Csound Csound-dev Csound-tekno Search About

[Csnd] about pitch tracking

Date2012-10-13 12:40
Fromfrancesco
Subject[Csnd] about pitch tracking
Hello All,
i'm trying to do some real time pitch tracking (with amplified guitar)
using ptrack; i have this problem:
when audio input is silence (well, when i'm not playing) i have output
at low frequencies (and hight amplitude);
using ampdbfs(kamp) into oscillator give me better result with silent input,
but a more scaled audio signal although i'm using ksmps = 1.
I have tried to make some sort of threshold on input, somethings
like if abs(ainput < 0.1) then amplitude * 0, but then i have distort
audio.
There is some way to apply a threshold at input?
Do i need to filter the output with a high pass filter?

Do You have some advices in general?


My simple test csd:

audio in
; ptrack
kcps, kamp ptrack audio, 4096

;a1 poscil ampdbfs(kamp), kcps, giSine
a1 poscil kamp*0.005, kcps, giSine

outs a1, a1




--
View this message in context: http://csound.1045644.n5.nabble.com/about-pitch-tracking-tp5716798.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-10-13 13:43
FromJustin Smith
SubjectRe: [Csnd] about pitch tracking
The compress opcode can be used as an noise gate if you set your
minimum pass through level as kthresh. This can eliminate output below
a certain threshold with minimal distortion.

Also, you can high pass filter your input (I recommend using buthp) to
eliminate those spurious low frequency signals. Really, unless you are
using a whammy bar, you can filter out everything lower than your low
E, and that should help the accuracy of your pitch tracking.

On Sat, Oct 13, 2012 at 4:40 AM, francesco  wrote:
> Hello All,
> i'm trying to do some real time pitch tracking (with amplified guitar)
> using ptrack; i have this problem:
> when audio input is silence (well, when i'm not playing) i have output
> at low frequencies (and hight amplitude);
> using ampdbfs(kamp) into oscillator give me better result with silent input,
> but a more scaled audio signal although i'm using ksmps = 1.
> I have tried to make some sort of threshold on input, somethings
> like if abs(ainput < 0.1) then amplitude * 0, but then i have distort
> audio.
> There is some way to apply a threshold at input?
> Do i need to filter the output with a high pass filter?
>
> Do You have some advices in general?
>
>
> My simple test csd:
>
> audio in
> ; ptrack
> kcps, kamp ptrack audio, 4096
>
> ;a1 poscil ampdbfs(kamp), kcps, giSine
> a1 poscil kamp*0.005, kcps, giSine
>
> outs a1, a1
>
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/about-pitch-tracking-tp5716798.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> 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-10-13 16:15
FromOeyvind Brandtsegg
SubjectRe: [Csnd] about pitch tracking
I normally use follow2 for better control over the amp envelope extraction.
Also, you can get a better tradeoff between frequency and time
resolution in ptrack by switching between two different ptrack
instrnaces with different hopsize, and do the switching dependent on
detected fundamental frequency.
Finally, some median filtering of the ptrack frequency output can get
rid of most of the intermittencies.

Here's some code lifted from the Hadron orchestra,
I've adapted it a little bit to make it more clear for what I guess is
your purpose.
Hope I did not make any silly errors when cutting and pasting,... did
not test this version of the code, but in any case it should show the
general idea of the setup.

best
Oeyvind

;*********************************************************************
; Pitch and amp analysis
; from Hadron code, Oeyvind Brandtsegg 2011, adapted 2012

	kcps 		init 0	
	ihopsize1	= 4096
	ihopsize2	= 512
	iChangeover	= (sr/ihopsize2)*3

if kcps > iChangeover kgoto small
	kcps, kamp 	ptrack a1, ihopsize1
if kcps <= iChangeover kgoto nosmall
small:
	kcps, kamp 	ptrack a1, ihopsize2
nosmall:

; filter pitch tracking signal
	imedianSize	= int(0.09*kr)		; calc as (1/(ihopsize*2))*kr
	kcps		mediank	kcps, imedianSize, imedianSize

; we don't use the amp output from ptrack as it is quite noisy, now
using the follow2 amp analysis
	iAttack		= 0.001
	iRelease	= 0.15 				
	aFollow		follow2	a1, iAttack, iRelease
	kamp		downsamp aFollow

;(your output is kcps and kamp)
;*********************************************************************



2012/10/13 Justin Smith :
> The compress opcode can be used as an noise gate if you set your
> minimum pass through level as kthresh. This can eliminate output below
> a certain threshold with minimal distortion.
>
> Also, you can high pass filter your input (I recommend using buthp) to
> eliminate those spurious low frequency signals. Really, unless you are
> using a whammy bar, you can filter out everything lower than your low
> E, and that should help the accuracy of your pitch tracking.
>
> On Sat, Oct 13, 2012 at 4:40 AM, francesco  wrote:
>> Hello All,
>> i'm trying to do some real time pitch tracking (with amplified guitar)
>> using ptrack; i have this problem:
>> when audio input is silence (well, when i'm not playing) i have output
>> at low frequencies (and hight amplitude);
>> using ampdbfs(kamp) into oscillator give me better result with silent input,
>> but a more scaled audio signal although i'm using ksmps = 1.
>> I have tried to make some sort of threshold on input, somethings
>> like if abs(ainput < 0.1) then amplitude * 0, but then i have distort
>> audio.
>> There is some way to apply a threshold at input?
>> Do i need to filter the output with a high pass filter?
>>
>> Do You have some advices in general?
>>
>>
>> My simple test csd:
>>
>> audio in
>> ; ptrack
>> kcps, kamp ptrack audio, 4096
>>
>> ;a1 poscil ampdbfs(kamp), kcps, giSine
>> a1 poscil kamp*0.005, kcps, giSine
>>
>> outs a1, a1
>>
>>
>>
>>
>> --
>> View this message in context: http://csound.1045644.n5.nabble.com/about-pitch-tracking-tp5716798.html
>> Sent from the Csound - General mailing list archive at Nabble.com.
>>
>>
>> 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"
>



-- 

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp

Date2012-10-13 17:55
Fromfrancesco
Subject[Csnd] Re: about pitch tracking
Thanks All,
i'm going to try Your suggestions.

About plltrack i need to better understand how is working ... 
For example:
is alock (phase lock indicator, a phase error indicating the quality of the
tracking)
related to amplitude values?
And what exactly means pll feedback gain, controls frequency range of PLL?

Where can i find some explanation about this algorithm?

Thanks,
ciao,
francesco.




--
View this message in context: http://csound.1045644.n5.nabble.com/about-pitch-tracking-tp5716798p5716805.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-10-13 18:12
FromVictor Lazzarini
SubjectRe: [Csnd] Re: about pitch tracking
Well, the value of alock, which will be between 0 and 1, indicates the phase errors, and so high values are good. You can ignore this if you like.

The higher the PLL gain (between 0 and 1) the wider the range of the tracking, but also more instability/errors can occur. Try a value of 0.2 to start with and then increase if you need.

The paper reporting on this is 

Zolzer, U, Sankarababu, S.V. and Moller, S, PLL-based Pitch Detection and Tracking for Audio Signals. Proc. of IIH-MSP 2012.

Regards

Victor

On 13 Oct 2012, at 17:55, francesco wrote:

> Thanks All,
> i'm going to try Your suggestions.
> 
> About plltrack i need to better understand how is working ... 
> For example:
> is alock (phase lock indicator, a phase error indicating the quality of the
> tracking)
> related to amplitude values?
> And what exactly means pll feedback gain, controls frequency range of PLL?
> 
> Where can i find some explanation about this algorithm?
> 
> Thanks,
> ciao,
> francesco.
> 
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/about-pitch-tracking-tp5716798p5716805.html
> Sent from the Csound - General mailing list archive at Nabble.com.
> 
> 
> 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"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2012-10-13 18:38
Fromjpff@cs.bath.ac.uk
SubjectRe: [Csnd] Re: about pitch tracking
Any chance of a manual page for this opcode?


> Well, the value of alock, which will be between 0 and 1, indicates the
> phase errors, and so high values are good. You can ignore this if you
> like.
>
> The higher the PLL gain (between 0 and 1) the wider the range of the
> tracking, but also more instability/errors can occur. Try a value of 0.2
> to start with and then increase if you need.
>
> The paper reporting on this is
>
> Zolzer, U, Sankarababu, S.V. and Moller, S, PLL-based Pitch Detection and
> Tracking for Audio Signals. Proc. of IIH-MSP 2012.
>
> Regards
>
> Victor
>
> On 13 Oct 2012, at 17:55, francesco wrote:
>
>> Thanks All,
>> i'm going to try Your suggestions.
>>
>> About plltrack i need to better understand how is working ...
>> For example:
>> is alock (phase lock indicator, a phase error indicating the quality of
>> the
>> tracking)
>> related to amplitude values?
>> And what exactly means pll feedback gain, controls frequency range of
>> PLL?
>>
>> Where can i find some explanation about this algorithm?
>>
>> Thanks,
>> ciao,
>> francesco.
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://csound.1045644.n5.nabble.com/about-pitch-tracking-tp5716798p5716805.html
>> Sent from the Csound - General mailing list archive at Nabble.com.
>>
>>
>> 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"
>>
>
> Dr Victor Lazzarini
> Senior Lecturer
> Dept. of Music
> NUI Maynooth Ireland
> tel.: +353 1 708 3545
> Victor dot Lazzarini AT nuim dot ie
>
>
>
>
>
> 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-10-13 19:12
FromVictor Lazzarini
SubjectRe: [Csnd] Re: about pitch tracking
yes... on my todo list.
On 13 Oct 2012, at 18:38, jpff@cs.bath.ac.uk wrote:

> Any chance of a manual page for this opcode?
> 
> 
>> Well, the value of alock, which will be between 0 and 1, indicates the
>> phase errors, and so high values are good. You can ignore this if you
>> like.
>> 
>> The higher the PLL gain (between 0 and 1) the wider the range of the
>> tracking, but also more instability/errors can occur. Try a value of 0.2
>> to start with and then increase if you need.
>> 
>> The paper reporting on this is
>> 
>> Zolzer, U, Sankarababu, S.V. and Moller, S, PLL-based Pitch Detection and
>> Tracking for Audio Signals. Proc. of IIH-MSP 2012.
>> 
>> Regards
>> 
>> Victor
>> 
>> On 13 Oct 2012, at 17:55, francesco wrote:
>> 
>>> Thanks All,
>>> i'm going to try Your suggestions.
>>> 
>>> About plltrack i need to better understand how is working ...
>>> For example:
>>> is alock (phase lock indicator, a phase error indicating the quality of
>>> the
>>> tracking)
>>> related to amplitude values?
>>> And what exactly means pll feedback gain, controls frequency range of
>>> PLL?
>>> 
>>> Where can i find some explanation about this algorithm?
>>> 
>>> Thanks,
>>> ciao,
>>> francesco.
>>> 
>>> 
>>> 
>>> 
>>> --
>>> View this message in context:
>>> http://csound.1045644.n5.nabble.com/about-pitch-tracking-tp5716798p5716805.html
>>> Sent from the Csound - General mailing list archive at Nabble.com.
>>> 
>>> 
>>> 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"
>>> 
>> 
>> Dr Victor Lazzarini
>> Senior Lecturer
>> Dept. of Music
>> NUI Maynooth Ireland
>> tel.: +353 1 708 3545
>> Victor dot Lazzarini AT nuim dot ie
>> 
>> 
>> 
>> 
>> 
>> 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"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2012-10-14 06:44
FromDavid Akbari
SubjectRe: [Csnd] Re: about pitch tracking
On Sat, Oct 13, 2012 at 12:12 PM, Victor Lazzarini
 wrote:

> Zolzer, U, Sankarababu, S.V. and Moller, S, PLL-based Pitch Detection and Tracking for Audio Signals. Proc. of IIH-MSP 2012.

Quite an interesting read. The low computational complexity and
implicit ability to scale this algorithm for large systems make this
an intriguing addition to Csound. I am sure there are some audio
situations where a single instance of this algorithm will not be
sufficient but it will be interesting to see how many instances
processing a signal using different parameters might yield what one
instance cannot. There are plenty of instances where F0 might not be
immediately obvious in a given signal or situation. It will be
interesting to see what results of this new opcode will yield. Csound
is the perfect place to sandbox something this innovative; thanks for
sharing!

With regards to the original poster's dilemma, it is probably still a
good idea to introduce an expander/ gate in some way to your signal
chain. Especially if you are considering using the PLL idea, it may be
important if your are mic-ing your guitar amplifier so that the
instantaneous frequency estimates are less contaminated by the "wash"
from the amplifier. From the paper it seems like the more you can do
to reduce extraneous noise from your signal of interest the better off
your pitch tracking result will be. It is not explicitly discussed in
the paper, but you may also find greater success in trying to minimize
reverberation, unison detune/ chorus effects, or other things that may
influence the algorithm's ability to accurately detect the fundamental
frequency of your audio input. Perhaps separate instances or Csound
instrs that detect a dry direct input signal vs. a mic'ed amplifier
signal would help in this regard.


-David