site desc

The Index that stays put
Home

Artwork Page

Comp Art Page

Books

Calenders

Food and Brew Page

Links Page

Metal Working Page

Pictures Page

Projects Page

CAFL Control Algorithm

DOS Bootsector

DFP Project

Linux Page

Music Page

Recursive Logistic Eqn

RF Electronics Projects

Software Projects

Temperature Data Logging

Wind Chime

Weather Page


Software Analysis Example
Software Simulation Example and Menu


DFP Software Development and Description


The files that the Digital File Processing (DFP) software I wrote work on, are Wave audio files that were created by recording with a SoundBlaster Card. The SoundBlaster operates using an onboard digital to analog and analog to digital converter as the main onboard workhorses with additional DSP hardware on-board. External connections are available for audio input and output. Internally the SoundBlaster is addressable through software where the data stream in 8 bit or 16 bit (for this model)can be retrieved or stored in files. I tested the input of the SoundBlaster auxiliary input jack with a power supply and found that it can be faked into being almost DC coupled (Freq. response <0.0001Hz) through using a high resistance (>1M) in series. Care must be exercised not to overvoltage or overcurrent the input. I used a voltage divider with 100X division. The device is capable of input a few volts positive and negative and also output in that range. Therefore the device could in principle be used as a voltmeter, scope, spectrum analyzer and arbitrary waveform signal generator.

The Wave files created by the SoundBlaster consist of a header followed by the data corresponding to the signal level. With an 8bit file the 0 volt reading generally falls at 128 or 127 (80h or 7Fh), allowing the positive excursion to reach 255 (FFh)and negative excursion to reach 0. The following is a file dump of a recording of a positive and negative delta function followed by zero input.


-d


1277:0100  52 49 46 46 38 2B 00 00-57 41 56 45 66 6D 74 20   RIFF8+..WAVEfmt 
1277:0110  12 00 00 00 01 00 01 00-22 56 00 00 22 56 00 00   ........"V.."V..
1277:0120  01 00 08 00 00 00 64 61-74 61 11 2B 00 00 80 7F   ......data.+....
1277:0130  7F 80 80 80 00 80 80 80-80 80 80 80 80 80 80 80   ................
1277:0140  FF 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:0150  00 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:0160  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:0170  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
-d<
1277:0180  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:0190  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:01A0  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:01B0  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:01C0  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:01D0  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:01E0  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................
1277:01F0  80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80   ................

-q

The delta functions can be seen as the frst byte of FF after 1277:0140 and 00 after 1277:0150. The header is 52 bytes long at the top and contains information which designations the characteristics of the file.

For example the fact that this file is sampled at 22kHz using 8 bits and is monaural is stored there.

Editors are available to cut and paste these files using a time domain graph of the file. Standard features of these editors also include volume control, file reversal, mixing files, inverting waveforms, echos, fades, mixing two files and file format conversion, all time domain editing functions. Some editors can filter files using an available graphic equalizer. But, in general there is a lack of features for handling the frequency domain manipulation of files.

This is the focus of this software which allows for viewing and manipulation of the files in the frequency domain. To view the files in the frequency domain the files are read in binary form (skipping over the 52 byte header as with all of the software in this package) and a discrete Fourier Transform is calculated . A specified number of samples is read in depending on the number inputted. One half of this number is taken as the Nyquist folding frequency. There is an outer loop in the code that runs from 0 to the folding frequency. In this loop a delta change in angle of 2pi multiplied by the index and divided by the number of samples is calculated. The inner loop summations and the angle variable are cleared in the outer loop.The inner loop runs from 0 to the number of samples minus 1. In the inner loop summations are taken in the imaginary and real axes of the indexed sample value multiplied by the sine and cosine of the angle values. While in the inner loop the angle is incremented by the delta value with every pass. These summations values are held in an array. Later on in the program the absolute value of the summations is taken and plotted against a frequency axis.

The spectral analysis program also allows for taking multiple batches of Short Time Fourier Transform samples from a file and forming the average of these amplitude values. This allows a amplitude -v- frequency plot of a signal which has much variation in the time domain. As for a white noise frequency response test of a system, the more batches averaged yields a frequency response which approaches a true response. Zoom functions are also incorporated in this software module. Data is outputted to a *.DFT file which consists of a frequency index followed by amplitude and phase at that frequency, suitable for spreadsheet import.

In the software package there are two filters a transversal FIR and IIR. These both can take user inputted A and B coefficients. Both programs contain a loop which inputs binary data from the wave file and applies multiplication with the coefficients to the (X-n in for FIR)data or (Y-n in for IIR)and collects the summation. This summation (Y out) is the written back to the file as the program moves down the file, much like an "assembly line". Both filter programs can be applied in succession to create a combination filter to represent any arbitrary transfer function.

Also in the package is a compandor. This is a simple type of compandor which takes input from the binary file and multiplies it with user inputted linear factor (volume control) and raises it to a power. Then the new value is written back into the file, until the end is reached. For example inputting 0.5 (square root) compresses the amplitude, followed with 2 (squared) expands the amplitude back to the original. Effects of artificial non-linear devices can also be created with method.

A viewer is available for the time domain representation of the file. This program reads in the file data and plots the stored amplitude values versus a given number of samples, which is adjustable. The viewer can step through the file and allows a rescan of any section to be made in greater or lesser detail, providing zoom functions. The final frame on the screen when the program is exited is captured to a *.TD file, which contains sample numbers and the corresponding amplitude, suitable for spreadsheet import. (8/1/1999)

Additional features described below have been added since the document above has been written.

An undersampler which allows for both integer and fractional time compression of wave files has been added. It has two modes of operation. In the integer mode it retains one sample per N samples, N being a user input parameter. This was originally used to allow recording of slow time varying systems. An example is a temperature control chamber which was allowed to heat up and cool down over a period of 10 minutes. This yielded 6.6 millions samples. By using a compression factor of a 1000, the file size was reduced to a more convenient size for analysis. The loss of data was not a problem due to the extremely low frequencies involved. The fractional time compression features allows rejection of one sample per every N samples. I have used this feature extensively to change the pitch of music samples on the scale. The octave on the musical scale consists of 8 logarithmically spaced notes (ABCDEFGA). Rejecting 1 sample in 9 raises the pitch of a sample by a note. To raise further the software module is applied recursively.

The product mixer module, mimics a harmonizer. It takes two files and multiplies the values on a pointwise basis. This effectively amplitude modulates one file with the second. This feature simulates the modulator or mixer as commonly known as a piece of hardware. It can produce some pretty strange sound effects on music and vocals also.

The statistical distribution analysis module, operates exactly as the name suggests. It takes a user inputted N samples and takes a tally in M user inputted "bins" across the magnitude range 0-255. The result is given as a plot of frequency of occurrence in the Y axis versus magnitude "bin" on the X axis. It is useful to see what bias appears on a signal and whether the signal is symmetrical. It also gives a clear picture of the excursions of a signal and the telltale signs of clipping and other non-linear amplitude compression.

The amplitude excursion, headspace test, gives a quick numerical indication of how many bytes in a file lie past a user defined distance away from the zero bias point. This is used as a check to determine is the file will be driven into clipping, before other operations are applied to it.

Preconfigured Low-pass and High-pass filters now appear as software modules. These are TVFIR filters built the same as the main TVFIR module, that automatically generate the (sin(X)/X) coefficients for the user. The user needs only to specify a cutoff frequency in terms of a fraction of the Nyquist limit.

Out of the preconfigured LPF and HPF modules is spawned the multiresolution frequency and time analysis module. This uses the same (sin(X)/X) function as the mother wavelet. The resolution operator is specified in terms of a fraction of the Nyquist limit, as was the case for the preconfigured filters. This couples the resolution with the order of the filter. Higher orders occurring at lower frequencies where they are applicable and can be supported. Supported means, the uncertainty principle comes into play here, so it makes sense to adjust the filter orders according to frequency scale. This adjustment comes naturally out of the way the specification of resolution is made internal to the software. The software module operates by recursively splitting an input wave file into fractional frequency sub-bands which are themselves stored as labeled wave files. By labeled, I mean each one is given a unique letter designator followed by the .WAV extension. These files then can either be analyzed individually by observing them in time domain individually. Or they can be all fed through the time domain display to produce a set of output files which then can compiled for 3D plotting. (12/2/1999)

Back to Top
Software Analysis Example



Below is the DFP display of time domain response taken of a sound system on the verge of going into screeching feedback. The time response of the system can be determined from the rise time between switching the mic on until near clipping. The sampling rate used is 22 kHz, given 16K samples, the plot is showing 72 milliseconds per division.

72 mS/Div.



Below is the DFP display of frequency response obtained by batch averaging multiple short time discrete Fourier transforms over the same region as in the above plot. This response can then be used to design a compensator for the feedback. This design then can be simulated in this software by using the TVFIR functions. 20 batches of 220 samples were used. The plot extends to 11 kHz, showing 1 kHz per division. The software generates a text file of the 110 plot points and the amplitude and phase at each point. Each point on this graph is separated by 100 Hz. Looking at the text file shows that the peaks occur at 300 Hz and 1300-1400 Hz.

1kHz/Div.

Back to Top


Software Simulation Example and Menu



What if we wanted to suppress the gain enough to keep the system from going into screeching feedback? For example, take the 1300-1400Hz range. Now pick some quick first order numbers. 22000 Hz (sampling rate) divided by 1350 Hz yields 16.29 samples per cycle. To simulate the compensator in software select the TVFIR filter option. Choosing a 16th order, setting the 16th for 1 full cycle to -1, the rest at 0. Instant negative feedback at the phase shift we want! Then the original is filtered with this TVFIR program module. Below is the resulting DFT frequency response of the simulation, showing that the response at 1300-1400 Hz has been suppressed. The same technique could be applied to the 300 Hz response, but I left it there as a reference. The suppression is not complete with the simple approximation and there is some ripple in the higher frequencies. But, the result can be refined or perhaps it is judged sufficient as is.

1kHz/Div.
Below is the main menu for the DFP software I wrote. It illustrates all of the functions currently available. In the future it will be expanded further to handle specialized sampling techniques for audio and music.

Keep it simple menu.


DFP Software Development and Description
Software Analysis Example

Back to Top
 


email me

Original Build Date:07-18-2005

Last updated 12-23-2005