4 Basic Waves in Core

Discussion in 'Building With Reaktor' started by Aleksandr Smirnov, Mar 15, 2009.

Thread Status:
Not open for further replies.
  1. Aleksandr Smirnov

    Aleksandr Smirnov NI Product Owner

    Messages:
    1,539
    Hello!

    I'm planning to do quite a big tutorial about building 4 basic waves (Sawtooth, Triangle, Pulse [or Square] and Sine) on Core level from scratch without copy paste. I've made my own Core Cell this way using basic Core Cell modules.

    I'd like to know if there is everything okay with them, because I'm thinking that something there could be wrong with programming language, CPU usage etc. I'm not also sure the cycle works okay in above terms, because I've used my own principle of it.

    You can find attached ensemble with Scope and 4 Basic Waves switch, where you can look at each wave and how it sounds.

    I'm also planning to develop it further, ex. - make pulse width, etc.

    I'll appreciate any feedback! :cool:

    - Alex.
     

    Attached Files:

    Last edited: Mar 15, 2009
  2. herw

    herw NI Product Owner

    Messages:
    6,394
    yes you can use them as starting point. The problem are the high frequencies - how do you avoide aliasing? The antialiasing algorithm (AA-macros) in NIs core cell oscillators is tricky and affords knowledge about statistics.
    Nevertheless you can use your oscillators as LFOs.
     
  3. Aleksandr Smirnov

    Aleksandr Smirnov NI Product Owner

    Messages:
    1,539
    I didn't know about this at all, but I looked quickly through some information in the net. Seems like this aliasing causes distortions. But I couldn't find AA-macros in NI's core oscillators. Can you give me module name and I will look it through? Thanks.
     
  4. herw

    herw NI Product Owner

    Messages:
    6,394
    f.i. 4-Wave-Master macro (attachment 1)

    There are two mistakes:

    1st: wrong setting of ramp steps. The amplitude is 1 so the range of the ramp is 2/SR.R (attachment 2)

    2nd: the ramp is reseted to -x when it is greater than 1 (attachment 3). Setting to -x will change frequency for high notes extremly because the ramp step are very high (attachment 4). Try with playing same notes several times. So you have to reset the ramp by wrapping with 2 (ramp phase x>1, set new phase to x-2). Then you get only the problem of antialiasing.
     

    Attached Files:

    Last edited: Mar 15, 2009
  5. Aleksandr Smirnov

    Aleksandr Smirnov NI Product Owner

    Messages:
    1,539
    Thanks again for your help! I'll try to fix it and will post my final core cell here. I need to find out more about antialiasing algorithm and wrap module as well.
     
  6. Aleksandr Smirnov

    Aleksandr Smirnov NI Product Owner

    Messages:
    1,539
    Done with 2 wrap (I guess).. ;)
     

    Attached Files:

  7. herw

    herw NI Product Owner

    Messages:
    6,394
    you will nothing find about an antialiasing algorithm in internet.
    Best is to have a looonnngggg look into the AA-macro: the important thing happens when the ramp reaches the 1. There is a phase correction. I think you will find the idea mentioned in Curtis Roads ("the computer music tutorial" pp 32 and 33) as time correction filter. As usual Curtis Roads only mentions this filter but there are no concret informations how it works or is implemented :angry: .
    The "trick" is (as i understand it - maybe wrong) to decrement the distance between the optimal value 1 and the phase 1-pd or 1+pd where pd is the difference between 1 and the nearest phase. The distance is squared to decrement the difference (the distance is very small so the squared will be smaller). After only a few ramp loops you will very near to 1.
    I think statistically the resulting phase length will be the midpoint (the optimal theoretical frequency). It works like a low pass filter.
    See here: method of least squares

    quote: Gauss was able to state that the least-squares approach to regression analysis is optimal in the sense that in a linear model where the errors have a mean of zero, are uncorrelated, and have equal variances, the best linear unbiased estimators of the coefficients is the least-squares estimators. This result is known as the Gauss–Markov theorem. (from wikipedia)

    ciao herw
     
    Last edited: Mar 15, 2009
  8. Horuschild

    Horuschild NI Product Owner

    Messages:
    1,635
    Isn’t that called a recursive function, we are looking at the ramp part of this right? Sorry that I am a bit confused. I have been trying to figure out how I can warp a sine wave to a saw and pulse wave, I know I can have it so that I use a selection module set to sine I was looking to do some a bit different.

    _____________
    Here’s some more questions although OT: how do I can the phase so that it’s odd harmonics rather then even, am I misunderstand the phase shift function on modular osc’s… ref see Buchla multiwave generator. I see osc on modular synths (ref above) with a timbre control what is this? A low-pass filter…1p or 6dB? Figured this is as good a place as any to ask rather then start a whole new thread on osc’s.
     
  9. herw

    herw NI Product Owner

    Messages:
    6,394
    that's another "problem". We just discuss about anti aliasing.
     
  10. Aleksandr Smirnov

    Aleksandr Smirnov NI Product Owner

    Messages:
    1,539
    Do you mean how to convert sine wave to saw and pulse?
    ---
    Okay, after reading several articles, in simple words anti-aliasing algorithm can be explained as following: cut all frequencies of each sample that are higher than Nyquist frequency (in our case Sample Rate / 2 = 22050). Am I right?
    ---
    The aliasing problem

    For example, audio CDs have a sampling frequency of 44100 Hz. The Nyquist frequency is therefore 22050 Hz, which is an upper bound on the highest frequency the data can unambiguously represent. If the chosen anti-aliasing filter (a low-pass filter in this case) has a transition band of 2000 Hz, then the cut-off frequency should be no higher than 20050 Hz to yield a signal with negligible power at frequencies of 22050 Hz and greater.

    To avoid aliasing, the Nyquist frequency must be strictly greater than the maximum frequency component within the signal. If the signal contains a frequency component at precisely the Nyquist frequency then the corresponding component of the sample values cannot have sufficient information to reconstruct the Nyquist component in the continuous-time signal because of phase ambiguity. In such a case, there would be an infinite number of possible and different sinusoids (of varying amplitude and phase) of the Nyquist frequency component that are represented by the discrete samples.

    (c) Wiki
    ---
    I just looked inside AA module in NI's core, and it seems that they subtract those higher distorted frequencies from Phase signal. There is some |i| value that probably is the value of those frequencies (it is original frequency - 2E-12).
     
    Last edited: Mar 15, 2009
  11. Horuschild

    Horuschild NI Product Owner

    Messages:
    1,635
    "2E-012" is that what that is for? I feel so stupid, I have been wondering what in the h** that is doing for a long time now.
     
  12. herw

    herw NI Product Owner

    Messages:
    6,394
    no - |i| means increment and is the height of the ramps steps. The height of the steps depends on the frequency: |i|=f·2/SR.R.
    |i| is clipped at bottom by 2E-12 to avoid a never ending ramp.

    [OT]just heard AC/DC live at Westfalenhalle Dortmund and my ears are ringing - i need antialiasing for my ears ;) [/OT]
     
  13. Aleksandr Smirnov

    Aleksandr Smirnov NI Product Owner

    Messages:
    1,539
    :D ..and it means they were good? :lol:

    I'm not sure about this |i|, I'm stuck.. This evening I'm going to draw the signal itself and what happens inside this AA module, probably I will understand what's going on then..
     
  14. herw

    herw NI Product Owner

    Messages:
    6,394
    [AC/DC]they are "old" men meanwhile and are allways playing same songs, same style, same gags, etc. in other words they do what we want ;) AC/DC in Dortmund (BTW. click on "Fotostrecke" to see pictures[/AC/DC]
    yes that's best - i did it too. You only have to look at the end of the ramp because only then the AA-algorithm works. Start f.i. with an easy example (SR.R=20 (!), f=5 (later f=7) calculate |i| and draw the ramp on paper!

    ciao herw
     
  15. Aleksandr Smirnov

    Aleksandr Smirnov NI Product Owner

    Messages:
    1,539
    :)
     

    Attached Files:

  16. Aleksandr Smirnov

    Aleksandr Smirnov NI Product Owner

    Messages:
    1,539
    Also for all waves I will have to make each antialiasing algorithm.. I did 2 wrap module wrong as well (there should be compare module for -1 as well right?)..
     
  17. herw

    herw NI Product Owner

    Messages:
    6,394
    not for sin-osc.

    Try to understand the algorithm for saw-osc first. The square-osc bases on two saw-osc with synchron anti aliasing so you don't need an AA-algorithm again. You will understand the AA-algorithm for tri-osc after a while.

    BTW i like pencil and paper solutions! Go deaper and draw the last steps of the ramp and the squared correction! What happens when the phase is in the intervall 1-|i| ... 1+|i| and the next SR-clock? What will happen without antialiasing when |i| is very high (f.i. 0.3 ... 0.5 or 0.9 (steps for high frequencies near Nyquist-frequency))?
     
  18. Vadim @ NI

    Vadim @ NI NI Team NI Team

    Messages:
    247
  19. Eklectro

    Eklectro Forum Member

    Messages:
    36
    I didn't expected it was so technic.
    Thx for these great papers Vadim.
     
  20. herw

    herw NI Product Owner

    Messages:
    6,394
Thread Status:
Not open for further replies.