Signal Generator

 

From: Dan Kennedy
Date: 10/22/00
Time: 6:30:36 PM

Comments

I have made a routine that generates a test signal of specific parameters. It adds the signal to an existing WAV file.

The start frequency, frequency drift, peak amplitude and Gaussian half-power interval can be specified.

Gaussian Curve

The signal varies in amplitude on a normal curve centered in the WAV interval. 

The equation to the left is a derivation of the normal distribution function. My routine uses this to set the amplitude curve. The free variable d controls the width of the curve.

 

 

 

 

 

 

Frequency Drift

It took me a while to figure out how to vary the frequency linearly. It turns out to be the same equation as accelerated motion. 

s' = so + v t + ½ a t2

cycles = f t + ½ d t2

Where f is start frequency and d is the Doppler drift rate and t is the sample number divided by the sample rate.

Cycles can be converted to phase by multiplying by 2 p

phase = 2 p cycles

This same process can be used in reverse to dechirp a file without introducing the non-linear curves that my TDdechirp.exe file produces by successive approximation errors.

Peak Value

The sin value ranges ± 1 and the normal curve factor ranges 0 to 1. Another value is needed to set the peak signal amplitude. The data can range ± 128. The test below uses a peak amplitude of 3, or about 2.3%

 

The amplitude of the test signal is then sin(phase) multiplied by the gaussian equation above multiplied by the peak value desired.

My routine takes each sample from a normal WAV file, calculates the signal value as above and sums it in. This then preserves the original WAV file and provides a much better test signal than my previous attempts.

This is an example injection where the signal peaks at a binary value of ± 3 or about 2.3%

Start freq = 1300 at the beginning of the file.

This file is here (7 Mb).


Here's the BASIC code that was used to sum in the signal.

Get #wavFile, , nChunkSize

' Set the Doppler drift rate.
d = 0.1 ' drift in hertz per second

freq = 1300
' Initial frequency
dur = 3

' Now read the data bytes, convert from PCM to ASCII values.
For i = 1 To nChunkSize:
' Just over 16 minutes. 
    

      ' Get the original value from the WAV file.
    Get #wavFile, , value
    
   
' Calculate the time index.
    t = i / 8000
    
   
' Calculate the phase angle at this time index.
    phase = 2 * 3.14159 * (freq * t + 0.5 * d * t ^ 2)
    
   
' Figure the normal curve value at this time index.
    a = i / nChunkSize * dur - dur / 2
    a = -((a ^ 2) / 0.4)
    a = 2.718 ^ a


   
' Sum in the signal scaled by phase, peak and normal factors.
    value = value + Sin(phase) * 3.0 * a

   
' Write an output value.
    Print #rawFile, (value - 128) / 128

Next i

My next step will be to create a command line program in C that can inject signals into a WAV file. Another step would be to re-write the TDdechirp code to use these equations. That would make the dechirp more linear and presumably increase SETIEasy sensitivity.

- Dan