sample hold

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

How to make sample/hold?

Post

11ivan11 wrote: Fri Jan 12, 2024 5:48 pm How to make sample/hold?
You asked the same question well over a year ago. Did you never check for a reply?

viewtopic.php?p=8566264#p8566264
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

I think it can be done with a conditional statement and memory
I'm don't have very much aptitude,
but like

a = trigger == 1 & lfostream
write a to memory
memory is held sample value

Post

nix808 wrote: Fri Jan 12, 2024 11:01 pm I think it can be done with a conditional statement and memory
I'm don't have very much aptitude,
but like

a = trigger == 1 & lfostream
write a to memory
memory is held sample value
Well.. kinda.. the naive approach is something like:

Code: Select all

init: state = 0

for each sample:
  if(trigger) state = input
  output = state
The issues with this is that it can only be triggered at integer samples. That's find for S&H of control signals, but if you're going to do this for audio signals it's better to (1) estimate (or solve if it's clocked from a steady clock) exact trigger time, (2) interpolate the input to find the value at the exact trigger time and (3) use BLEPs to reconstruct the zero-order hold output. This way there will be aliasing/imaging based on the S&H clock, but you'll avoid aliasing related to the processing sample rate... but again, if you're mostly processing low-frequency control signals, then this is totally overkill and the naive approach is perfectly fine.

Post

thanks Mystran
In Flowstone, Ruby which doesn't have streams, only buffer blocks of samples,
can interpret 'if',
where DSP audio coding has no if, and the statement would be like that in part at least
As far as anti-aliasing, I am largely at a loss to band-limit such a device,
sample accuracy should be quite do-able though

Post Reply

Return to “DSP and Plugin Development”