Quantcast

Re: Get audo sigal's highest frequency/lowest frequency (above certain thresold)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get audo sigal's highest frequency/lowest frequency (above certain thresold)

seanlee
Hi Daniel,

Thanks for pointing out, could you explain more about  RunningMax / RunningMin for helping trakcing the higest/lowest freq?  I'm kind of new to these kind of machine listening. Thanks!

On Wed, Feb 15, 2017 at 3:45 AM, Daniel Mayer [via New SuperCollider Mailing Lists Forums (Use These!!!)] <[hidden email]> wrote:

Am 14.02.2017 um 16:15 schrieb seanlee <[hidden email]>:

> Hi sc users,
>
> I was trying to synthesis some sound based on current audio input's highest
> frequency /lowest frequency (maybe need to above a thresold), sort of like
> *SpecCentroid* but for lowest/highest.



In addition to a FFT-based analysis, as Nathan suggested, you might want
to use RunningMax / RunningMin for tracking.

Regards

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------



_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/



To unsubscribe from Get audio sigal's highest frequency/lowest frequency (above certain thresold), click here.
NAML



--
Best regards,
李松, Sean Lee
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get audo sigal's highest frequency/lowest frequency (above certain thresold)

daniel-mayer

Am 16.02.2017 um 06:08 schrieb seanlee <[hidden email]>:

> Hi Daniel,
>
> Thanks for pointing out, could you explain more about  RunningMax /
> RunningMin for helping trakcing the higest/lowest freq?


Applying to a variant of Nathan's example:

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(2, 100, 300), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(2, 200, 1000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(chain, 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(chain, 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with Saw
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(Saw.ar(min, 0.12) + Saw.ar(max, 0.05) + IFFT(chain)) ! 2 *
                EnvGate(fadeTime: 0.5);
}.play;
)

// retrigger min / max tracking, try several times
x.set(\t_max, 1)

x.set(\t_min, 1)


s.scope

s.freqscope

x.release


// higher register and sine waves as indicator, easier to follow the effect in freqscope

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(0.5, 100, 600), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(0.5, 200, 2000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(chain, 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(chain, 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with SinOsc
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(SinOsc.ar(min, 0, 0.12) + SinOsc.ar(max, 0, 0.05) + IFFT(chain)) ! 2 *
                EnvGate(fadeTime: 0.5);
}.play;
)

// retrigger min / max tracking, try several times
x.set(\t_max, 1)

x.set(\t_min, 1)


s.scope

s.freqscope

x.release



Greetings

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------







_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get audo sigal's highest frequency/lowest frequency (above certain thresold)

Glen Fraser
Hi Daniel, I don't know why, but when I run your examples, the tracked values don't coincide at all with the range of frequencies.  Instead, I get min of around 4k Hz and max of ~18kHz.  Strange, because Nathan's original SpecPcile version gives me good values.

Looking at this further, it seems that once you throw an IFFT in there, it screws up the SpecPcile values...at least for me! (OS X, SC 3.8.0)

When I run the following version (just added IFFT, doesn't matter whether you output it or not), I get wrong SpecPcile values.  If the IFFT line is commented out, then the values make sense:

(
{
    var snd, chain;
    snd = WhiteNoise.ar;
    snd = BHiPass4.ar(snd, 300, 0.1);
    snd = BLowPass4.ar(snd, 1000, 0.3);
    chain = FFT(LocalBuf(2048), snd);
    SpecPcile.kr(chain, 0.05).poll(label: "min");
    SpecPcile.kr(chain, 0.95).poll(label: "max");
  IFFT(chain); // when this line is commented out, the results of SpecPcile look correct
  0
}.play;
)

With IFFT included, I get wrong values like:

min: 4818.73
max: 17726

With it commented (Nathan's original code), I get reasonable values:

min: 279.659
max: 1355.27

Somehow the (later) IFFT is screwing up the FFT buffers for "earlier"?

Glen.


On Thu, Feb 16, 2017 at 8:47 PM, Daniel Mayer <[hidden email]> wrote:

Am 16.02.2017 um 06:08 schrieb seanlee <[hidden email]>:

> Hi Daniel,
>
> Thanks for pointing out, could you explain more about  RunningMax /
> RunningMin for helping trakcing the higest/lowest freq?


Applying to a variant of Nathan's example:

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(2, 100, 300), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(2, 200, 1000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(chain, 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(chain, 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with Saw
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(Saw.ar(min, 0.12) + Saw.ar(max, 0.05) + IFFT(chain)) ! 2 *
                EnvGate(fadeTime: 0.5);
}.play;
)

// retrigger min / max tracking, try several times
x.set(\t_max, 1)

x.set(\t_min, 1)


s.scope

s.freqscope

x.release


// higher register and sine waves as indicator, easier to follow the effect in freqscope

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(0.5, 100, 600), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(0.5, 200, 2000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(chain, 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(chain, 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with SinOsc
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(SinOsc.ar(min, 0, 0.12) + SinOsc.ar(max, 0, 0.05) + IFFT(chain)) ! 2 *
                EnvGate(fadeTime: 0.5);
}.play;
)

// retrigger min / max tracking, try several times
x.set(\t_max, 1)

x.set(\t_min, 1)


s.scope

s.freqscope

x.release



Greetings

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------







_______________________________________________
sc-users mailing list


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get audo sigal's highest frequency/lowest frequency (above certain thresold)

Glen Fraser
(in your two examples, it works fine if you replace IFFT(chain) by the original snd)


On Fri, Feb 17, 2017 at 10:34 AM, Glen F <[hidden email]> wrote:
Hi Daniel, I don't know why, but when I run your examples, the tracked values don't coincide at all with the range of frequencies.  Instead, I get min of around 4k Hz and max of ~18kHz.  Strange, because Nathan's original SpecPcile version gives me good values.

Looking at this further, it seems that once you throw an IFFT in there, it screws up the SpecPcile values...at least for me! (OS X, SC 3.8.0)

When I run the following version (just added IFFT, doesn't matter whether you output it or not), I get wrong SpecPcile values.  If the IFFT line is commented out, then the values make sense:

(
{
    var snd, chain;
    snd = WhiteNoise.ar;
    snd = BHiPass4.ar(snd, 300, 0.1);
    snd = BLowPass4.ar(snd, 1000, 0.3);
    chain = FFT(LocalBuf(2048), snd);
    SpecPcile.kr(chain, 0.05).poll(label: "min");
    SpecPcile.kr(chain, 0.95).poll(label: "max");
  IFFT(chain); // when this line is commented out, the results of SpecPcile look correct
  0
}.play;
)

With IFFT included, I get wrong values like:

min: 4818.73
max: 17726

With it commented (Nathan's original code), I get reasonable values:

min: 279.659
max: 1355.27

Somehow the (later) IFFT is screwing up the FFT buffers for "earlier"?

Glen.


On Thu, Feb 16, 2017 at 8:47 PM, Daniel Mayer <[hidden email]> wrote:

Am 16.02.2017 um 06:08 schrieb seanlee <[hidden email]>:

> Hi Daniel,
>
> Thanks for pointing out, could you explain more about  RunningMax /
> RunningMin for helping trakcing the higest/lowest freq?


Applying to a variant of Nathan's example:

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(2, 100, 300), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(2, 200, 1000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(chain, 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(chain, 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with Saw
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(Saw.ar(min, 0.12) + Saw.ar(max, 0.05) + IFFT(chain)) ! 2 *
                EnvGate(fadeTime: 0.5);
}.play;
)

// retrigger min / max tracking, try several times
x.set(\t_max, 1)

x.set(\t_min, 1)


s.scope

s.freqscope

x.release


// higher register and sine waves as indicator, easier to follow the effect in freqscope

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(0.5, 100, 600), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(0.5, 200, 2000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(chain, 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(chain, 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with SinOsc
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(SinOsc.ar(min, 0, 0.12) + SinOsc.ar(max, 0, 0.05) + IFFT(chain)) ! 2 *
                EnvGate(fadeTime: 0.5);
}.play;
)

// retrigger min / max tracking, try several times
x.set(\t_max, 1)

x.set(\t_min, 1)


s.scope

s.freqscope

x.release



Greetings

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------







_______________________________________________
sc-users mailing list



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get audo sigal's highest frequency/lowest frequency (above certain thresold)

daniel-mayer
In reply to this post by Glen Fraser

Am 17.02.2017 um 10:34 schrieb Glen F <[hidden email]>:

> Hi Daniel, I don't know why, but when I run your examples, the tracked values don't coincide at all with the range of frequencies.  Instead, I get min of around 4k Hz and max of ~18kHz.  Strange, because Nathan's original SpecPcile version gives me good values.


Examples ran for me on 3.6.6.
But right, and there are even two issues here:
EnvGate doesn't work as expected anymore and the
implementation of SpecPcile seems to have changed.
As the FFT procedure changes its chain,
apply it to a PV_Copy thereof.

BTW it seems a bit odd that SpecPcile, though not designed
for a spectral transformation, changes its chain.
Its not mentioned in the help file either.

Here checked on 3.8

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max, chain_1, chain_2;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(2, 100, 300), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(2, 200, 1000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(PV_Copy(chain, LocalBuf(2048)), 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(PV_Copy(chain, LocalBuf(2048)), 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with Saw
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(Saw.ar(min, 0.12) + Saw.ar(max, 0.05) + IFFT(chain)) ! 2 *
                EnvGen.ar(Env.dadsr(0.5, 1, curve: 1), doneAction: 2);
}.play;
)


// retrigger min / max tracking, try several times
x.set(\t_max, 1)

x.set(\t_min, 1)


// higher register and sine waves as indicator, easier to follow the effect in freqscope

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(0.5, 100, 600), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(0.5, 200, 2000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(PV_Copy(chain, LocalBuf(2048)), 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(PV_Copy(chain, LocalBuf(2048)), 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with SinOsc
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(SinOsc.ar(min, 0, 0.12) + SinOsc.ar(max, 0, 0.05) + IFFT(chain)) ! 2 *
                EnvGen.ar(Env.dadsr(0.5, 1, curve: 1), doneAction: 2);
}.play;
)



Regards

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------





_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get audo sigal's highest frequency/lowest frequency (above certain thresold)

Glen Fraser
I don't think the problem is that SpecPcile changes the chain, but rather that IFFT seems to do so "retroactively"...  It works fine if you just make one PV_Copy after the SpecPcile calls but before the IFFT (see below).  I guess this may be because the SpecPcile runs at control rate (which is more frequent than "FFT rate"), so after the first control block (including FFT stuff) is done, the chain has been modified for subsequent evaluations of SpecPcile... ?

This works fine for me:

.... // noise, filters, FFT, etc
min = RunningMin.kr(SpecPcile.kr(chain, 0.05), t_min).poll(label: "min");
max = RunningMax.kr(SpecPcile.kr(chain, 0.95), t_max).poll(label: "max");
chain = PV_Copy(chain, LocalBuf(2048));
... // LeakDC on SinOscs plus IFFT, etc



On Fri, Feb 17, 2017 at 12:27 PM, Daniel Mayer <[hidden email]> wrote:

Am 17.02.2017 um 10:34 schrieb Glen F <[hidden email]>:

> Hi Daniel, I don't know why, but when I run your examples, the tracked values don't coincide at all with the range of frequencies.  Instead, I get min of around 4k Hz and max of ~18kHz.  Strange, because Nathan's original SpecPcile version gives me good values.


Examples ran for me on 3.6.6.
But right, and there are even two issues here:
EnvGate doesn't work as expected anymore and the
implementation of SpecPcile seems to have changed.
As the FFT procedure changes its chain,
apply it to a PV_Copy thereof.

BTW it seems a bit odd that SpecPcile, though not designed
for a spectral transformation, changes its chain.
Its not mentioned in the help file either.

Here checked on 3.8

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max, chain_1, chain_2;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(2, 100, 300), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(2, 200, 1000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(PV_Copy(chain, LocalBuf(2048)), 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(PV_Copy(chain, LocalBuf(2048)), 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with Saw
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(Saw.ar(min, 0.12) + Saw.ar(max, 0.05) + IFFT(chain)) ! 2 *
                EnvGen.ar(Env.dadsr(0.5, 1, curve: 1), doneAction: 2);
}.play;
)


// retrigger min / max tracking, try several times
x.set(\t_max, 1)

x.set(\t_min, 1)


// higher register and sine waves as indicator, easier to follow the effect in freqscope

(
x = { |t_min = 1, t_max = 1|
        var snd, chain, min, max;
        // min gets 0 at start, so trigger again with delay

        t_min = t_min + DelayN.kr(Impulse.kr(0), 0.1, 0.05);
        snd = WhiteNoise.ar(0.05);

        snd = BHiPass4.ar(snd, LFDNoise3.ar(0.5, 100, 600), 0.1);
        snd = BLowPass4.ar(snd, LFDNoise3.ar(0.5, 200, 2000), 0.1);
        chain = FFT(LocalBuf(2048), snd);
        min = RunningMin.kr(SpecPcile.kr(PV_Copy(chain, LocalBuf(2048)), 0.05), t_min)
                .poll(label: "min");
        max = RunningMax.kr(SpecPcile.kr(PV_Copy(chain, LocalBuf(2048)), 0.95), t_max)
                .poll(label: "max");
        // indicate min/max with SinOsc
        // build in LeakDC for freq values 0
        // add envelope
        LeakDC.ar(SinOsc.ar(min, 0, 0.12) + SinOsc.ar(max, 0, 0.05) + IFFT(chain)) ! 2 *
                EnvGen.ar(Env.dadsr(0.5, 1, curve: 1), doneAction: 2);
}.play;
)



Regards

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------





_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Loading...