Sample and hold
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
I'm tying to design a sample and hold circuit in SB1. http://en.wikipedia.org/wiki/Sample_and_hold
For the life of me, I can't seem to find a way how to do it. Antoine, is it even possible?
For the life of me, I can't seem to find a way how to do it. Antoine, is it even possible?
-
- KVRist
- 158 posts since 25 Mar, 2005
Well, this was a nice little puzzle.
Solution:
https://www.dropbox.com/s/bboyq4kdudr2p ... ld.sbc.zip
It revolves around the bufferizer object. Mode 1 plays, mode 2 records. With a speed of 0, it will play the first sample. Unfortunately, when recording, it outputs silence, so the greater element is used to fix that. Also, there's a bug in the bufferizer object where it won't playback a one sample recording (due to an off by 1 error), so I used the delay element to turn the ktap single sample 1 output into a two samples output.
This is fairly ugly, but it works...
I don't think you could have made that without consulting the bufferizer source code.
Solution:
https://www.dropbox.com/s/bboyq4kdudr2p ... ld.sbc.zip
It revolves around the bufferizer object. Mode 1 plays, mode 2 records. With a speed of 0, it will play the first sample. Unfortunately, when recording, it outputs silence, so the greater element is used to fix that. Also, there's a bug in the bufferizer object where it won't playback a one sample recording (due to an off by 1 error), so I used the delay element to turn the ktap single sample 1 output into a two samples output.
This is fairly ugly, but it works...
I don't think you could have made that without consulting the bufferizer source code.
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
Hey, thanks for that! I thought that the bufferizer would be used...
So, then, a sample and hold element in SB2?
So, then, a sample and hold element in SB2?
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
It mostly works, but if you replace the "source" by, say, the linear noise element, you'll notice glitches in the result.
At the end of the day, I'm looking for a random generator that will output a new number when "tapped" rather than at a set frequency: that's why I wanted to connect a sample & hold circuit to one of the random generator (Linear Noise, White Noise, Pink Noise, Random, Random ramp).
At the end of the day, I'm looking for a random generator that will output a new number when "tapped" rather than at a set frequency: that's why I wanted to connect a sample & hold circuit to one of the random generator (Linear Noise, White Noise, Pink Noise, Random, Random ramp).
-
- KVRist
- 158 posts since 25 Mar, 2005
That's because of the trick I had to use to workaround the bug in bufferizer (duplicate the ktap).
Try this:
https://www.dropbox.com/s/phg9075iz3j1d ... ap.sbc.zip
Try this:
https://www.dropbox.com/s/phg9075iz3j1d ... ap.sbc.zip
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
Yes, that's perfect. Should have asked for what I wanted in the first place!
Thanks again...
Thanks again...
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
Antoine, I was wondering, any reason to prefer the random ramp element to the random element in the circuit?makira wrote:Try this: https://www.dropbox.com/s/phg9075iz3j1d ... ap.sbc.zip
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
While we're at it, why "999999" for the multiplication?
Would it work better with a higher value? What is the highest value that circuit can take?
TIA!
Would it work better with a higher value? What is the highest value that circuit can take?
TIA!
-
- KVRist
- 158 posts since 25 Mar, 2005
A more proper value would be the current sample rate, which would tell the module to change the value every time the ktap is pressed.Kewl wrote:While we're at it, why "999999" for the multiplication?
Would it work better with a higher value? What is the highest value that circuit can take?
TIA!
If you use samplerate/4, it will take 4 ktap to move from a random sample to the next, ramping in between.
Using 999999 was just a lazy shortcut to ensure a new value is generated everytime the ktap is pressed.
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
OK.
And the choice between Random and Random Ramp? If I want instantaneous change, Random would be better?
I'm just wondering if there's a technical reason like "at that frequency, Random is more glitchy than Random Ramp" or something like that...
And the choice between Random and Random Ramp? If I want instantaneous change, Random would be better?
I'm just wondering if there's a technical reason like "at that frequency, Random is more glitchy than Random Ramp" or something like that...
-
- KVRist
- 158 posts since 25 Mar, 2005
Ha, I didn't even remember the Random element. Yep, that would avoid the ramping issue completely.
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
Thanks.
One thing is for sure, I'll need both Random and Random ramp generators in SB2!
One thing is for sure, I'll need both Random and Random ramp generators in SB2!
-
- KVRist
- Topic Starter
- 225 posts since 11 Apr, 2007 from Montreal, Canada
In my test, at the current sample rate, it takes two taps to change the value: I checked it at 44.1, 48, 88.2 and 96 kHz.makira wrote:A more proper value would be the current sample rate, which would tell the module to change the value every time the ktap is pressed.
Current sample rate + 1 is what worked to change the value for one tap.