One of the more difficult concepts for my ECE207 students to understand is that of using the oscilloscope in XY mode to view Lissajous figures. When thinking of a way to demonstrate this idea, I thought of hooking the audio output from a laptop to the scope’s channels to play audio. Better yet, use the laptop audio out as a fancy function generator.
Not finding any quick (or free) solutions that would do what I wanted, I came up with this python script. It generates and mixes up to three sine waves on both left and right channels, with each sine independently adjustable in frequency, amplitude, and phase. Then I went overboard and added a real-time graphical depiction of the XY plot generated by the current signals.
It has features to save the current settings, playback those settings in a “slideshow”, and record the audio to a wav file.
The python script requires the Pyo module for audio processing, and the matplotlib module for the plotting. Thanks to this blog for a good example of real-time integration of matplotlib into wx frames. There’s probably more efficient ways to do this, but I’ve used matplotlib extensively in plotting research data, and it’s always easier to use what you already know. Because it’s python, it should run fine in Windows, Unix, or Mac. It was tested under Mac OS 10.7.3 using Python 2.7, with pyo version 0.6.
Here’s a video of it in action, complete with unnecessary Beethoven sound track…
And the WAV file created by the demo scripts. CAUTION: don’t play this too loudly (or at all) on your speakers. It can be rather headache-inducing. Note I manually added the fade-ins and outs using Audacity. Maybe I’ll include that feature automatically in version 2.