# Learning DSP Concepts with BasicDSP

Completely by accident, I happened to stumble upon a program that gives you an easy way to learn DSP techniques by focusing on the underlying algorithms and not the hardware details. The program is called BasicDSP and is available as a Linux source tarball or Windows executable. BasicDSP was created by PA3FWM and PE1OIT as a tool to allow you to experiment with signal processing algorithms from basic building blocks such as filters and mixers, up to complete receiver systems in code. The program can take its input from a variety of sources, such as the soundcard, a file, or an internally generated signal. A simple scripting language is then used to manipulate the input data using a variety of DSP techniques (including some built-in functions). The resulting audio is them piped back out to the soundcard, as well as optional spectrum and oscilloscope displays.

The source tarball didn't want to compile on my Ubuntu Hardy machine on the first try. It threw some cryptic errors about some of the wxWidget objects in the code. A bit of Googling and some lucky guessing enabled me to figure out that the code wanted to compile with wxWidgets 2.6, not the version 2.8 that is standard on Hardy. I forced the linker to use 2.6 and managed to get the code to compile (although it was still complaining about a few warnings). Once I got over that speed bump, the program seemed to work as advertised, with one exception. As you can see in the attached screenshot, something is seriously wrong with the spectrum display. For some reason, the program is drawing vertical lines across the entire spectrum where there should be nothing. Since I had access to the code, I thought that maybe I would give a shot a locating any glaring problems that might be causing this. I know a bit of C++, but have very little experience in coding for *nix machines, and know virtually nothing about wxWidgets. However, the code to draw the spectrum display seemed fairly obvious and I couldn't find anything wrong with it. You can still see a signal on the display if you look hard enough, but its very difficult to tell with all of the offending vertical lines. My best guess is that something is wrong in the array which holds the FFT data plotted by the spectrum display, but that's only a guess. I just don't have the expertise or the proper tools to properly debug this type of problem.

Ignoring that flaw, this is otherwise a really neat program. The syntax is very simple and allows you to easily try different processing concepts in just a few lines of code. There are two special variables that get used in every script: in and out. The in variable represents the data flowing into BasicDSP from the chosen source, while out is the variable that you send your processed data to in order to output it to the speaker. The simplest script that you can write for BasicDSP is a passthrough function, where no processing of the data is performed:

out = in

In the above example, each sample is directly passed to the output. If you could not hear the output very well, you can amplify the signal by performing multiplication with a constant.

out = in * 100

By multiplying the sample by 100, you are increasing the signal level by 40 dB.

There are four slider controls which are accessible via variable (slider1 - slider4). These allow you to dynamically alter variables in the script. For example, if you wanted to be able to change the signal level with a slider, it's a simple as:

out = in * slider1

There are other special variables and functions included in the scripting language that help to enable common DSP tasks. These can all be put together to create simple circuit blocks like low-pass filters, up to more complex tasks like quadrature receivers. A basic direct conversion receiver can be put together quite simply using these functions. The following code (taken from a reprint of a SPRAT tutorial) implements the DC receiver in code by creating a sawtooth oscillator (in lines 2 & 3), mixing the input signal to baseband (just a simple multiplication at line 4), then sending the signal through two stages of low-pass filtering (lines 5 & 6).

1 2 3 4 5 6 7 samplerate = 48000 sawtooth = mod1(sawtooth+slider1) osc = sin1(sawtooth) mix = osc * in lpfa = lpfa + slider2*(mix-lpfa) lpfb = lpfb + slider2*(lpfa-lpfb) out = lpfb

There's some more information on the program and some good example code on the website of PE1OIT. If you have even a small bit of interest in the inner workings of a SDR receiver, you owe it to yourself to download this software and try it out.