Support

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

Clean Rate Reducer help

DSP related issues, mathematics, processing and techniques

Clean Rate Reducer help

Postby adamszabo » Sat Oct 25, 2014 1:52 pm

Hey guys!

I am trying to create a sample rate reducer effect, but I am having a bit if trouble so I thought I'd ask here if anybody could help out.

So basically I would like to make a clean sample rate reducer or also known as decimator. Basically it samples and holds the signal and creates hard edges. Now once the signal is aliased or "square-ized" it aliases even more creating lots of noise and it sounds horrible. Do not confuse this with a bitcrusher, there, noise is expected and wanted, here not so much. I have compared several sources to see how they sounds like and SM is the worst :( . Sylenth1 has some reduced noise, and Reaktor 5 is the cleanest. Unfortunately they use a simple quantize module in reaktor and I cannot see inside the module how did did it.

I have made an image showing the different results from a simple sine wave, and decimation added.

Image

I have tried upsampling the rate reducer, but made no difference. I guess I have to do another method to get rid of the aliasing. Does anyone have any info on how to make it cleaner? I have attached the rate reducer I currently have.

Thank you in advance!
Attachments
rate_reducer.osm
(104.25 KiB) Downloaded 1397 times
adamszabo
 
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Clean Rate Reducer help

Postby KG_is_back » Sat Oct 25, 2014 9:23 pm

From what I can tell, changing when sample rate down you need to lowpass the signal first so no aliasing happens. When changing the sample rate back up,you just need to interpolate the values (usually done by lowpass filter and zero stuffed signal).
The signal at any sample rate IS NOT STAIRS. When signal is reconstructed, a curve is being drawn to connect the sample points and the curve can contain only frequencies below Nyquist. In theory When you downsample and upsample back only difference should be that the new signal should be lowpassed.

I'm not really sure of what effect you are after actually.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Clean Rate Reducer help

Postby adamszabo » Mon Oct 27, 2014 10:53 am

Thank you for the answer KG but I think you might have misunderstood my question. I dont want to resample a signal, but instead create an effect which makes it sounds like its downsampled. So If I have a sine wave, I can make it look like this:

Image

Now because of the hard edgesI think you will get aliasing distortion, and that is what I would like to remove, so I get a cleaner signal.
adamszabo
 
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Clean Rate Reducer help

Postby KG_is_back » Mon Oct 27, 2014 12:18 pm

The oversampling should deal with the aliasing then... probably higher than 2x... I'd go with 8. Another thing is how to archive subsample precision with the"sample and hold" thing. You know, when you try to downsample 2.5x currently your schematic would produce 2-3-2-3 sample long segments.

EDIT: I've just tried it with the oversampling and it simply removes the stairs completely. basically recreating the original sine wave.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Clean Rate Reducer help

Postby tulamide » Mon Oct 27, 2014 5:23 pm

It's the first time that I hear the term decimator. But Wikipedia is surprisingly deep explaining what type of filter has to be used. Unfortunately I have no skills at all in filter design, but people like martin and others have proven many times their talents. So maybe you should ask them for a FS Example of the Wikipedia descriptions?

http://en.wikipedia.org/wiki/Decimation_%28signal_processing%29
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Clean Rate Reducer help

Postby adamszabo » Mon Oct 27, 2014 8:21 pm

Thank you for the tip, I have seen that link, but unfortunately that math is a bit too abstract for me. But looking at it, I dont think it has so much to do with my problem :(
adamszabo
 
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Clean Rate Reducer help

Postby KG_is_back » Mon Oct 27, 2014 9:38 pm

adamszabo wrote:Thank you for the tip, I have seen that link, but unfortunately that math is a bit too abstract for me. But looking at it, I dont think it has so much to do with my problem :(


Wikipedia says basically what I've said. To downsample a signal you have to lowpass it with sharp lowpass filter with cutoff at 1/M where M is the downsampling factor ( for example 2 when 44100->22050). And the downsampled signal can then simply by sampled without aliasing. However, this means you convert a sine wave into another sine wave, just with lower samplerate. The thing you are trying to do is downsample and upsample back for special "stairs"-like effect which emerges, when you use a really cheap upsampler. If you'd use perfect downsampler and upsampler you'd simply get the original wave (only lowpassed by the antialiasing filter). The stairs effect emerges, when you upsample by sample&hold method which is a very cheap way to do it (the stairs are in fact aliasing). If you remove the aliasing, there will be no stairs anymore. So the thing you might be looking for is some kind of "smoothing" which will not be perfect anti-aliasing.

Try lowpass filter before and after the decimator you already have. with the cutoff set to 1/M.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Clean Rate Reducer help

Postby adamszabo » Mon Oct 27, 2014 10:58 pm

Ok I have added a filter before and after the decimator. Nothing happened except the last lowpass filtered the whole signal. But I think we are not on the same page. The wikipedia is talking about REAL down and upsampling. However I am not up or downsampling anything. I am just making an effect which makes the wave look like it was downsampled. So the decimator code is simply a ramp that goes from 0-1 and when it reaches 1 it sends out a trigger to hold the sample until the counter reaches 1 again. The speed of this counter can be adjusted. The slower the counter, the longer the samples will be held and the signal will look like a square more and more.

So now that we sample and hold the signal, the overtones that have been created are causing aliasing, and the problem lies in how to remove them. There is no point in putting a filter before the decimator because if you filter a sine wave you will just make it have lower volume since its only 1 frequency.
Attachments
rate_reducer_2.osm
(135.33 KiB) Downloaded 1418 times
adamszabo
 
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Clean Rate Reducer help

Postby martinvicanek » Mon Oct 27, 2014 11:06 pm

From the top of my head because I'm traveling:

As KG says, you usually use lowpass filters before downsampling (decimation) and for upsampling (reconstruction or interpolation). However, this would simply result in a lowpass filter effect overall. This is not what the spectra in Adam's original post show.

To me all three spectra show aliasing from reconstruction. The difference is that in the first two spectra, aliasing exceeds Nyquist and folds back, whereas in Reaktor 5 it does not. So the trick is to bandlimit the reconstruction to frequencies below Nyquist. I think that this will only be necessary if M is not an integer, though.

You don't want aliasing in the decimation stage, so lowpass with cutoff=Nyquist/M before decimation.
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: Clean Rate Reducer help

Postby tulamide » Mon Oct 27, 2014 11:41 pm

martinvicanek wrote:You don't want aliasing in the decimation stage, so lowpass with cutoff=Nyquist/M before decimation.

I think that's basically it. At 44100 Hz Nyquist equals 22050 Hz. With a decimation factor of M = 2, cutoff = 11025. Now the wiki says: "The anti-aliasing filter that can ensure the condition is met has a cutoff frequency less than 1/M times the Nyquist frequency. (Realizable low-pass filters have a "skirt", where the response diminishes from near one to near zero. So in practice the cutoff frequency is placed far enough below the theoretical cutoff that the filter's skirt is contained below the theoretical cutoff.)"
1/M * Nyquist in our case would be 1/2 * Nyquist = 11025. I don't know how much 'skirt' there is on the available filters on these forums (I don't even know what is meant by that :lol: ), but at least one could test by partially lowering the cutoff starting from Nyquist/M until condition is met.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Next

Return to DSP

Who is online

Users browsing this forum: No registered users and 33 guests