Version 1 of Tcl based signal processing fundamentals: Frequency Modulation

Updated 2004-08-10 14:37:30 by TV

by Theo Verelst

Using the Tcl/Tk package Bwise, and some fundamental, tcl-coded, signal processing procedures, such as fourier transformation, I'll examplify the important signal processing concept of frequency modulation by making an Tk applet to play around with this modulation principle, known in radio engineering, wireless communication, modems, and sound synthesis, to mention a few fields.

The interest comes mainly from two signal processing considerations (are the signal processing page leaders on holiday ?! ;) ), first, it is an overlooked principle/theorym which is of great value in many signal processing/analysis applications, also when tcl is used (as appears regulalrly on these pages), and second, I think it is a fun and interesting and relevant use of tcl/tk to examplify an important principle, which for me historically goes back to the advent of the Yamaha DX-7 synthesizer which is based on sine wave frequency modulation sound synthesis. When I was a second year electrical engineering student looking for a section to graduate in, I had just worked enough to buy a DX-7, and I had the schematic diagram of it, because I was very interested in what the chips (at the time competatively big and complicated ones) in that synthesizer worked like, and also how FM synthesis worked, so at the time I programmed a sample reproducer and FM program on the Atari ST. At the time, such programs were preferably compiled, but nowadays we can use Tcl and do things more or less in interaction time, and even make an interactive user interface in Tk on top. IMNSHO a very important, and protection-worthy use of a modern progamming language like tcl/tk.

First, lets make a few one-liners to de signal frequency analysis, first a 256 (tcl-list) sample sinewave (three wavelengths are fitted in the list in this case, so a third harmonic):

  set r {}; for {set i 0} {$i < 256} {incr i} {lappend r [expr sin( 3.0 * $twopi*$i/256)] }

To find a certain harmonic in the signal, we can use the well known fourier analysis, in this case in discrete form (multiplying the signal sample for sample with a certain harmonic component):

  set t 0.0; for {set i 0} {$i < 256} {incr i} {set t  [expr $t+ [lindex $r $i] * sin( 3.0 * $twopi*$i/256)] } ; puts [ expr $t/([llength $r] /2.0)]

The third harmonic returns a 'strength' of 1 (full amplitude), then the 3.0 above is replaced by 1.0 for fundamantal (1st harmonic) or another harmonic (smaller than 128) some number very close to zero (background numerical noise) is returned.

I'd rather make an application which does something like this [L1 ] (Click on the left on Waveform Lab, Theory, View Applet, Making Wavews, Sine f=2) in tcl/tk, but I want to do other things first, and I don't know if something like it already exists.