obscure antialiased saw code [Ancient thread bumped; see page 3]

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

self quotation :oops:
This way, I guess that the differentiators can be interpreted as a series of very-small-box filters.
This series converges to a gaussian filter.
http://citeseer.ist.psu.edu/cache/paper ... ussian.pdf:
"a Gaussian filter can be implemented by iteratively convolving a signal with an arbitrary, but simple, positive kernel".
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

lol. :shock: your DSP teacher sure was an evil guy.

Post

Mr Smith wrote:lol. :shock: your DSP teacher sure was an evil guy.
Only for this exam. His courses were quite cool compared to other DSP teachers. It was nice to learn some DSP using CSound and Synoptic's "Virtual Waves" (one of the first virtual synth a long time before VSTis...). This teacher also teached analog and digital electronics (our final year project was a rudimentary but functional analog synth, I think that its schematics are available somewhere on the web). Then he leaved the university and worked with Canam computers, they went bankrupt, then I lost his track.
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

I would not be on line for the incoming days. That's why I post it today instead of the April 1st. I know that it is childish but I can't stop doing stupid things :oops:. It is based on a small code by rochebois, but this time I obfuscated it myself :D . Have fun. :clown:

Code: Select all

//sqrfish.cpp
                       #include <math.h>
                        #include <stdio.h>
                        //obfuscation P.Sernine
 int main()      {float ccc,cccc=0,CC=0,cc=0,CCCC,
     CCC,C,c;    FILE *CCCCCCC=fopen("sqrfish.pcm",
      "wb"  );  int ccccc= 0; float CCCCC=6.89e-6f;
      for(int CCCCCC=0;CCCCCC<1764000;CCCCCC++   ){
      if(!(CCCCCC%7350)){if(++ccccc>=30){ ccccc =0;
      CCCCC*=2;}CCC=1;}ccc=CCCCC*expf(0.057762265f*
      "aiakahiafahadfaiakahiahafahadf"[ccccc]);CCCC
      =0.75f-1.5f*ccc;cccc+=ccc;CCC*=0.9999f;cccc-=
      2*(cccc>1);C=cccc+CCCC*CC;  c=cccc+CCCC*cc; C
      -=2*(C>1);c-=2*(c>1);C+=2*(C<-1);      c+=1+2
      *(c<-1);c-=2*(c>1);C=C*C*(2 *C*C-4);
      c=c*c*(2*c*c-4); short cccccc=short(15000.0f*
      CCC*(C-c  )*CCC);CC=0.5f*(1+C+CC);cc=0.5f*(1+
     c+cc);      fwrite(&cccccc,2,1,CCCCCCC);}
 //algo by              Thierry  Rochebois
                        fclose(CCCCCCC);
                       return 0000000;}
it generates a 16bit 44.1kHz MONO raw pcm file.
nota: it is another algo, just guess how it works :nutter: .
Last edited by Paul Sernine on Wed Apr 05, 2006 9:10 am, edited 1 time in total.
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

Fishy fishy.. :)
Image

Post

Flashback on the first algo
Fire Sledge - Ohm Force wrote:I also found an empirical compensation for the volume loss in high freq, but valid up to nyquist/2 : gain /= 1 - step * 1.15;
As it can be interpreted as a series of box filters, the resulting frequency attenuation can be interpreted as a sinc()^4 (nota: with its first zero at sr, not sr/2). That would explain this attenuation.
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

Always about the first algo (not the 1st april's fish, btw who knows how it works...).
I drawn the sinc4 filter with Laurent's plitplot :
Image
This unwanted filtering side-effect is a drawback of Rochebois algo.
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

After playing with fishes :) I came back to rochebois' polynomial algorithm. I am thinking of using it for wavetables. After a while it came to me that the "first order algo" (integral of waveform in the table -> lin interpol -> differenciator) was simply the equivalent of SAT (Summed Area Table) that are used in image synthesis as an alternative to MipMapping.
See http://www.liacs.nl/~mlew/cg2006.class11.pdf for a bried tut on the image texturing topic.
Anyway I will continue my experiments and see if it can replace mipmapping...
Last edited by Paul Sernine on Mon Jun 19, 2006 11:30 am, edited 1 time in total.
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

It will give you aliasing if you do it the "summed area" way (integrate the waveform and play the average of it since the last sample instead of playing it's current value), but, you will decrease the aliasing with 6dB / oct (box filtering) compared to the naive implementation, iirc.

Post

stefancrs wrote:It will give you aliasing if you do it the "summed area" way (integrate the waveform and play the average of it since the last sample instead of playing it's current value), but, you will decrease the aliasing with 6dB / oct (box filtering) compared to the naive implementation, iirc.
Yes, I think so. Maybe, I can double (or quadruple as in rochebois' sawtooth algorithm) integrate but I am afraid of amplifying digital "noise"... :scared: and it would require double precision and induce instabilities with fast frequency modulations (as stated before for rochebois's algo).

Anyway, I will give it a try with simple and double integrations (-12dB is not that bad after all).

Sure, this cannot be as good as MipMapping, but anyway it can be useful: it can be combined to MipMapping and help to limit the number of MipMap levels (which is always good for your cache memory).

Maybe it can also be interesting for filter effects: it is easy to do variable box filtering with such a table... just need to interpolate two phase offsetted values, differenciate them, and normalize the result. Sounds fun to me :clown: (even if I cannot guess how to do this for the double integration version :oops: ). I will have a busy easter weekend. :phones:
Last edited by Paul Sernine on Mon Jun 19, 2006 11:33 am, edited 1 time in total.
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

I finally got enough time to experiment rochebois' first algorithm with wavetables.
I used a second order version :
- FFT-precalculated-wavetables with harmonics decaying with -6dB(saw) -12dB/oct (2nd order pre-integration).

- realtime Hermite interpolation of the wavetable + second order differentiation + amplitude compensation.

It works fine, with low aliasing even without mip mapping.
Hermite interpolation is necessary, linear interpolation causes errors that are strongly amplified by the differenciators.

Regards,
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

I have a few minutes to add a link related to this old topic:

http://www.dafx.ca/proceedings/papers/p_169.pdf

Kind regards,

Paul
Science is the belief in the ignorance of the experts.
Richard P. F
EYNMAN

Post

I was reading that just yesterday :)

DSP
Image

Post

5 years later, what is the most common use method to generate a band-limited sawtooth ? I am searching for a method that is suitable for SIMD implementation.

I have used minBLEP method which was OK (also for hard-synchronization), but this requires reading thru a table which is difficult for me to use with SIMD. Maybe I am missing something ...

Post

0xFF wrote:5 years later, what is the most common use method to generate a band-limited sawtooth ? I am searching for a method that is suitable for SIMD implementation.

I have used minBLEP method which was OK (also for hard-synchronization), but this requires reading thru a table which is difficult for me to use with SIMD. Maybe I am missing something ...
Just use linear-phase BLEPs (unlike what the original paper claims, minimum-phase just adds problems without solving any). To reduce cache line fetches reorder your BLEP table such that every single "branch" is a continuous array of samples (instead of striped into every Nth sample). That said, I'm not convinced there's anything to be gained from SIMD here.

Oh, and did you REALLY have to resurrect this old thread?

Post Reply

Return to “DSP and Plugin Development”