Hands-on Digital transmission with your soundcard

This article is part of the fundamentals of my real-world tutorial on digital communications using a cheap soundcard as the radio. If this notebook is interesting to you, check out the full tutorial!

02 - Using the simulated audio channel

In the previous notebook, we set up the audio environment, listened to the transmitted signal from the loudspeaker and visualized the recorded signal from the microphone. However, since soon hearing the signal all the time could be annoying we used a cable to shortcut the connection between audio output and audio input.

Another possibility is to replace the actual audio transmission with a simulation of the propagation channel. Moreover, in contrast to the real audio channel, the behaviour of a simulated channel is reproducible, hence it can help debugging your signal processing chain. Therefore, in this notebook, we perform the same experiment as before, but use a simulated channel object.

So, first let's import the standard python packages:

In[1]:
import matplotlib
import matplotlib.pyplot as plt
%matplotlib ipympl

%load_ext autoreload
%autoreload 2

import numpy as np
import sys
sys.path.append('..')
In[2]:
try:
    %load_ext tikzmagic
except ModuleNotFoundError:
    print ("Did not find tikzmagic. You will not be able to compile the tex code!")

Subsequently, import the classes needed for the experiment:

In[3]:
from audioComms import Environment, TX
from audioComms.plotting import PlotSpectrum, PlotWaveform

In addition, let's import the SimulatedChannel and a custom channel effect:

In[4]:
from audioComms.channels import SimulatedChannel, IdentityChannelEffect

The channel effect describes the actual behaviour of the channel. For example, common soundcards have a frequency range of 20Hz-20kHz, so a reasonable channel effect is to apply a bandpass to the transmitted signal. However for simplicity, here we use an ideal channel, which does not change the transmitted signal at all.

Now, let's setup our transmitter again:

In[5]:
# Source code has been redacted in online version
# Omitting 12 lines of source code

Similar to the previous notebook, the data flow for the subsequent experiment looks as follows:

In[6]:
# Source code has been redacted in online version
# Omitting 11 lines of source code
No description has been provided for this image

Eventually, let's setup the experiment and run it:

In[8]:
# Source code has been redacted in online version
# Omitting 18 lines of source code

As seen, the simulated channel also simply forwards the signal, which is then plotted as a spectrum and waveform.

Summary and Outlook

With this notebook, we have finished setting up our programming environment. Let's get hands on real data transmission in the following notebook, where we will transmit a pulse-shaped signal in baseband and show the resulting eye diagram.

This article is part of the fundamentals of my real-world tutorial on digital communications using a cheap soundcard as the radio. If this notebook is interesting to you, check out the full tutorial!

Copyright (C) 2025 - dspillustrations.com


DSPIllustrations.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com, amazon.de, amazon.co.uk, amazon.it.