Hi Julius,

Thanks for the trick, it works pretty well: I can compile it using faust 
compiler and options -lang cpp -scal -ftz 0 with 300 samples. I will try for 
more with some more time. The web assembly seems not to like it actually.

I did not try yet to see if the detected pitch is accurate. But I think you got 
the idea.

Thanks :)

Nicolas



> On 6 May 2020, at 19:21, Julius Smith <julius.sm...@gmail.com> wrote:
> 
> Hi Nicolas,
> 
> It looks like you are asking for unbounded correlation lags.  Try limiting it 
> with something like   i = min(1e8,+(1)) ~_ ;
> 
> - Julius
> 
> On Tue, May 5, 2020 at 11:56 PM Nicolas Gravillon <gravil...@gmail.com 
> <mailto:gravil...@gmail.com>> wrote:
> Hi everyone,
> 
> First of all, thank you all for your amazing achievement with Faust. I am 
> delighted to use it and amazed by all this work. Regarding my problem, I try 
> for some time now to implement a pitch tracker implementing autocorrelation, 
> for a more reliable metering than the zero crossing method. I ended with the 
> following version, strongly inspired from Tiziano Bole work :
> 
> import("stdfaust.lib");
> 
> BufferLength=4;
> 
> pitch(x) = ma.SR / max(M, 1) - ma.SR * (M == 0)
>   with {
>   AC(x, k) = sum(j, BufferLength, (x@(j))*(x@(j+k))) / (BufferLength) ; // 
> Correlating two signals, on the buffer length, ideally over 600 samples with 
> actual SR
>   i = +(1) ~_ ;
>   U = AC(x,i)  >  AC(x,0)/2;             // Detection of a good correlation, 
> AC(x,0) being the highest possible value, so its half becomes the detection 
> threshold
>   V = AC(x,i)  <= AC(x,i+1);
>   W = AC(x,i+1) > AC(x,i+2);
>   Y = U: *(V) : *(W);                        
> 
>   N = (+(1) : *(1 - Y)) ~ _;
>   M = (N' + 1) : ba.sAndH(Y);
> };
> 
> process = pitch : hbargraph(“Frequency", 50, 2000);
> 
> The problem seems to be located in the Autocorrelation function :   AC(x, k) 
> = sum(j, BufferLength, (x@(j))*(x@(j+k))) / (BufferLength) since the error 
> says “can’t compute the min and max values of […] used in delay expression 
> […] (probably a recursive signal).
> 
> Any chance to get it working? I do not see actually how to fix boundaries for 
> the delay lines, or get rid of the recursive guess from the compiler.
> 
> Thanks for reading this,
> 
> Nicolas
> _______________________________________________
> Faudiostream-users mailing list
> Faudiostream-users@lists.sourceforge.net 
> <mailto:Faudiostream-users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/faudiostream-users 
> <https://lists.sourceforge.net/lists/listinfo/faudiostream-users>
> 
> 
> -- 
> "Anybody who knows all about nothing knows everything" -- Leonard Susskind

_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to