Dear Oleg, James, Dario, all,
`control` looks promising, however, it is not as straight-forward as I thought: ``` import("stdfaust.lib"); // a sinewave sineFloatFreq = os.oscp(1000.0, 0); // an impulse with variable frequency and leading trigger trigger = impulse(1000) with { impulse(freq) = 1-1', (lfsaw_uni(freq, 0) : strictFalling) :> _; strictFalling(x) = x < x'; lfsaw_uni(freq, phase) = inc(freq) + phaseChange(phase : ma.frac) : + ~ ma.frac with { phaseChange(phase) = phase - phase'; inc(freq) = freq/float(ma.SR); }; }; process = trigger <: _, _, _, _ : _, // trigger sineFloatFreq, // sine wave, try to toggle-comment this line // 0, // with this line to see how it affects // computational behaviour control(sineFloatFreq, _), // outer sine wave control(innerSine, _), // inner sine wave (integer frequency) control(innerSineFloatFreq, _) // inner sine wave (same definition as outer sine wave) with { innerSine = os.oscp(1000, 0); innerSineFloatFreq = os.oscp(1000.0, 0); }; ``` if you run this e.g. in the faustide[1], you'll see that `sineFloatFreq` and `innerSineFloatFreq ` reduce to the same code, while `innerSine`, which has a slightly different definition (`freq` is `(int) 1000` instead of `float(1000.0)`) behaves as I'd expect. Note that, although definitions are equivalent, output of all is different This means that a recursive definition with latch is still needed. I'll investigate further. all the best Till [1] (I turned off autorun but it seems to have no effect...) https://faustide.grame.fr/?autorun=0&voices=0&name=controlDemand&inline=aW1wb3J0KCJzdGRmYXVzdC5saWIiKTsKCi8vIGEgc2luZXdhdmUKc2luZUZsb2F0RnJlcSA9IG9zLm9zY3AoMTAwMC4wLCAwKTsKCi8vIGFuIGltcHVsc2Ugd2l0aCB2YXJpYWJsZSBmcmVxdWVuY3kgYW5kIGxlYWRpbmcgdHJpZ2dlcgp0cmlnZ2VyID0gaW1wdWxzZSgxMDAwKSB3aXRoIHsKICAgIGltcHVsc2UoZnJlcSkgPSAxLTEnLCAobGZzYXdfdW5pKGZyZXEsIDApIDogc3RyaWN0RmFsbGluZykgOj4gXzsKICAgIHN0cmljdEZhbGxpbmcoeCkgPSB4IDwgeCc7CiAgICBsZnNhd191bmkoZnJlcSwgcGhhc2UpID0gaW5jKGZyZXEpICsgcGhhc2VDaGFuZ2UocGhhc2UgOiBtYS5mcmFjKSA6ICsgfiBtYS5mcmFjIHdpdGggewogICAgICAgIHBoYXNlQ2hhbmdlKHBoYXNlKSA9IHBoYXNlIC0gcGhhc2UnOwogICAgICAgIGluYyhmcmVxKSA9IGZyZXEvZmxvYXQobWEuU1IpOwogICAgfTsKfTsKCgpwcm9jZXNzID0gdHJpZ2dlciA8OiBfLCBfLCBfLCBfIDogCiAgICBfLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHRyaWdnZXIKICAgIHNpbmVGbG9hdEZyZXEsICAgICAgICAgICAgICAgICAgLy8gc2luZSB3YXZlLCB0cnkgdG8gdG9nZ2xlLWNvbW1lbnQgdGhpcyBsaW5lICAKICAgIC8vIDAsICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gICB3aXRoIHRoaXMgbGluZSB0byBzZWUgaG93IGl0IGFmZmVjdHMgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgY29tcHV0YXRpb25hbCBiZWhhdmlvdXIKICAgIGNvbnRyb2woc2luZUZsb2F0RnJlcSwgXyksICAgICAgLy8gb3V0ZXIgc2luZSB3YXZlIAogICAgY29udHJvbChpbm5lclNpbmUsIF8pLCAgICAgICAgICAvLyBpbm5lciBzaW5lIHdhdmUgKGludGVnZXIgZnJlcXVlbmN5KQogICAgY29udHJvbChpbm5lclNpbmVGbG9hdEZyZXEsIF8pICAvLyBpbm5lciBzaW5lIHdhdmUgKHNhbWUgZGVmaW5pdGlvbiBhcyBvdXRlciBzaW5lIHdhdmUpCndpdGggewogICAgaW5uZXJTaW5lID0gb3Mub3NjcCgxMDAwLCAwKTsKICAgIGlubmVyU2luZUZsb2F0RnJlcSA9IG9zLm9zY3AoMTAwMC4wLCAwKTsKfTsK -- Till Bovermann https://tai-studio.org | http://lfsaw.de | https://www.instagram.com/_lfsaw/ > On 14. Jul 2020, at 14:42, Oleg Nesterov <o...@redhat.com> wrote: > > On 07/14, Till Bovermann wrote: >> >> Thanks also to you, Oleg; is there somewhere an example for the control >> primitive, > > Sorry, I do not know. But see below. > > However, I did "git pull" and it seems that "control/enable" are already > supported in FIR scalar mode. Probably the commit 32846af52e92498? Cool. > > Say, > > process = control(sin, _); > > compiles to > > virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** > outputs) { > FAUSTFLOAT* input0 = inputs[0]; > FAUSTFLOAT* input1 = inputs[1]; > FAUSTFLOAT* output0 = outputs[0]; > float fTemp0 = fTempPerm0; > for (int i = 0; (i < count); i = (i + 1)) { > if (float(input1[i]) != 0.0f) { > fTemp0 = std::sin(float(input0[i])); > } > output0[i] = FAUSTFLOAT(fTemp0); > } > fTempPerm0 = fTemp0; > } > > note that sin(input0[i]) is only evaluated if input1[i] != 0. > > Oleg. > _______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users