Is it possible to generate a real square wave?

Discussion in 'Working with Sound' started by SyNtH., Jan 28, 2017.

  1. SyNtH.

    SyNtH. Platinum Record

    Joined:
    Nov 27, 2013
    Messages:
    402
    Likes Received:
    229
    Thanks for the clarification guys, sweet stuff!
     
  2. SyNtH.

    SyNtH. Platinum Record

    Joined:
    Nov 27, 2013
    Messages:
    402
    Likes Received:
    229
    @Pinkman could you create a graph with a really high sample rate, im interested in the results. Has anyone calculated an "optimum" rise and decay time that would still pass most speakers, from a physics point of view, or is it simply a limitation of sample rate?
     
  3. Yea, I knew that too!
     
    • Like Like x 1
    • Love it! Love it! x 1
    • List
  4. Qrchack

    Qrchack Rock Star

    Joined:
    Dec 15, 2015
    Messages:
    798
    Likes Received:
    338
    Location:
    Poland
    Yes. The theoretical audible range is 20Hz - 20kHz, but practice shows most adults can't even hear 16kHz, and pretty much anything below 60Hz is also stuff you feel rather than hear. So capping at 20kHz will not show any audible change, unless you're making music for bats and dolphins.

    Though, after doing some more research (I'm a student, trying to get into plugin development), I've found some cool stuff. You know JP6K by Adam Szabo? This one:

    [​IMG]

    Well, it's his Bachelor of Science Thesis at KTH Computer Science and Communication in Stockholm, Sweden - back in 2010. Here's the full paper:
    https://www.nada.kth.se/utbildning/grukth/exjobb/rapportlistor/2010/rapporter10/szabo_adam_10131.pdf

    Basically he writes about how he measured the Roland JP-8000 and recreated it in software. Here's the interesting bit:
    [​IMG]
    [​IMG]
    [​IMG]

    So, seems like aliasing can be used for good stuff too!
     
    • Interesting Interesting x 4
    • Like Like x 2
    • List
  5. AbsoluteMadLad

    AbsoluteMadLad Ultrasonic

    Joined:
    Feb 21, 2020
    Messages:
    62
    Likes Received:
    35
    Is it not possible to oversample in a synthesizer plugin?
     
  6. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,956
    Likes Received:
    3,830
    Location:
    Europe
    This is the answer.
    It's like using a a 1 sample impulse to measure the frequency response (IR). Both a digital 1 sample impulse and the transitions of a perfect square are possible in the digital domain. But they contain almost infinite frequencies that are impossible when it comes to real sound. Audible or not I mean.

    Cool stuff. Reminded me a new thread here about generating sub harmonics.
     
    Last edited: May 5, 2021
  7. 1357

    1357 Noisemaker

    Joined:
    Jan 1, 2021
    Messages:
    6
    Likes Received:
    4
    from what I read, I believe its impossible to achieve a mathematically perfect square wave because the requirement is not met (infinite bandwidth). So in a physical systems which have finite bandwidth a clever way to achieve a square wave is to use a Fourier series to approximate the square function. Since it's continuous it has global convergence. So the higher the nth term of the series you calculate, the greater accuracy of the approximation. An infinite summation of the series will perfectly converge to a square function. The Fourier function for the square wave consist of sine waves, this will cause ringing noise which is also documented.
     
    Last edited: May 24, 2021
  8. Obineg

    Obineg Platinum Record

    Joined:
    Dec 7, 2020
    Messages:
    640
    Likes Received:
    226
    what you see here is a bandlimited squarewave, and this should be considered the "perfect square" - and not the most square one.

    and oversampling is pretty pointless here, no matter what technique you use. (objects like [rect~] or [squinewave~] use BLEP, not additive)
    you would loose all the good stuff when downsampling again.

    what i always find interesting is how far away from the theoretical ideal many analog synths are: if you look at the waveforms from a 101, 303, system-100, and moog rogue you would not think that those the "same" types of waveform - and you suddenly understand why the synths sound so different. :)
     
  9. Obineg

    Obineg Platinum Record

    Joined:
    Dec 7, 2020
    Messages:
    640
    Likes Received:
    226
    the main issue when you DAC and then ADC is that the clocks of the converters are never in sync, so the upper octave of the spectrum will be lowpassfiltered at random.

    you can recreate that phenomen in a digital delay effect, where you write the samplevalues in a buffer and then read them out interpolated - with a delay of 17.437 or 19.391 samples - the HF content goes boom.
     
  10. Obineg

    Obineg Platinum Record

    Joined:
    Dec 7, 2020
    Messages:
    640
    Likes Received:
    226
    it does not make any sense to oversample an already bandlimited waveform.

    oversampling can be a method to create bandlimited material, but it wont make the spectrum broader.

    if you create a square using 88 khz it will contain partials between 22 and 44 khz. later when you downsample you will have to remove those again, and since filters are not ideal, you will have to remove quite some of the content also below 22 khz.

    so it makes more sense to produce bandlimited waveforms at the "final" samplingrate already, then you can produce them perfectly until nyquist.
     
    Last edited: May 24, 2021
  11. Obineg

    Obineg Platinum Record

    Joined:
    Dec 7, 2020
    Messages:
    640
    Likes Received:
    226
    this is exactly what you can not do. :)
     
Loading...
Loading...