Author Topic: Signal Generator Square Wave and Aliasing?  (Read 1629 times)

0 Members and 1 Guest are viewing this topic.

Offline ssashtonTopic starter

  • Regular Contributor
  • *
  • Posts: 236
  • Country: gb
Signal Generator Square Wave and Aliasing?
« on: September 29, 2021, 07:38:42 pm »
I'd like to understand more about how digital signal generators (proper ones like R&S, Keysight, not a PC) produce square waves? Would someone with a good quality bit of kit be willing to post an FFT (logarithmic please) of a 10KHz square wave?
 
I watched a youtube video about aliasing, Nyquist and square waves etc..
https://youtu.be/bg6bOVShU-w

The video showed that if you use the tone generator in Adobe Audition and create a square wave it results in significant aliasing distortion in the waveform. Basically it uses a mathamatical function to create a square wave (at unknown bandwidth?) and then down-samples to the working project sample-rate without anti-aliasing filters.

To me that seems wrong, as I think it should apply anti-aliasing to whatever the generator outputs to give a 'realistic' (analog?) representation of a band-limited square wave.

I'm very curious how a proper dedicated signal gen does this same task? Does it also kick out lots of alias products, or does it band-limit before interpolation?

If there is a good reason for not applying anti-aliasing to the generator output, what is it?

Please help me understand.

I'm sure we all know that a square wave consists of odd harmonics, so a 10KHz square wave should have only 10KHz, 30 KHz, 50KHz, 70KHz etc.. I *assume* if I got a high bandwidth square wave such as from a switching transistor and recorded it in to my audio interface ADC I would not have all these extra distortion products thanks to the input filtering and ADC digital filter? I've got to try it now!


« Last Edit: September 29, 2021, 10:32:51 pm by ssashton »
 

Offline bdunham7

  • Super Contributor
  • ***
  • Posts: 8007
  • Country: us
Re: Signal Generator Square Wave and Aliasing?
« Reply #1 on: September 29, 2021, 07:59:45 pm »
The video showed that if you use the tone generator in Adobe Audition and create a square wave it results in significant aliasing distortion in the waveform. Basically it uses a mathamatical function to create a square wave (at unknown bandwidth?) and then down-samples to the working project sample-rate without anti-aliasing filters.

This is a common issue when people generate 'illegal' audio files--those that violate the input rules--by either disregarding the need to filter digitally generated files or by using improper recording techniques.  This is often used to 'demonstrate' that digital audio is inferior to analog.  A 10kHz square wave generated by a typical AWG or DDS is going to indeed only have the harmonics you expect.  As you approach their sampling limits, the results may vary with the cheapo ones, but all decent ones will have analog and/or oversampling filtering of the output.

Does Adobe Audition allow you to manually apply brickwall anti-aliasing filter?
A 3.5 digit 4.5 digit 5 digit 5.5 digit 6.5 digit 7.5 digit DMM is good enough for most people.
 
The following users thanked this post: ssashton

Offline ssashtonTopic starter

  • Regular Contributor
  • *
  • Posts: 236
  • Country: gb
Re: Signal Generator Square Wave and Aliasing?
« Reply #2 on: September 29, 2021, 08:32:42 pm »
I realised I can easily test what happens with a square wave recorded by my audio interface. I used the digital output pin of an Arduino Uno and switched it at 10KHz. I don't know how clean it switches, but I guess with audio bandwidth sampling it won't really matter?

The results are interesting!

As expected, the aliasing products are significantly lower than those of the digitally generated square wave.

On the other hand I am surprised they are as high as they are! In both cases the highest amplitude alias products are about -25dB (sorry I didn't normalise the files to 0dB).  I thought the brick wall digital input filters in the ADC would be more effective.




Note the frequency axis scale changes in these graphs.
 

Offline ssashtonTopic starter

  • Regular Contributor
  • *
  • Posts: 236
  • Country: gb
Re: Signal Generator Square Wave and Aliasing?
« Reply #3 on: September 29, 2021, 08:34:22 pm »

This is a common issue when people generate 'illegal' audio files--those that violate the input rules--by either disregarding the need to filter digitally generated files or by using improper recording techniques.  This is often used to 'demonstrate' that digital audio is inferior to analog.  A 10kHz square wave generated by a typical AWG or DDS is going to indeed only have the harmonics you expect.  As you approach their sampling limits, the results may vary with the cheapo ones, but all decent ones will have analog and/or oversampling filtering of the output.

Does Adobe Audition allow you to manually apply brickwall anti-aliasing filter?

Thanks for the info.

There is no option to apply filtering to the waveform generator. You can of course filter after generation, but by then the aliasing products are already baked in to the waveform.

If you re-sample a file there are options about filters and for bit depth change there are dithering options. So I think it's a bit of an oversight to miss it from the tone generator.
« Last Edit: September 29, 2021, 08:36:58 pm by ssashton »
 

Offline TurboTom

  • Super Contributor
  • ***
  • Posts: 1430
  • Country: de
Re: Signal Generator Square Wave and Aliasing?
« Reply #4 on: September 29, 2021, 09:43:17 pm »
...and that's what a 10kHz 0dBm fundamental square wave from a rather crappy arbitrary waveform generator (integrated AWG of a DS2000A-S o'scope -- all the better ones are in the basement lab and I don't bother to go and get one  ;)) looks like on an entry level spectrum analyzer (logarithmic frequency scale, 1kHz~1MHz). The LO/1st IF feedthrough on these simple devices makes looking at lower frequencies pointless.

All half-way decent lab signal generators have high-order (usually 7th or 9th) reconstruction filters installed right after the DAC that will virtually eliminate all aliasing products form the output by cutting off everything above approx. 0.8 Nyquist frequency. And the sampling frequency of these devices is in the hundreds of megahertz to gigahertz ballpark, so not at all comparable with the usual audio converters. On the other hand, your screenshots show that the input of the audio ADC is probably un-filtered, resulting in a whole bunch of mirror frequencies below the fundamental that are the result of harmonics above Nyquist of the ADC passing through to the sampler input. Some of the sampling aliases of the generator signal of your first test may also contribute.

I hope this somewhat helps to shine some light on your questions  :D

Cheers,
Thomas
« Last Edit: September 30, 2021, 07:00:36 am by TurboTom »
 
The following users thanked this post: ssashton

Offline ssashtonTopic starter

  • Regular Contributor
  • *
  • Posts: 236
  • Country: gb
Re: Signal Generator Square Wave and Aliasing?
« Reply #5 on: September 29, 2021, 10:16:49 pm »
Thanks for the plot!

The video creator replied to my message and I have asked if I can reproduce it here.

He basically explained that Audition apparently uses wavetable synthesis. He pointed out that the samples themselves are a 'square wave' - i.e. samples go '00001111'. Essentially it is producing square samples, not a square wave.
 

Offline ssashtonTopic starter

  • Regular Contributor
  • *
  • Posts: 236
  • Country: gb
Re: Signal Generator Square Wave and Aliasing?
« Reply #6 on: September 29, 2021, 10:25:10 pm »
your screenshots show that the input of the audio ADC is probably un-filtered

The ADC itself is the AKM AK5385 which has a digital LP filter when operating at 192KHz. It says stopband 106KHz (which is above 1/2 fs!) and 100dB attenuation. I'm sure there is also some soft analog filtering for RFI rejection etc..

I guess the aliasing products we see in my plots are from whatever creeps in between the 96KHz upper limit of the 192KHz sample-rate and the 106KHz stopband.
 

Offline ssashtonTopic starter

  • Regular Contributor
  • *
  • Posts: 236
  • Country: gb
Re: Signal Generator Square Wave and Aliasing?
« Reply #7 on: September 29, 2021, 10:32:35 pm »
Oh no cocked up! The first waveforms I posted from Audition were wrong. I must have had a modulator enabled. I'll edit the first post if I can.

Here are the correct results.

The point is still valid - aliasing products are there.


« Last Edit: September 29, 2021, 10:34:24 pm by ssashton »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf