Waveform play

I have had loads of fun playing with waves- for their appearance when drawn or for the sounds I can make. For this Liberty BASIC (or JustBASIC) are ideal, but too slow for real-time processing. I also make heavy use of free software- 'Audacity' in particular.

Sine wave

Sine waves are, in audio terms, single frequency and fixed amplitude, Pretty boring.

White noise and Pink noise

In 'white noise' every possible amplitude is visited, with equal probability, giving a 'hissing' sound. Some of us remember it as the 'noise' on AM radio, or the 'snow' on cathode ray TVs.

'Pink noise' means a more rumbly, less hissy version, with the low frequency cahanges happening much more than the rapid ones.

Adding sines

If you add more than one sin wave together it is like in music- you hear both as a chord- or dischord!

If you add two sine waves of similar amplitude and frequency they 'beat' at the difference-frequency,

...and if you add series of sine waves of calculated amplitude and frequency you can synthesize ANY shape of repeating wave.See my Fourier pages...


There's a lot of fun to be had with more complex shaped waveforms( or ones which vary with time in frequency and amplitude) created in LB/JB. Although too slow to output or process audio input in real time, you can save and play the results as audio wav files.

Amplitude modulation

Here the frequency is fixed but the amplitude varies. It can vary between 0% and 100%, or over another range.

Frequency modulation

Here the amplitude is constant but the frequency goes up and down- waves follow each other close or further apart.


These are simply sine waves whose frequency moves up ( or down) in a smooth way.

Ring modulation

This involves creating a new waveform from a signal, typically from an instrument, voice or microphone by multiplying its value at all times by a second signal, usually a sine wave but others can be used. This creates weird discordant and unusual sounds, where frequencies get inverted and transposed. Many TV and film voices have used this to make 'robotic speech'- first made famous for the Daleks on 'Dr. Who'. If driven by a square wave +1/-1 it 'scrambles' speech making it unintelligible. But if you know the frquency and phase, you can unscramble it.


Mathematically multipling sines gives two waves at cos half sum and at cos half difference.

As a demo, here's a LB ring-modulated version of a sine wave that sweeps steadily up in frequency, You hear ascending and descending sweeping tones.

Code- just one example


    WindowWidth  =780
    WindowHeight =690

    graphicbox  #w.g,    40, 220, 604, 400
    graphicbox  #w.g2,   40,   5, 604, 103
    graphicbox  #w.g3,   40, 110, 604, 103

    button      #w.g,   "Save Screen", savScr, LR, 130, 10

    statictext  #w.st1, "Signal",    660,  40, 110,  30
    statictext  #w.st2, "Amplitude", 660, 150, 110,  30
    statictext  #w.st1, "Output",    660, 400, 110,  30

    open "y-t scrolling window " for window_nf as #w

    t   =1

    #w   "trapclose [quit]"

    #w.g  "down ; fill cyan ; color darkblue ; size 1 ; flush ; up"
    #w.g2 "down ; fill 160 160 80 ; color black ; size 3"
    #w.g3 "down ; fill 160 160 80 ; color red   ; size 3"
    #w.g  "goto     1 ";       200
    #w.g  "down"

    #w "font 10"

    while 1 =1
        sig     =100 *sin( t /5)
        amp     =1 +1.0 *sin( 1.1 *t /50)
        Y       =200     -int( sig *amp)
        if t >599 then
            #w.g  "goto     599 ";       Y
            #w.g  "getbmp scr 1 1 599 400"
            #w.g  "cls ; down ; fill cyan ; drawbmp scr 0 1 ; discard"
            unloadbmp "scr"
            #w.g  "goto "; int( t); " "; Y

            #w.g2 "set  "; int( t); " "; 50 -int( sig /2 /2)
            #w.g2 "set  "; int( t); " "; 50

            #w.g3 "set  "; int( t); " "; 100 -int( 30 *amp)
            #w.g3 "set  "; int( t); " "; 100
        end if

        t   =t +1

        timer 50, [goOn]
        timer 0


    sub savScr h$
        #w.g "flush ; getbmp scr 0 0 600 400"
        bmpsave "scr", str$( time$( "seconds")) +".bmp"
    end sub

    close #w