Here is a short work-in-progress test for a frequency tracker with the
 Hilbert transform

The structure is
DC blocker -> adaptive lowpass prefilter -> Hilbert ->>
->> phase difference:unwrap:normalize, amplitude ->> short adaptive integration

it's a bit expensive, but four stages in the Hilber seem to suffice (
the lowpass uses 3 SVF ).

Sometimes it gets stuck on max or min frequency, but whats interesting is that
otherwise it seems to find a musical picth with noisy or even polyphonic input,

The example uses the CZ half sine oscillator, whats funny is that it
retains part of the timbre,
You can even understand speech to some extend.
I assume due to phase and amplitude modulations that remain in the
output  (?) and the waveform.

The concept was based on Miller Puckette: Ptach For Guitar I believe,
where the idea was to
use the phasor directly for synthesis. I used it for live granular
pitch and formant shifting in the past,
but dont recall the structure in detail anymore.

The output here is: normalized frequency, amplitude.

I am not sure why it  sometimes gets stuck, maybe someone has an idea
or solution
to fix and improve this:

// continous monophonic frequency tracker test
//
// dc blocker -> adaptive lowpass prefilter -> Hilbert ->
//  -> phase difference:unwrap:normalize, amplitude -> short adaptive
integration
//
//( concept originally based on "Patch For Guitar" by Miller Puckette iirc )
//

import("stdfaust.lib");

drywet =  (hslider("[1]DryWet[style:knob]",1,0,1,0.01)) ;

fwmin = 55 / ma.SR;    // min. frequency
fwmax = 1760 / ma.SR;  // max. frequency

// lowpass for integration ( cutoff, input )
lpp = ma.E^(- 2*ma.PI * lpfw * 0.5);
lpa = 1-lpp;
lp(fw, x) = x : fi.pole(lpp)*(1-lpp)
        with { lpp = ma.E^(- 2*ma.PI * fw); };

freqtrack(x) = (_,x:prefilt:
wamp:max(_,fwmin),_:min(_,fwmax),_:(_<:_,_,_),_:lp,lp)~_:_,_
        with {
            prefilt(fw,x) = x:  fi.svf.lp(fw*ma.SR, 0.518):
                                fi.svf.lp( fw*ma.SR, 0.707):
                                fi.svf.lp( fw*ma.SR, 1.932);

            wamp(x) = x:fi.hilbert(4, ma.SR/128) <:(_<:_,_),(_<:_,_):
                    route( 4,4, 1,1, 2,3, 3,2, 4,4 ):(_<:_,_), (_<:_,_),_,_:
                     *,*,_,_: + ,_,_:sqrt,(_,_:route(2,2, 1,2, 2,1):atan2):
                     _,(_ <:_,_'): _, - :_,ma.unwrap(ma.PI):_,_/(2*ma.PI):
                    route(2,2, 1,2, 2,1);
            };

testosc(fw, amp) = os.CZhalfSine(fw*ma.SR,0.3) * amp: fi.dcblockerat(25);

process = +:fi.dcblockerat(35): _<:_*(1-drywet), (freqtrack:testosc) *
drywet :>_ <:_,_;


_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to