3

For research purposes, I am trying to transmit a tone and record it using sub-Nyquist sampling. Via the PC microphone, for instance, I would expect to see the aliasing effect somewhere in the spectrum plot, but no matter what I try it is absent. I guess that my audio card or my phone's microphone perform low-pass filtering to the recorded signal behind the scene.

Is there any way I could record a sound and hear the aliased tones on purpose?

** update ** audacity (as in @JRE's answer) indeed has that sort of functionality, but I wanted to recreate the effect as close as possible to the "hardware" hence to the sampling using the hardware itself rather then downsample as a post process

Dannynis
  • 31
  • 3
  • 2
    How serious is your research and does its funding extending to buying an ADC and DAC demo board where you can set the sampling rates? Have you looked into this? What makes you think a PC will do sub-Nyquist sampling on a tone you can actually hear? – Andy aka Apr 08 '23 at 15:13
  • 1
    not an electronics design question ... I think that you may be able to do it with Audacity ... https://www.audacityteam.org/ – jsotola Apr 08 '23 at 15:44
  • 1
    your question belongs at https://dsp.stackexchange.com/ ... see https://dsp.stackexchange.com/questions/19295/how-can-i-enforce-aliasing-with-audacity – jsotola Apr 08 '23 at 15:55
  • @jsotola audacity indeed has that sort of functionality, but I wanted to recreate the effect as close as possible to the "hardware" hence to the sampling using the hardware itself rather then downsample as a post process – Dannynis Apr 08 '23 at 16:13
  • You can make your ADC alias by running at a higher sampling rate (which will increase the AA filter cutoff) and then decimating down to the original sampling frequency. This will combine the too high AA filter with a lower sampling rate. – user1850479 Apr 08 '23 at 16:22
  • @Dannynis your comment is important information about your project ... it does not belong in a comment ... please edit the info into your question – jsotola Apr 08 '23 at 22:23

2 Answers2

6

I guess that my audio card or my phone's microphone perform low-pass filtering to the recorded signal behind the scene.

Well, it seems you already knew this before you started! A proper ADC for a baseband signal such as audio will of course have an anti-aliasing filter.

Thus does your soundcard.

It's not going to be a perfect filter though – a sufficiently loud ultrasonic tone will alias into audio frequencies. Been there, cursed about that. (It was caused by extremely loud electrical ringing on a potentiometer. Cannot recommend; mostly noise, but correlated to the angle… thus can contain a tone if potentiometer is turned in harmonic fashion)

But since the sound card probably oversamples a lot internally and hence, the tone must be pretty high and pretty loud, it might be nontrivial to get your sound card to actually hear some tone that you generated. The trick here is that the analog anti-aliasing filter is really minimal (and might be implemented as integrated components on-chip these days, even!), and that most of the anti-aliasing filtering happens digitally already on a sample rate much higher than what your sound card delivers to your PC digitally, whilst simultaneously downsampling to the target rate. It'll be mostly impossible to turn that functionality "off" in your sound card.

Luckily, sound cards aren't the only digitizer boards available. A simple microcontroller board with a microcontroller for which the vendor has a demo software that captures an ADC input at a fixed interval and sends it e.g. through USB bulk transfers is a viable DAQ for this purpose.

So, two options:

  1. Use something that's not a sound card for sampling, as these integrate anti-aliasing
  2. Record something that does not get suppressed by the anti-aliasing filter of your sound card, and then just downsample that without proper anti-alias filtering (e.g., throw away every second sample); you'd get aliasing in the digital domain.
Marcus Müller
  • 88,280
  • 5
  • 131
  • 237
4

You can't really do it with any sound card. They automatically filter out anything that would cause aliasing. They do it in the hardware, so you can't really even play games with the drivers to get an aliased recording. If the out of band signal is really strong, some of the aliasing might get through but I really don't know how hard you'd have to push the sound card and whether or not it would survive.

The best suggestion I can make is to use Audacity or other sound editor to generate an aliased sound.

This thread on the Audacity forum gives an example. In short form, you set the sampling rate, then use a built in function to generate a tone that would be above the Nyquist frequency.

Like this:

  1. Open a new project and set the sampling rate to 44100: enter image description here
  2. Generate a new track with silence in it: enter image description here

enter image description here

I've set it to generate 1.1 seconds of silence.

  1. Select the whole track. Click in the track, then press CTRL A.
  2. Open the Nyquist effect:

enter image description here

enter image description here

  1. Enter the following text in the Nyquist box:

(hzosc 43100)

  1. That should generate a 43.1kHz tone. Since it above the Nyquist frequency, it will be aliased back to 1000 Hz.
  2. Play the tone using the playback and hear a 1000 Hz tone.
  3. Use the "Analyze" functions to see that there's really just a 1000Hz signal in the spectrum.
  4. You can use different sampling rates and various tones to see where the aliases land.

It isn't as cool as recording an alias, but it's the closest I think you can get without buying special hardware.

JRE
  • 67,678
  • 8
  • 104
  • 179