News:

SMF for DIYStompboxes.com!

Main Menu

Freeze-a-like

Started by potul, January 11, 2011, 09:14:48 AM

Previous topic - Next topic

potul

Hi all,

After reading some DSP documentation, forums, and other infinite resources... I've decided to jump in and start my first DSP experience.
What I have in mind is to create something similar to the EHX Freeze, which seems a good project to start with.

In terms on how to implement it, I have a some questions and some suggestions I would like to have:

-My Idea of the algorithm is basically to read the ADC, store in a circular buffer and then play the circular buffer on and on.
-What buffer size looks like OK? If it's too long, it will contain too much sound "variations", if it is too short it will not contain enough information and the "quantize" error will be higher.
-The circular buffer will have a seam, that can be noticeable, I guess. I was thinking on some kind of "crossfade" so that the change is less evident. Any brilliant idea on a simple way to implement it?

Once I have the basic thing working I plan to expand it a little, by maybe adding some modulation to the "sustained note".

As for the platform, I'll start with what I have in hand, some dsPIC. I know it is not the ideal platform for audio, but will do the trick for my first DSP experience.

Regards,

Mateu

ExpAnonColin

This would not be hard to implement at all, even on a meager platform like arduino (as long as you are OK with rather low bit rates).  The simple idea would be that once a button is pressed, a buffer (eg, an array of ints) is filled with values from the ADC (be it an onboard one or a nicer one for audio).  Then, that buffer is just looped over and over again.  Cross-fading would be one way to prevent really garish discontinuities, but you could also do something simple like interpolate the first and last value of the buffer so that they smoothly ramp between the second to last and first value in the buffer.  It sounds like the Freeze does something smart - perhaps looking for the first  and last near-zero values and making that be the buffer length.  There's a lot of wiggle room to make it sound "smoother".

-Colin

earthtonesaudio

I thought the Freeze has some additional modulation of the looped signal, the slight variations make it more interesting and could make it easier to hide the seam.

Mark Hammer

You would think that part of the algorithm would involve some digital compression so as to make any "seam" less noticeable.

The Tone God

When I was hacking around with a software looper I tried to make a Freeze style effect. Its not just the start/end seem of the loop that needs to be dealt with and most loopers already do this. I believe the volume of the whole loop needs to be made constant so as the loop is being played back it will not create a tremolo effect. That happens sometimes when you "glitch" the Freeze.

Andrew

potul

Thanks everybody for the feedback.

I guess what Mark propose regarding compression, and Andrew comment regarding volume are pursuing the same goal, right? I'll take it into consideration, although I though that being a rather short loop (I think in the less than a second range, or even less), the volume difference would be less noticeable.
I'll experiment with the different "smoothing" approaches once I can make the basic functionality work.

So far, I have problems making the ADC to work, so ... I'm still far away from being able to play with any smoothing/modulation, I was just asking from the theoretical perspective.

Thanks, I'll keep you updated on my progress.

Mateu

wavley

I have a Roland SVC-350 Vocoder, the freeze is a lot like the Hold function of the vocoder albeit the vocoder is in analog form, it might help you, it might not.  http://rvgm.site90.net/Manuals/Roland/SN/Roland%20SVC-350%20Service%20Notes.pdf
New and exciting innovations in current technology!

Bone is in the fingers.

EccoHollow Art & Sound

eccohollow.bandcamp.com

potul

Hi all,

now that my basic ADC-in PWM-out is working I will start coding the freeze..

Any suggestion on size of the circular buffer needed?


ExpAnonColin

Quote from: potul on January 13, 2011, 05:07:11 PM
Hi all,

now that my basic ADC-in PWM-out is working I will start coding the freeze..

Any suggestion on size of the circular buffer needed?



You can calculate it easily based on the sampling rate of your ADC.  If you're sampling at, say, 44.1 kHz, and you want it to be a .1 second buffer (this would allow for two cycles of a 20 Hz wave to be stored), the buffer should be 44100*.1 = 4410 samples.  The larger the buffer, the longer it will take to fill up (more latency if that's an issue), but the shorter the buffer, the worse its low frequency resolution will be.

-Colin

potul

Quote from: ExpAnonColin on January 13, 2011, 05:19:41 PM

You can calculate it easily based on the sampling rate of your ADC.  If you're sampling at, say, 44.1 kHz, and you want it to be a .1 second buffer (this would allow for two cycles of a 20 Hz wave to be stored), the buffer should be 44100*.1 = 4410 samples.  The larger the buffer, the longer it will take to fill up (more latency if that's an issue), but the shorter the buffer, the worse its low frequency resolution will be.

-Colin

Thanks for the guidance. I have clear how to size it based on the sample rate and time length I need, the question for me is, what time length to use in order to get the desired "freeze" effect.

By now I think I'll just go as big as my dspic can, because anyway I don't have a lot of RAM available. The pic I use now has only 2k RAM, and some of it is already allocated for other stuff, so I'll have to go with something in the range of 1k.

I'm using 22k sampling rate, so this will give me only 46 ms. I'm afraid this could be too less. It's only around one cycle for a 20Hz signal...., and it means if the cycle does not fit exactly, the resulting frequency when repeating will be different.

I'll just try and see how it sounds.... Anyway I plan to move to a dspic33 with 16k RAM that will give me more margin, but I wanted to play a little with this one first.

Mateu

ExpAnonColin

Quote from: potul on January 14, 2011, 06:17:37 AM
Quote from: ExpAnonColin on January 13, 2011, 05:19:41 PM

You can calculate it easily based on the sampling rate of your ADC.  If you're sampling at, say, 44.1 kHz, and you want it to be a .1 second buffer (this would allow for two cycles of a 20 Hz wave to be stored), the buffer should be 44100*.1 = 4410 samples.  The larger the buffer, the longer it will take to fill up (more latency if that's an issue), but the shorter the buffer, the worse its low frequency resolution will be.

-Colin

Thanks for the guidance. I have clear how to size it based on the sample rate and time length I need, the question for me is, what time length to use in order to get the desired "freeze" effect.

By now I think I'll just go as big as my dspic can, because anyway I don't have a lot of RAM available. The pic I use now has only 2k RAM, and some of it is already allocated for other stuff, so I'll have to go with something in the range of 1k.

I'm using 22k sampling rate, so this will give me only 46 ms. I'm afraid this could be too less. It's only around one cycle for a 20Hz signal...., and it means if the cycle does not fit exactly, the resulting frequency when repeating will be different.

I'll just try and see how it sounds.... Anyway I plan to move to a dspic33 with 16k RAM that will give me more margin, but I wanted to play a little with this one first.

Mateu


Please keep in mind that 1k of ram on the dsPic is 1000 bytes, and so your samples need to be 8-bit.  If you want to store 10 or 12 or 16 bit samples, you need to use twice as much memory.  46 ms I think is almost certainly not enough to get the desire freeze effect, but it could sound interesting.

-Colin

potul

oops you are right..... 1k memory will store only 0.5k samples... I'll have to switch sooner or later to the dspic33 with 16k ram. I hope I'll be able to reuse most of the code.
Thanks for the warning.


ExpAnonColin

Quote from: potul on January 14, 2011, 03:48:29 PM
oops you are right..... 1k memory will store only 0.5k samples... I'll have to switch sooner or later to the dspic33 with 16k ram. I hope I'll be able to reuse most of the code.
Thanks for the warning.



8 bit quantization is not so bad :)  Just the right amount of "digital grime".  If it's not going to be 16, may as well be 8 :)

-Colin

potul

 :icon_mrgreen: I will probably give 8 bits a try. Anyway it's all about experimenting...
I have to admit I'm having fun with it. My dsp "baptism"  :icon_lol:

On the other hand, I've been trying today different PWM rates, and I'm a little puzzled. I've cranked it up to 100khz, and still hear a high pitch noise. For testing I use a simple RC lowpass filter, but I would expect 100khz to be outside of the audible spectrum. Maybe there is something else?

cloudscapes

one way to make the microsample seamlessly loop with "crossfade" is to ping-pong the playback of the sample.  :)
I do that on one of the modes of my sampler
ping-pong back and forth on a very small sample
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

ExpAnonColin

Quote from: cloudscapes on January 15, 2011, 11:32:46 PM
one way to make the microsample seamlessly loop with "crossfade" is to ping-pong the playback of the sample.  :)
I do that on one of the modes of my sampler
ping-pong back and forth on a very small sample

Smart!  Though I can imagine it can sound harsh at certain times... like if at the edge of the buffer the slope is very steep, you would get a slope discontinuity.  Post some sound clips!  :)

-Colin

cloudscapes

#16
Quote from: ExpAnonColin on January 16, 2011, 10:33:35 PM
Smart!  Though I can imagine it can sound harsh at certain times... like if at the edge of the buffer the slope is very steep, you would get a slope discontinuity.  Post some sound clips!  :)

-Colin

http://www.youtube.com/watch?v=TRflDaVqfuQ

;)

edit: though the following is prolly a better example of 'sample freeze'
http://nearworlds.org/stuff/wtf_looper.mp3
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

potul

Quote from: cloudscapes on January 15, 2011, 11:32:46 PM
one way to make the microsample seamlessly loop with "crossfade" is to ping-pong the playback of the sample.  :)
I do that on one of the modes of my sampler
ping-pong back and forth on a very small sample

Interesting idea... I will play a little with it and see how it sounds!

potul

Hi All,

After playing a little with my dspic trying to simulate a "Freeze effect", I have to say the Tone God was right.... Having a smooth transition is not enough, you really need to normalize the volume of the whole sample in order to avoid the "tremolo effect". I've tried the ping poing technique, and it's great to avoid glitches at the end of the sample, but still does not solve the volume differences problem.
I'm still experimenting on how to do this normalization, I'll keep you updated if I get any remarkable result.

Mat

add4

I have absolutely no experience in DSP and i might say something totally stupid here, but here goes.
I have worked in signal processing and when i saw the freeze come out, i played at imagining how i would do it on a computer.
The idea i had was
- When the button is pressed, sample the signal during a very small time
- Make a fourier or discrete wavelet decomposition of this signal -> you get the values of all the frequencies into the signal at that particular moment (the program transcribe does this: it shows the waveform of the audio signal, you select a part of this signal and it will show a graph of the frequencies present into this selected signal, superimposed on a piano keyboard, so you can see what notes are present in the signal you have selected and transcribe more easily). Discrete fourier or wavelet transforms can be very computationally light i guess all DSP have these algorithms.
- once you have all the frequencies present in the signal you sampled, you make an inverse transform of these frequencies, and you get a sound back, which is (theoretically) a kind of summary of what happened during your sample time.
- you play that sound while the input of the guitar is bypassed.

Does it seems totally stupid those who know DSP much better than me?
I'm curious about the answer, ... and idk .. theres 1% of chances that it works like that and can be helpful, but i think it would solve all volume normalization and weird sound problems.