[chuck-users] using global variables as arguments in sporking functions

Julien Saint-Martin julien.saintmartin at googlemail.com
Tue Mar 10 11:51:10 EDT 2020


Hi Herman,

I think you must use your CFreq (global variable) inside your second
function. And update the parameter you want inside the loop :

fun void LFO(float LFOfreq) {
    SinOsc lfo => blackhole;
    LFOfreq => lfo.freq;
    while( true )
    {
    1::samp => now;
    lfo.last() => c.gain ;

    *CFreq => lfo.freq;*

    }
}

Have fun,

Julien


Le mer. 4 mars 2020 à 20:22, herman verbaeten <hverb54 at hotmail.com> a
écrit :

> Hi,
>
> I'm having a problem passing a changing parameter(by an LFO in another
> function) to a function i'm sporking . Maybe this isn't possible :-( but
> i'd like your opinion) This is part of my script. Let me tell you this:
> When i give float *Cfreq *an initial value of 0.3  LFO does change gain
> of SinOsc c. If i don't give it an initial value and have *LFOtochangeCfreq
> *change it  -> no sound.
>
>
>  SinOsc m => SinOsc c => Pan2 p => dac;
> 2 => c.sync;
> float *Cfreq*;   //if i replace this line by: .3 => float Cfreq;
>
> spork ~ *LFOtochangeCfreq*(.1);
> spork ~ LFO(*Cfreq*);
>
>
>
> fun void *LFOtochangeCfreq*(float variation) {
>     SinOsc lfo => blackhole;
>     variation => lfo.freq;
>     while( true )
>     {
>     1000::samp => now;
>     <<<lfo.last() => *Cfreq*>>>;
>     }
>  }
>
> fun void LFO(float LFOfreq) {
>     SinOsc lfo => blackhole;
>     LFOfreq => lfo.freq;
>     while( true )
>     {
>     1::samp => now;
>     lfo.last() => c.gain ;
>     }
> }
>
> while (1) 10::ms=> now;
>
>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200310/30af6204/attachment-0001.html>


More information about the chuck-users mailing list