<< Chapter < Page
  Digital signal processing - dsp     Page 10 / 25
Chapter >> Page >

As the frequency of the sine wave continues to increase beyond that point, without a corresponding change in the sampling frequency, it is impossible todetermine from the samples so obtained whether the frequency is increasing or decreasing.

An ambiguity in the spectrum analysis

As a result, the spectrum analysis process was unable to determine if the peak in the frequency spectrum was below or above the folding frequency. Thus,the bottom trace in Figure 3 shows two peaks which are mirror images of one another with the folding frequency being half way between the two peaks.

(As a practical matter, when doing spectrum analysis, there is no point in computing the values above the folding frequency. I did that here just toillustrate that there is a folding frequency, which is equal to one-half the sampling frequency.)

Let's see some code

The class used to produce the data displayed in Figure 3 is named Dsp002 . A complete listing of this class definition is shown in Listing 38 near the end of the module.

I will break this class down into fragments and briefly discuss it to show how you can define significant classes and easily connect them to the generalizedplotting program named Graph01 .

As before, having compiled the class named Dsp002 , you would exercise it by entering the following at a command prompt:

java Graph01 Dsp002

Different from the previous example class

This class differs from the class named Graph01Demo in one very significant way. In that class, all the values returned by the methods named f1 through f5 were computed on the fly as the methods were called.

In this new class named Dsp002 , all the data is generated and stored in array objects when an object of the class named Dsp002 is instantiated. When the methods named f1 through f5 are called later, they simply retrieve the data from the array objects and return that data to the plotting program.

Basic operation of the program

As mentioned earlier, this program applies a narrow-band convolution filter to white noise, and then computes the amplitude spectrum of the filtered noiseusing a Discrete Fourier Transform (DFT) algorithm. The spectrum of the white noise is also computed. All of the processing occurs when an object of the classis instantiated, and the processed results are saved in arrays.

The input noise, the filter, the filtered output, and the two spectra are deposited in five arrays for later retrieval and display. The data in the fivearrays are returned by the methods named f1 , f2 , f3 , f4 , and f5 respectively.

The values that are returned by the methods are scaled for appropriate display in the plotting areas provided by the program named Graph01 .

Beginning of the class named Dsp002

The code in Listing 9 establishes the data lengths for the white noise, the convolution filter, the filtered output, and the spectrum.

Listing 9. Beginning of the class named Dsp002.
class Dsp002 implements GraphIntfc01{ int operatorLen = 33;int dataLen = 256+operatorLen; int outputLen = dataLen - operatorLen;int spectrumPts = outputLen;

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing - dsp. OpenStax CNX. Jan 06, 2016 Download for free at https://legacy.cnx.org/content/col11642/1.38
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing - dsp' conversation and receive update notifications?

Ask