“Hello World”: a simple  DSP simulation Project using GNU Radio

A good place to start learning to use GNU Radio is to build a simulation DSP, not connected to an SDR, and no more involved than outputting an audio tone through the computer sound card.  This project is one that is described in the GNU Radio How to Video: ‘How To’ Video    This project  is simplified by using GNU Radio default values when possible.  Fewer variables to have to consider when first using GNU Radio.  The principles embodied in this project have general application to all GNU Radio flowgraphs.  See ‘Comments‘ for further thoughts on defaults.  The project generates an audio waveform and processes the sound to output via the computer sound card.  Both the audio frequency and audio volume are controlled by on-screen controls.

Audio Oscillator GNU Radio Flowgraph

Inspection of the flow graph image shows two rows of DSP blocks.  The top row of blocks are the Options block and the two WX GUI control blocks to control the audio frequency and audio volume.  The lowest row of block contains the Signal Source, the Multiply Constant audio volume control, and the Audio Sink which is the computer sound card.

Many of the operating parameters of the DSP blocks are visible in this flowgraph image.  For instance, the Signal Source block emits a Cosine signal, the default output frequency is 250 Hz, and the output amplitude is set at 0.1 on the relative scale of 0 to 1.  The dynamic range of the DSP data stream is +1 and -1 peak to peak before distortion occurs.  The Signal Source frequency is controlled by the WX GUI Slider box above the Signal Source block.  The ID for that frequency control block is ‘audio_tone’, and the frequency control range is 250 to 4000 Hz.  The default frequency was set at 250 Hz.  The ‘audio_tone’ ID is inserted as the frequency parameter value inside the Signal Source block.  This parameter is not seen in this image, but can be viewed in a downloaded .grc file by right clicking and ‘opening’ the Signal Source block.

Audio Oscillator Project Signal Source Properties


The Multiply Constant block functions as an audio volume control by multiplying the digital data stream by a factor set by the WX GUI Slider with the ID audio_amplitude.  As with the Audio Tone control, the ‘audio_amplitude’ factor is inserted as the constant value in the Multiply Constant block.  Varying the Audio Tone value from 0 to 6 results in a pleasing non-distorted audio range.

Audio Oscillator Project Multiply Constant Properties

Once the flowgraph is executed, the operating GUI appears on the screen.  Sliding the Tone and Amplitude controls left and right will vary the sound frequency and amplitude from the computer sound card.

Audio Oscillator Project Operating GUI

The procedure for downloading the .grc file is here: Downloading .grc files  The .grc file with the flowgraph annotated for this project :  Audio Oscillator project.grc


A couple items regarding flow graphs in general are worth further explanation.  First of all, the practice of creating a control box, assigning that control box an ID, and inserting that ID string into the desired parameter box of the DSP block to be controlled is a fundamental operation with GNU Radio DSP.  This practice is one worth understanding a remembering as you go forward.  The downloadable .grc flowgraph is annotated so as to help explain this concept.

You will note that the control operation in this executed flowgraph is not smooth but rather halting with latency.  This phenomenon is characteristic of this simple flowgraph that uses the default 32,000 samples per second samp_rate.  The samp_rate value is displayed in the Variable block on the left hand edge of the flowgraph.  Increases in the samp_rate by multiples of 32,000 samples per second materially improve and ultimately eliminate any lack of smoothness in the control functions.  Doing so in this simple flow graph is not possible because the default samp_rate was chosen to be within the range of the sample rates accepted by the computer sound card.  An advanced DSP practice, not illustrated in this project is called multi-rate sampling.  Multi-rate sampling adjusts the samp_rate with-in a flow graph to accommodate to the requirements of the various Sink blocks included in that particular digital data stream.

Link to Terms and Abbreviations: Terms and Abbreviations

Link to Home Page: Home Page