If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
True sample and hold
9 posts
• Page 1 of 1
True sample and hold
Hello gang,
Does any one have a real sample and hold or could design one for me. That is one that samples (captures, grabs) the voltage of a continuously varying analog signal and holds (locks, freezes) its value at a constant level for a specified minimum period of time. This is the definition of a analog hardware sample and hold. I need a Flowstone version that does exactly the same thing.
Many thanks in advance if you have one or the possibilits of designing one!
Later then, BobF.....
Does any one have a real sample and hold or could design one for me. That is one that samples (captures, grabs) the voltage of a continuously varying analog signal and holds (locks, freezes) its value at a constant level for a specified minimum period of time. This is the definition of a analog hardware sample and hold. I need a Flowstone version that does exactly the same thing.
Many thanks in advance if you have one or the possibilits of designing one!
Later then, BobF.....
- BobF
- Posts: 598
- Joined: Mon Apr 20, 2015 9:54 pm
Re: True sample and hold
Are you thinking something like a VCA ? [voltage control amplifier].
This 'sample/hold' value ... are you talking volume ? If so ... PEAK level? RMS ?
This 'sample/hold' value ... are you talking volume ? If so ... PEAK level? RMS ?
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: True sample and hold
Hi RJHOLLINS,
No! For now look up some definitions of a analog sample and hold. I will TRY to come up with a better explanation later if no one figures it out.
Thanks, BobF.....
No! For now look up some definitions of a analog sample and hold. I will TRY to come up with a better explanation later if no one figures it out.
Thanks, BobF.....
- BobF
- Posts: 598
- Joined: Mon Apr 20, 2015 9:54 pm
Re: True sample and hold
This will sample (and hold) the input value when the trigger goes from <=0 to >0:
- Code: Select all
streamin in; streamout out;
streamin sampleTrigger;
float prevTrigger;
float update;
update = (sampleTrigger>0)&(prevTrigger<=0);
out = out + (in - out)&update;
prevTrigger = sampleTrigger;
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: True sample and hold
And this one will hold for a specified time (=number of samples):
- Code: Select all
streamin in; streamout out;
streamin sampleTrigger;
streamin duration;
float trigger;
float prevTrigger;
float time;
float update;
trigger = (sampleTrigger>0)&(prevTrigger<=0);
prevTrigger = sampleTrigger;
time = min(time + 1,duration);
time = time - time&trigger;
update = trigger | (time>=duration);
out = out + (in - out)&update;
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: True sample and hold
I was just working on this, because I thought this would make a perfect entry in dsp programming. It is relatively simple. Yet, my code wasn't nearly as effective as yours, Martin. Especially, I don't understand this line in your second code:
I can read it, but I don't get the human logic behind it. Could you elaborate, please? Just if you can spare a minute!
- Code: Select all
out = out + (in - out)&update;
I can read it, but I don't get the human logic behind it. Could you elaborate, please? Just if you can spare a minute!
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: True sample and hold
That's essentially
if update then out = in
else out = out
How is that? The "update" vasiable is a bit pattern, either all 1 or all 0. In the first case the expression evaluates to
out = out + (in - out)&1 = out + in - out = in
In the second case we get
out = out + (in - out)&0 = out + 0 = out
The objective of using bit masking insead of an if-then-else structure is to avoid branching so the code can be better optimized by the compiler. Specifically for FS, bitmasks work in the poly section of a synth whereas if-then-else does not.
if update then out = in
else out = out
How is that? The "update" vasiable is a bit pattern, either all 1 or all 0. In the first case the expression evaluates to
out = out + (in - out)&1 = out + in - out = in
In the second case we get
out = out + (in - out)&0 = out + 0 = out
The objective of using bit masking insead of an if-then-else structure is to avoid branching so the code can be better optimized by the compiler. Specifically for FS, bitmasks work in the poly section of a synth whereas if-then-else does not.
Last edited by martinvicanek on Sun Sep 25, 2016 2:44 pm, edited 1 time in total.
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: True sample and hold
Thanks a million Martin,
I will defiantly put these to the test later today.
Also thank you tulamide for taking a look at it..
I will let you all know later today or tomorrow if it all works for my application.
Again thanks all, BobF.....
I will defiantly put these to the test later today.
Also thank you tulamide for taking a look at it..
I will let you all know later today or tomorrow if it all works for my application.
Again thanks all, BobF.....
- BobF
- Posts: 598
- Joined: Mon Apr 20, 2015 9:54 pm
Re: True sample and hold
BobF, I am excited to see what you will come up with!
Martin, thank you for the explanation. I know about bitmasking and why it is used, but when actually reading your thoughts that led you to this code it makes much more sense. It is sooooooooooo damn difficult for me to think in bitmasks rather than in branching, and I don't know why. I mean it is just computer logic and I am around computers for ages. In fact as a kid I built my own circuits to understand the then new invention of an IC. I love logic, yet this dsp code seems to slip aways under my thoughts and always tries to fool me.
Martin, thank you for the explanation. I know about bitmasking and why it is used, but when actually reading your thoughts that led you to this code it makes much more sense. It is sooooooooooo damn difficult for me to think in bitmasks rather than in branching, and I don't know why. I mean it is just computer logic and I am around computers for ages. In fact as a kid I built my own circuits to understand the then new invention of an IC. I love logic, yet this dsp code seems to slip aways under my thoughts and always tries to fool me.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 81 guests