My starting point was this: https://faustdoc.grame.fr/manual/syntax/#rwtable-primitive
On 22/12/20 14:37, Stéphane Letz wrote:
Where does this looper code comes from? Thanks. StéphaneLe 22 déc. 2020 à 14:29, Daniele Pagliero <daniele.pagli...@gmail.com> a écrit : Hello Stéphane, thanks a lot, This solve the compile error. I take the advantage of your kindness to ask more about the language functionality that to me is still cryptic. here is the previous code with the int cast fix: import("stdfaust.lib"); sampleRate = 48000; maxTime = 4; maxSamples = sampleRate * maxTime; btn = button("[4]trigger"); readSpeed = hslider("[3]read_speed", 1, -3, 3, 0.1) : si.smoo; loopSize = ba.sAndH(btn, fi.pole(btn, btn)) : int : hbargraph("[0]loop_size", 0, maxSamples); readIndex = readSpeed/float(sampleRate) : (+ : ma.decimal) ~ _ : *(float(loopSize)) : int : hbargraph("[1]read_index", 0, maxSamples); recIndex = (+(1) : %(maxSamples)) ~ *(btn) : int : hbargraph("[2]rec_index", 0, maxSamples); looper = rwtable(maxSamples,0.0,recIndex,_,readIndex); process = looper, looper; I need help to understand the recursion operator and why it doesn't work as I expect. this statement is clear: recIndex = (+(1) : %(maxSamples)) ~ *(btn) and I can translate it in something like: recIndex = ((recIndex + 1) % maxSamples) * btn Now I have problem understanding this one: readIndex = readSpeed/float(sampleRate) : (+ : ma.decimal) ~ _ : *(float(loopSize)) : int This doesn't fit my needs as I want the speed constant independently on the loopSize so I tried to change it in this way: readIndex = (+(1) : %(loopSize)) ~ _ : int that for me seems the same syntax of: readIndex = (readIndex + 1) % loopSize But it doesn't work. Can you please help me? Thank you, Daniele On 22/12/20 12:34, Stéphane Letz wrote:OK, : rwtable(n,s,w,_,r) : _ Where: • n: the table size • s: the initial table content • w: the write index (an int between 0 and n-1) • r: the read index (an int between 0 and n-1) So « w » and « r » must be of type « int » , correction here : recIndex = (+(1) : %(maxSamples)) ~ *(btn) : hbargraph("[2]rec_index", 0, maxSamples) : int; This does compile (but I’ve not tested final result) StéphaneLe 22 déc. 2020 à 11:52, Daniele Pagliero <daniele.pagli...@gmail.com> a écrit : Hello Stéphane, actually I'm playing with the online Faust IDE. Daniele Il giorno mar 22 dic 2020 alle ore 11:40 Stéphane Letz <l...@grame.fr> ha scritto: Hi Daniele, I don’t see this error when compiling here with master-dev 2.30.3 version. Which Faust version are you using ? Thanks. StéphaneLe 22 déc. 2020 à 01:34, daniele.pagli...@gmail.com a écrit : Hi Dario, thanks a lot! It is exactly what I needed. To go further with the looper, here is the code so far: import("stdfaust.lib"); sampleRate = 48000; maxTime = 4; maxSamples = sampleRate * maxTime; btn = button("[4]trigger"); readSpeed = hslider("[3]read_speed", 1, -3, 3, 0.1) : si.smoo; loopSize = ba.sAndH(btn, fi.pole(btn, btn)) : hbargraph("[0]loop_size", 0, maxSamples); readIndex = readSpeed/float(sampleRate) : (+ : ma.decimal) ~ _ : *(float(loopSize)) : int : hbargraph("[1]read_index", 0, maxSamples); recIndex = (+(1) : %(maxSamples)) ~ *(btn) : hbargraph("[2]rec_index", 0, maxSamples); // doesn't compile // looper = rwtable(maxSamples,0.0,recIndex,_,readIndex); // compiles looper = rwtable(maxSamples,0.0,0,_,readIndex); process = looper; the read and write indexes are from the example I found on the documentation: https://faustdoc.grame.fr/manual/syntax/#rwtable-primitive I get this error for the recIndex and I can't understand its meaning: ERROR inferring write table type, wrong write index type : RSESN interval() Can you please point me anywhere I can figuring out what does it mean? Sorry, my knowledge of the platform is quite small and also functional programming syntax is not always clear to me... Thanks, Daniele Il 21/12/20 15:34, Dario Sanfilippo ha scritto:Hi, Daniele. Perhaps something like this? import("stdfaust.lib"); btn = button("trigger"); down_samples = ba.sAndH(btn, fi.pole(btn, btn)); process = down_samples; Ciao, Dario On Mon, 21 Dec 2020 at 14:56, Daniele Pagliero <daniele.pagli...@gmail.com> wrote: Hello, I need help understanding how to get the elapsed time or samples between 2 clicks on a button. Let's say I have a button like: btn = button("trigger"); I need to know for how long the button was pressed. Then use the value to control a rwtable to create a variable length looper. I've searched in the docs but I didn't find any clue... Thanks, Daniele _______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users -- Dr Dario Sanfilippo http://dariosanfilippo.com_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users-- Daniele Pagliero Via Rosta, 5 10143 TORINO - ITALY mobile: (39)339-1154922 --- Think before you print to save energy and paper. Do you really need to print this email? If you do, print it double sided. ---
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users