Weird spike on waveform
  • Hi,

    I'm building a moogish sawtooth oscillator based on some published modelling. I've got a bunch of equations, fed by a standard audulus sawtooth oscillator (just like when you use a phasor to create different LFOs, but at audio rate).

    For the most part it works, except for when the feed sawtooth goes from 1 to -1 in an instant. Then I get a weird spike on my transformed waveform. I thought that maybe it was where the two waves that I'm splicing together were joining and that maybe I could just find that time point and filter it out (set it to -1) but I've done that and the blip still comes through. Why?

    For my visualisation, I'm looking at the wave with a hz=0.5 just so I can see it. Is it because the oscillator isn't designed for this rate or is something else going on? I know the phasor is better for low rate stuff.

    I'm fairly sure I can hear the blip in the audio. Based on the paper, the modelled saw should have less high end than a textbook saw. This one has less mids but sounds like more high highs, which would be that spike.

    Any help would be great.

    Also FYI on the screenshot, the lower wave is the transformed wave and the one above it is the textbook sawtooth feeding the equations.
    Moog Saw VCO.audulus
    146K
    IMG_0105.PNG
    1536 x 2048 - 337K
  • Nothing wrong on the scope at audio rate. However the analyzer shows huge amounts of aliasing. This type of waveshaping is probably not the way to go.
  • This is almost definitely artifact of the Osc node being anti-aliased. Perhaps the anti-aliasing in the textbook that you're referring to would happen after whatever's going on there with the spike, and having it happen before interferes with it.

    The Osc node is good for audio because it is anti-aliased, and the phasor is better for accuracy because it is not anti-aliased. They both have their pros/cons. Maybe someday in the future we'll build an easy way for people to anti-alias, but as far as I understand it, it's not as easy as just an "anti-alias" node that you just send audio through (I've talked about this with Taylor like a year ago, maybe things are different now).

    Try subbing out the saw oscillator with a scaled phasor

    Phasor/(2*pi)*2-1

    Creates a -1 to 1 saw wave from a phasor.

    This also might have to do with how you're using logic equations, which are not evaluated at audio rate, but at at frame rate (sample rate/~320). There is currently no way to make a portion of a design single-sample unless you have a z-1 in a feedback loop configuration, and even then, the only portion of the patch that becomes single sample is that whatever is in the feedback loop.

    Can you link to the article that you're basing this off of? We might be able to find an easier way that sounds better :)
  • Thanks guys,

    @SansNom, are you talking about the flat section at the bottom and the jumps around it? They're really just there to illustrate my point about the spike, they're not my proposed waveform. Also, this may be a silly questions, but how do I get the scope to show me something useful at audio rate? For the most part I just get 2 flat lines at the top and bottom. Sometimes a bit more when I change notes.

    @biminiroad, the paper is here http://eprints.maynoothuniversity.ie/4185/1/VL_Discrete-time.pdf
    I've used the phase distortion model which is the first one they've discussed. The other one was a bit more complicated. The logic (I assume you mean the > and the Ptest parts) are for equation 3 which has different forms depending on the part of the oscillation. Would there be a better way to do this if logic isn't done at audio rate?

    I put a phasor in instead and that fixed it (hooray!) Is the phasor generally ok at audio rate? One of the other cool things about the oscillator node is that I can feed these equations with other nodes, like sine or triangle, or play with the shape control to create some really cool effects. I guess I can still do that with math, but it was all built in! What are the other cons of the phasor?

    Cheers

    IMG_0107.PNG
    1536 x 2048 - 242K
  • @zilch42 - No I was talking about playing with a keyboard and analyzing the audio waveform and harmonics. On iOS I use MC oscilloscope and MC analyzer via audiobus.

    See the pictures (waveform, looks normal ; and harmonics, looks full of aliasing. The first harmonic is 440 Hz).
    Moogvco_wave.png
    2048 x 1536 - 308K
    Moogvco_harmcs.png
    2048 x 1536 - 746K
  • @biminiroad - speaking of that, I just checked the osc node, and there is an awful lot of aliasing too (see included image)... Didn't notice that before, it's me or something has changed in the last updates? I just plugged an osc sawtooth to the audio out @220 Hz.
    oscnode_alias.png
    2048 x 1536 - 731K
  • Hey @SansNom, I've got a bunch of tests to try to ensure there isn't much aliasing, but I make all sorts of mistakes, so who knows.

    Here's my plot in Audacity. I replicated your sawtooth 220hz test, isolating just the oscillator code.
    image

    This looks nearly perfect to me, so let's try to reconcile with your plots.

    Do you hear the aliasing? If it's pretty bad, usually you can hear it on high notes.

    Can you export to an audio file and use Audacity on your end? I trust its spectrum analysis.
    fft.png
    1478 x 803 - 92K
  • Hey @Taylor, good to see you again :)

    Here are the files you wanted. It's not as good as your analysis, but not as bad as I posted before. I actually messed up with the block size, setting it much too high in MC analyzer. With a setting of 8192 samples it's much better. Sorry for this.

    @2 kHz it's not very pretty however.

    Recorded in AudioShare via audiobus.
    saw_220Hz.jpg
    1920 x 1040 - 396K
    saw_220Hz_MCA.png
    2048 x 1536 - 533K
    saw_2kHz.jpg
    1920 x 1040 - 334K
    saw_2kHz_MCA.png
    2048 x 1536 - 426K
  • Now perhaps it's iOS only, or the limited samplerate? Just recorded Arp Odyssei at around 2 kHz and it looks similar... I'm not sure but it seems there is aliasing (the mirrored harmonics at Nyquist) and something else. All these little peaks around the main harmonics are weird.
    odyssei_saw.png
    2048 x 1536 - 424K
  • @SansNom, is the Arp Odyssey the analog synth? If so, I'm surprised to see any aliasing. It does look like aliasing in the plot.

    I recorded a bit of the 220Hz sawtooth into GarageBand on iOS (via inter-app audio) and exported to an AIFF. For some reason there appears to be a bit of noise added, but I don't see aliasing. I don't understand why the noise is there though.

    image
    fft2.png
    1451 x 886 - 91K
  • Wow @Taylor is commenting in the forums again!? What a time to be alive!
  • @Taylor - No, it's the iOS app (with an "i").
  • I recorded my waveforms in Loopy then sent them to Logic. Do they look ok? (I've sort of only just learned what aliasing is).

    Back to my other questions, what are the downsides of using the phasor at audio rate rather than the oscillator node? Would there be a better way to deal with equation 3 in the reference I posed without logic if logic isn't evaluated at audio rate?

    screenshot_23.png
    1164 x 676 - 197K
    screenshot_24.png
    1182 x 680 - 148K
  • The first cap is perfect saw and the second looks aliased. The Osc node is bandlimited - it does not produce frequencies above 22.5kHz. The phasor does. When the phasor resets, it does so instantaneously, which causes a burst of high frequiences (think when you loop an audio clip and can sometimes hear that click every time the loop comes around. Look up Fourier Series - for an ideal saw to not alias, you'd need near infinite sampling rate.

    There is a hack to force single sampling using the z-1 node in a feedback config, but I'm not sure what you mean by equation 3?
  • @biminiroad, sorry, equation 3 in this paper that I linked to a few days ago up above. You asked for the article :) http://eprints.maynoothuniversity.ie/4185/1/VL_Discrete-time.pdf

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!