Sample & Hold CV signal

thought there was a topic on it already, but, here it is again anyway:
Formula Device Sample & Hold:

  
<?xml version="1.0" encoding="UTF-8"?>  
<filterdeviceclipboard doc_version="0"><br>
  <deviceslot type="FormulaMetaDevice"><br>
    <isactive>true</isactive><br>
    <isselected>true</isselected><br>
    <selectedpresetname>Sample &amp; Hold</selectedpresetname><br>
    <selectedpresetismodified>false</selectedpresetismodified><br>
    <ismaximized>true</ismaximized><br>
    <customdevicename>Sample&amp;Hold</customdevicename><br>
    <formulaparagraphs><br>
      <formulaparagraph>sh(OUTPUT, A, B, C)</formulaparagraph><br>
    </formulaparagraphs><br>
    <functionsparagraphs><br>
      <functionsparagraph>function sh(output, a, input, c)</functionsparagraph><br>
      <functionsparagraph> if a == 1 then return output</functionsparagraph><br>
      <functionsparagraph> else return input</functionsparagraph><br>
      <functionsparagraph> end</functionsparagraph><br>
      <functionsparagraph>end</functionsparagraph><br>
      <functionsparagraph></functionsparagraph><br>
    </functionsparagraphs><br>
    <inputnamea>S/H</inputnamea><br>
    <inputnameb>Input</inputnameb><br>
    <inputnamec>_</inputnamec><br>
    <editorvisible>false</editorvisible><br>
    <panelvisible>0</panelvisible><br>
    <inputa><br>
      <value>0.0</value><br>
      <visualization>Device only</visualization><br>
    </inputa><br>
    <inputb><br>
      <value>0.449292958</value><br>
      <visualization>Device only</visualization><br>
    </inputb><br>
    <inputc><br>
      <value>0.0</value><br>
      <visualization>Device only</visualization><br>
    </inputc><br>
    <desttrack><br>
      <value>-1</value><br>
      <visualization>Device only</visualization><br>
    </desttrack><br>
    <desteffect><br>
      <value>-1</value><br>
      <visualization>Device only</visualization><br>
    </desteffect><br>
    <destparameter><br>
      <value>-1</value><br>
      <visualization>Device only</visualization><br>
    </destparameter><br>
  </deviceslot><br>
</filterdeviceclipboard>  
  

stupid little demo:
dl link: test.xrns

I’ve mentioned a very similar idea, can’t remember if in my own thread or as an extension to another idea (live recording into an LFO kinda thing.) If this does what I think then SWEET!!!

Yes and it was really simple too, just looking at the inertia… little difference, this machine has either full (1.0) inertia, or none.

How can you trigger recording? My idea was basically for live usage, where you would record a parameters change into a repeating buffer and then loop it at an adjustable rate (basically the current LFO device with some kind of record arming.) How do you toggle between recording and repeating? How long is the buffer?

Or don’t I quite understand?

Ahh yours is more like a gated CV signal (IE changes only get passed sometimes and held at last values at others), rather than sampling and holding the control signal. Misunderstanding on my part but I get it now I’ve had a quick look at your example I think…

You understand a bit of it, and that’s also what the device would record, a bit of it.
Although your idea is supercali, this thing does a true sample&hold and that means one sample.
I think your idea might be toolable though, but I’m not gonna really do stuff with LFO custom envelope until it’s got proper api support (it deserves that! :P)

Yeah I started thinking about it and came to the same conclusion and my coding skills are pale compared to yours!

But you’re right, that is proper sample and hold. Think it was the description of the link you erroneously posted in the wrong thread started me thinking like that, although rereading it now I see it also obviously means it works more like this. Although I still thinking of it more as time gated control…

You probably could use the Formula Device for something similar to what I describe, extending from what you already have here. Set up a lot of variables as shift registers, use the C input with a square wave input to cycle through them (one per line with standard square wave LFO would be easiest, you could go more resulation with Custom.) The the A input would change between playback and record modes…

Haha well look at the bright side man, you keep coming up with awesome ideas :D

Indeed with the formula it may be possible… But if you make it you constantly have to think with every decision: is this gonna be for 64 line patterns only, or for 12 lpb songs does it have to be usable too, etc :(

NUMLINES : Number of lines in current pattern

If you are sample at a multiple of X times per Line then it should work at any LPB.

Formula section is LUA, same as the API isn’t it? Little confused even with your basic formula for this… Can you use either A/B/C or whatever you’ve named them? As you seem to have “a” and “input” one of which I assume is your given name, the other is the default. Also doesn’t seem to follow capitalisation as I would have expected it too…

EDIT: I was forgetting there’s a USER and a FORMULA bit…

EDIT2: Sweet! Didn’t know that you get error messages from the Formula Device show up in the Terminal of the Scripting Editor if you have it open until just now :) It would be nice if it refrained from doing so while it was turned off though…

As you might have seen, C is the only one that’s not actually used (I think I renamed it C or _ or just “” or sth)
EDIT: switching “Input” & “Sample&Hold” would be a agreeable move so it looks a bit more like the Inertial Slider
So go on experiment, would be really cool to see a CV buffering Formula Device

Yeah my confusion with names was forgetting the User and Formula bits and how the obviously work differently. Kinda have it now though…

Did have a quick go of trying to create a ramp of value into a table and read them back one per line but so far completely failed! Not a good start but might try and find some time to give it another go…

I actually think it’s not yet possible to have custom (ie array/list) variables in the scripts in formula device, that are saved and remembered. All vars you have in the user area, are the ones you init…

There seem to be some weird things about it too, such as commenting out likes in the Formula section at the top doesn’t allow it to run from the ones below, you have to actually fully remove them.

So you don’t think you can do something along the lines of:

x = {}  
for i=1, NUMLINES do  
x[i] = i/NUMLINES  
end  

(May very well be syntax errors or others.)

to fill a table with a value ramp. And then try and play them out somehow…

Well the Formula side should be just one line, it’s the “return” line

about this other thing, I’m not sure how to test it, because, if you init it like that every time of course it’s gonna be available everytime. The question is, if you put this in the Formula section

  
formula(A,B,C)  
  

and this in the user

  
function formula(a,b,c)  
 x[LINE] = a  
 C = x[LINE]  
end  
  

and you point a LFO to the Formula’s A, for a whole pattern, and then turn the formula off, does the C slider keep moving??

Funny, thinking about it I’ve just found a working little thing that can save one pattern CV points, one every line. I tested it with a LFO > Formula Input, then reset a few times during pattern (run pattern at least once fully, with Formula “Store” set to 1) - Next set store to 0 (read mode) and disable the LFO… output keeps the original ‘loop’. You could use the B var still to determine the loop speed / factor. It’s a start

  
<?xml version="1.0" encoding="UTF-8"?>  
<filterdeviceclipboard doc_version="0"><br>
  <deviceslot type="FormulaMetaDevice"><br>
    <isactive>true</isactive><br>
    <isselected>true</isselected><br>
    <selectedpresetname>Init</selectedpresetname><br>
    <selectedpresetismodified>true</selectedpresetismodified><br>
    <ismaximized>true</ismaximized><br>
    <formulaparagraphs><br>
      <formulaparagraph>formula(A,B,C)</formulaparagraph><br>
    </formulaparagraphs><br>
    <functionsparagraphs><br>
      <functionsparagraph>function formula(a,b,set)</functionsparagraph><br>
      <functionsparagraph> if set==1 then x[LINE]=a end</functionsparagraph><br>
      <functionsparagraph> return x[LINE]</functionsparagraph><br>
      <functionsparagraph>end</functionsparagraph><br>
    </functionsparagraphs><br>
    <inputnamea>Input</inputnamea><br>
    <inputnameb>B</inputnameb><br>
    <inputnamec>Store</inputnamec><br>
    <editorvisible>true</editorvisible><br>
    <panelvisible>0</panelvisible><br>
    <inputa><br>
      <value>0.599437118</value><br>
      <visualization>Device only</visualization><br>
    </inputa><br>
    <inputb><br>
      <value>0.0</value><br>
      <visualization>Device only</visualization><br>
    </inputb><br>
    <inputc><br>
      <value>0.0</value><br>
      <visualization>Device only</visualization><br>
    </inputc><br>
    <desttrack><br>
      <value>-1</value><br>
      <visualization>Device only</visualization><br>
    </desttrack><br>
    <desteffect><br>
      <value>-1</value><br>
      <visualization>Device only</visualization><br>
    </desteffect><br>
    <destparameter><br>
      <value>-1</value><br>
      <visualization>Device only</visualization><br>
    </destparameter><br>
  </deviceslot><br>
</filterdeviceclipboard>