Versatile FFT Supports
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For highly-precise 1/3 octave analysis of audio signalsIntroductionWhen Agilent chose to retire the classic HP 3582A audio spectrum analyzer, high-quality audio spectrum analysis suddenly became a lot harder. This article discusses a way to configure a general-purpose xDAP measurement system for this purpose — discovering higher levels of performance, lower cost, and new opportunities for measurement system automation. Overview of Octave AnalysisMathematically, a pair of sine waves at 80 and 80+10 cycles per second, or at 8000 and 8000+10 cycles per second, are equally distinguishable. As audio signals, however, the first pair would be perceived as significantly different tones to a listener, while the last pair would be virtually indistinguishable. Pitch is perceived as changing with the ratio of frequencies, not by linear increase in cycles per second. In an audio signal, tones one octave apart differ by a factor of 2 in frequency. As you go from lower to higher frequencies, each successive octave band doubles in width. To more naturally group frequencies of audio signals, so that the distributed signal power scales better for analysis, measured signal power can be combined within each octave. This is known as octave analysis. For purposes of analyzing audibility rather than equipment performance, A-weight filtering [2] is often combined with the octave analysis, so that instead of showing the actual signal power, each octave shows approximately the perceived signal loudness in each octave. The audible range is spanned by just a few octaves, so partitioning the spectrum octave-by-octave produces a relatively coarse distribution. Resolution is improved by breaking the octave bands into sub-octave bands, preserving the logarithmic band spacing. For the conventional case that octaves are separated into 3 parts, each successive 1/3 octave band increases in width by a factor of Methods of Octave AnalysisThe traditional way for instruments to perform an octave analysis was to pass the signal through a bank of analog bandpass filters, each filter responding to a narrow portion of the spectrum. The total signal power in each band is then proportional to the square of the signal magnitude in each band. Designing these analog filters well — so that they precisely align to the desired band centers, roll off at precisely the right places, include all spectrum energy, avoid excessive overlap, and scale gains to correctly reflect the signal power in each band — turns out to be a remarkably difficult design problem. There is little wonder that high-quality spectrum analyzer instruments have always been relatively expensive. Digital processing technology is a practical alternative today. Digital filtering can approximate the behaviors of the traditional analog filters. This approach also turns out to have its own share of difficulties, however. Analog filter banks have a natural logarithmic character, but digital filters do not. The easy methods for mapping the analog designs to digital designs do not produce good results at the band edges, and considerable effort is necessary to individually tune each filter characteristic. Another difficulty is the time/resolution tradeoff. The sampling rates necessary to capture high frequency information produces excessive data sets at low frequencies, so the design turns into a multi-rate as well as a multi-band problem. The approach discussed in this note is based on FFT analysis. This shares the resolution and time scale difficulties of other digital approaches. However, it is appealing because the difficult filter design work is eliminated. An FFT acts like a huge bank of very precisely tuned digital filters. The challenge is to properly identify the desired 1/3 octave bands. Preprocessing? or Postprocessing?Performing the octave analysis on a DAP sometimes makes good sense; sometimes it does not. It depends on the application. If the venerable HP analyzer instruments had produced only a stream of raw measurement numbers, not an immediate presentation of the spectrum results, it would have been considered a disastrous failure. Yet, that kind of thing is tolerated as the norm in the present day of "virtual instruments". You can do some really advanced analysis using the appropriate GUI tools in your PC host environment. There is a price, however, in terms of computing resources, complexity, and... price. Sometimes you just want the spectrum numbers without all of that overhead. Then it can make sense to embed the processing with your data acquisition. The FFT analysis provides detailed spectrum information. What then remains is the bookkeeping details for distinguishing the frequency bands. The next section provides more information about how this is done. Octave Analysis via FFT The new and more general Some of the features of this new FFT processing:
The processing of the The second challenge is to analyze the frequencies within the nonlinear spacing of the 1/3 octave bands. The A preview: the following two-line configuration provides a rigorous octave analysis covering 34 bands from ANSI band 10 (10 Hz nominal) to ANSI band 43 (20 kHz nominal). // Sampling runs at 48000 samples per second MIXRFFT(65536,FORWARD,VONHANN, samples,POWER, spectrum) THIRDOCT(32768,34, spectrum, octaves) One 65536-term block is analyzed every 1.36 seconds. As you can see, the application is quite trivial to set up, but the sampling rate and the FFT block size are not arbitrary. In fact, they must satisfy some very specific requirements. How It Works: Internal MathA special observation simplifies the "bookkeeping" problem of octave analysis. There is a relationship between frequencies in an FFT spectrum and frequencies in an octave. Consider the set of 12 linearly-spaced frequencies for the octave ranging from 10 Hz to 20 Hz. 10.000, 10.833, 11.666, 12.500, 13.333, 14.166, 15.000, 15.833, 16.666, 17.500, 18.333, 19.166, 20.000, ... Compare these to the logarithmic spacing of band center frequencies necessary for 1/3 octave analysis. 10.000, - - - - - - - - 12.599, - - - - - - - - - - - - 15.874, - - - - - - - - - - - - - - - - 20.000, ... The correspondence between the 1/3 octave band locations and the 12 uniformly-spaced frequency locations is remarkable. This can be considered a convenient mathematical accident. This grouping of 3 + 4 + 5 frequency samples happens to work almost perfectly to span the first octave. Align the first octave of interest to this group of frequencies, and you have a valid octave analysis for this band. Doubling the frequencies shifts to the next octave, and this octave is covered by 24 frequency samples with grouping of 6 + 8 + 10. And this pattern continues. If the first octave is correctly aligned, the rest will follow. If you have enough terms and the right sampling rate, this pattern can cover the full spectrum you want to analyze. A tabulation given in the appendix lists all of the standard frequency bands your application might want to cover. The band alignment is not perfect, so there are some predictable biases in the signal power measurements for each band. If you care about this, you can apply a compensation factor to "level the gain" for signal power indicated in each band.
Configuring FFT Length and Sample RateThis section explains how to correctly specify the FFT length and the corresponding sampling rate to align to 1/3 octave standard ANSI bands. However, first check the table of pre-determined configurations below. You are likely to find the combination you need, and if so you can dispense with the details in the rest of this section.
Find the desired band coverage in the configuration table. Enter the block size number as your FFT block length, and configure the General designIf you do not see a configuration you can use in the table above, you can apply the following steps to determine a suitable sampling rate and block size.
There is some flexibility in choosing the sampling rate and FFT block size. For example, you might choose a conventional number and accept a slight compromise in the block size, or you can pick the most efficient block size and operate at whatever sampling rate the analysis suggests. Close approximations will yield an analysis with slightly shifted frequency bands. So, for example, if your calculations say the block size should be 16249 values, using a block size 16250 or 16384 should produce satisfactory results with frequency alignment off by a fraction of a percent. Here is an example of the calculations, based on the first configuration in the typical configuration table above. The low frequency band has a band center frequency 10.0, so the resolution figure is computed as follows. resolution = 1.356491 * 10.0/10.0 = 1.356491 For the highest band ANSI 43, the highest frequency is 22627, so by the Nyquist criterion the sampling frequency must be greater than 45254. The commonly used audio sampling rate of 48000 is selected. Given this choice, the block size should be block size = 48000 * 1.36491 = 65516 The block size 65536, which is an exact power of 2, is an excellent approximation and a natural choice. Configuring the 1/3 Octave BookkeepingAfter performing the FFT power spectrum analysis, all that remains is to accumulate the power terms in accordance with the table of 1/3 octave bands shown in the appendix. A DAPL custom processing command
Reducing resolutionOne thing that you cannot do with the FFT-based 1/3 octave analysis is match the results of typical filter-based instruments. The resolution of the FFT-based analysis is vastly better. It is not because the instruments are bad. The filters are designed that way. Though the standards [3] do not require this, many implementations mimic the analog filters described as a reference implementation. This preserves a degree of consistency with historical measurement instruments, even if this is not the best result possible. A well-configured FFT will respond a very small amount to off-center frequencies present in an adjacent FFT location. But two locations away: no significant response. The narrowest 1/3 octave band spans three FFT locations, so we can state simply that there is no relevant interaction beyond one neighboring 1/3 octave band. For a typical instrument using a 6th order Butterworth bandpass filter, bands three steps removed will interact. The following graphic is shown very close to true scale, for a case of frequencies located very close to the band edge. If you really prefer to match the behavior of a historical instrument, a Data Acquisition Processor could apply appropriate resolution-reduction adjustments as an additional post-processing step. You would have to determine the matrix describing how much each band filter responds to signals that are out-of-band. Applying this matrix would spread the well-isolated results of the FFT analysis and make the results closely match the requisite instrument response. Keep in mind that this is a process of throwing away information. A processing command to do this is not currently implemented. Conclusions We have shown how a rigorous 1/3 octave analysis can be configured trivially, after some careful (but easy) preliminary calculations to guarantee alignment with ANSI band location standards. The FFT analysis for the application requires very long data blocks, and to obtain a best tradeoff between block sizes and sampling rates there must be flexibility. The
The Footnotes and References:
APPENDIX - ANSI 1/3 octave band tableThis table lists:
View other Technical Notes. |