Spectrum Lab's Test Signal Generator

Spectrum Lab is more than a simple audio analyser. It has a built-in audio signal generator with the following features:

This chapter contains:

  1. Generator function blocks
  2. Generator control window
  3. Arbitrary waveform editor
  4. Generator phase-locking to GPS or timestamps
  5. Controlling the generator via interpreter commands
  6. Background notes

The test signal generator can be activated either from Spectrum Lab's main window or the Component Window: The output of the generator can be added to the input of the processing chain, but also to the output (to test external devices). If you need a generator with I/Q-output, let the signal run through the FFT-based filter (which can turn normal signals into complex signals, and remove the "negative" frequencies in the spectrum if necessary).

See also:  circuit window overview ,   main index ,  sample applications .


Generator function blocks

Three independent audio frequencies may be generated WHILE the audio input of the sound card is analyzed. Each of these "tones" can be adjusted from 0.1 Hz to the half sampling rate in 0.1 Hz steps. By setting a tone's frequency to zero you turn it off (so you can use this generator also for one-tone- and two-tone- tests).

The three sine waves are calculated in real-time using the PC's floating point unit, so you need a fast CPU if you want to generate these tones WHILE analyzing the input. The generator can be started from the "View/Windows" menu.

The signal generator also has an adjustable noise generator (white noise). This is a useful tool for testing filters. You may test the "software"-filters in SpecLab with this generator, but you can also test a "real" filter with it if you connect the signal generator to the sound output and the spectrum analyzer to the sound input.

back to top


Generator Control Window

The signal generator's control window can be opened from Spectrum Lab's main window, or by clicking on the generator block in the test circuit diagram.

Here are just some of the generator controls:

back to top


Arbitrary Waveform Generator / Editor

Each of the signal generators -also the AM+FM modulators- can be switched to "arbitrary waveform" mode. The arbitrary waveform is stored in array with 1024 sample points, from where it can be read out in any desired speed (using interpolation). To define the waveform, you can ...

To fill the arbitrary waveform array with calculated values, enter a numeric formula in the edit field on the right side of the graphic waveform display. The formula will be evaluated by SpecLab's numeric interpreter.


Screenshot of the signal generator's "arbitrary waveform editor",
after filling the waveform array from a numeric expression.

The variable 'x' runs as index from 0 to 1 over the whole array (regardless of the actual length of the array; so 'x' is the array index "normalized" to 0 ... 1). To use 'x' in an argument of the trigonometric functions like sin and cos (sine and cosine), 'x' must be multiplied with 2 * pi ( pi is a constant, approx. 3.14159265...) .
The result of the formula must be in the range +/- 1 . Some examples :

Expression ("formula")

Result

sin(2*pi*x)

fills the waveform array with a pure sine wave

sin(2*pi*x)^3

fills the waveform array with a distorted sine wave

sin(2*pi*x)^99

fills the array with a very distorted sine wave

(x<0.5)

fills the array with a pulse, 50 percent duty cycle

(x<0.1)

fills the array with a pulse, 10 percent duty cycle

(x<0.1)+0.01*((x>0.5)&&(x<0.6)) produces a "strong", followed by a "weak" pulse

(1-x)*sin((5*(1-x))^4)

"Starwars"-like sound (laser) when played at 5 Hz .
Taken from CrazyBirds1.usr, a nonsense-audio-generator

rand()

fills the waveform array with white noise

back to top


Generator phase-locking to GPS or timestamps

By default, the phases of the generated signals (sine waves, also for the modulators) are unpredictable - they just start at 'phase zero' when the generator was turned on, and that's it. Enough for most applications.

Only for a few special cases (mainly testing timestamped audio streams), it was desirable to lock the test signal generator output to GPS (with sync output) or a similar precise source for time and frequency (and thus the ability to measure "absolute" phases, as specified further below). Alternatively, if there is no GPS receiver providing timestamps (for the reference phase), the generator's phase-locking feature can also use UTC timestamps received from timestamped audio streams.

In any case ("GPS phase lock" or "precisely timestamped streams"), this option can be enabled on the generator's "Options" tab:

☑ GPS phase lock (or phases locked to timestamps when available)

The above option is actually the same as 'GPS phase lock' on the Sample Rate Calibrator control panel. It is only duplicated here for convenience, and because it's also useable without SR calibration.



Controlling the generator via interpreter commands

There are a few commands and functions in Spectrum Lab's interpreter which can be used to control the signal generator. They can be used to control the generator from an external program, etc.
To set a new value, use a formal assignment like "generator[0].freq=123.4".
The token "generator" can be abbreviated as "gen" if necessary.

generator[N].ampl
Reads or sets the amplitude of one of the three function generators (N=0..2) on a linear scale.
generator[N].freq
Reads or sets the frequency of one of the three function generators (N=0..2) in Hertz.
generator[N].level
Reads or sets the amplitude of one of the three function generators (N=0..2) on a logarithmic scale, the unit is decibels (dB), 0 dB is the clipping point.
generator[N].trigger_cycles
Activates the N-th generator channel (N=0..2) for a limited number of output periods of the selected waveform.
Example:
  generator[N].trigger_cycles = 1
When configured as square wave output (on the generator control panel), the above example will emit a single pulse. Intended to be triggered, for example, by any of Spectrum Lab's programmable buttons, which may be activated via hotkey (keyboard on the PC) for special tests - see screenshot of the 'Macro Button Editor' shown further below.
If the assigned value ("number of cycles" aka tone frequency periods) is larger than one, the command can also be used to send a short tone burst. The duration in seconds would be the number of cycles (= value assigned to generator[N].trigger_cycles) divided by the configured tone frequency (= generator[N].freq).
generator.on = 1
turns the signal generator on (applies to all channels)
generator.on = 0
turns the entire signal generator off (applies to all channels)


Example: Generator controlled via one of SL's programmable buttons (to send a 'single pulse').
This button is programmed to show the remaining number of 'test pulses' like a countdown.


back to top


Background Notes

The author used this generator to find out how "linear" his "linear transverter" for 136kHz really was by feeding it with a two-tone signal and analyzing the transmitted spectrum at the same time. A simple two-tone test is also good for testing the intermodulation of receivers or single amplifier stages.

It was later used in a 'confidence test' for some of Spectrum Lab's spectrum analysis functions (using the FM modulator to spread the energy from a sine generator, without changing the total power).

Tech notes, something to test:

back to top


Last modified : 2020-10-23

Benötigen Sie eine deutsche Übersetzung ? Vielleicht hilft dieser Übersetzer - auch wenn das Resultat z.T. recht "drollig" ausfällt !
Avez-vous besoin d'une traduction en français ? Peut-être que ce traducteur vous aidera !