Is it possible to create a simple spectrum analyzer?

There is no way to know the spectral frequency level of a signal accessible to blind people. There is the possibility with the integrated audaciti analyzer but it must be exported to a text file. Ahun thus is very uncomfortable because the minimum report is 128 bands. What I want to know is if a simpler analyzer can be created with subwoofer, bass, bass and sub-bass, using filters and some integrated Nyquist function to calculate the peak and present a message, just like Measure rms, informing Only the result of the sum of the two channels.

I’m not sure what you mean by “subwoofer, bass, bass and sub-bass”. What’s the job? Are you trying to determine how much bass there is? Would it be adequate to get a measurement of just one frequency band (such as, frequencies below 100 Hz)?

Yes, that is exactly what I want. Have information on the entire audio spectrum from the bass to the treble divided into a certain frequency range.

So long as the selection that you are measuring is not too long, then you could use this (in the Nyquist Prompt):

;version 4
;type analyze

(setf hz 100) ;lowpass frequency
(setf *float-format* "%.2f")  ;decimal places to print

(when (arrayp *track*)
  (setf *track* (mult 0.5 (sum (aref *track* 0)
                               (aref *track* 1)))))
(setf peak (peak (lowpass8 *track* hz) ny:all))
(format nil "~a dB" (linear-to-db peak))

The analysis is not accurate since placing two filters impinged to restrict the frequency band, adjusting the low pass filter and the high pass filter at the same frequency gives me a peak of -19 dB. I compared the results with an exported frequency band in the text file of the audacity integrated analyzer, and I have lower values. I guess Nyquist filters are not good at preserving the frequency band without having face problems. I think that it works for something. At least to compare some frequencies of some audios.

The Nyquist filter in that code example is a Butterworth filter. The filter retains maximum flatness in the pass band, but does not have linear phase response, so the peak level in the pass band is likely to change. Nevertheless, the reported peak level IS the peak level of the filtered audio.

I’m not totally clear about what you want. Is a peak level measurement actually appropriate for your purpose? What is your purpose for this?

I want to use the analysis to find a balance in the spectrum of a mix in mastering. The objective is to focus mainly on the serious frequencies, but also on the main frequencies that can be problematic. Around 400 and 700 hz dirt can accumulate, between 2 and 5 khz there may be a lack or excess presence, between 5000 and 20000 hz the brightness etc.

So is it the “average” level that you want to measure, or the RMS level, or something else?

I don’t know how to say very well, but I think that the peak reported in the bruebas is quite high compared to the full spectrum. For example, if the entire spectrum has a peak of 0 dB, it is assumed that a frequency band should not have a peak as close to 0.

Here’s an experiment for you to try, which will illustrate what is occurring.

  1. Generate a 440 Hz Square wave, amplitude 0.5

  2. With the track selected, open the Analyze effect and note “Amplification dB” setting. This is the amount of amplification required to bring the level up to 0 dB, so if the “Amplification dB” setting says “6.021”, then that means that the peak level of the selected audio is -6.021 dB (minus 6.021).

  3. Apply a “High Pass” filter, set to 100 Hz, 6dB per octave.

Because the filter is set to a frequency below the square wave frequency, we might expect that the square wave to be largely unaffected by the filter, but now repeat step 2

  1. With the track selected, open the Analyze effect and note “Amplification dB” setting.
    Note that peak level has increased very noticeably. This is because the filter (a Butterworth filter) has non-linear phase response, which distorts the shape of the waveform. The waveform no longer looks “square”. The leading edge of the square wave now goes higher, and the previously flat top of the waveform now slopes downward. The downward going edge of the waveform goes further down than it did originally, and the previously flat bottom now slopes up. This is the due to frequency dependent phase shift.

When applying filters to complex waveforms, it is almost impossible to predict what the peak level of the filtered waveform will be, because of these phase shifts. Phase shift does not change the sound of the waveform, but it does change the shape, and the peak level. The exception to this is when using “linear phase” filters. In the case of linear phase filters, all frequencies are phase shifted by the same amount, so the resulting amplitude is somewhat more like one would expect.

Audacity’s Equalization effect has linear phase. Unfortunately there is not yet a linear phase filter included in Nyquist.

Do the linear filters have any audible difference? When using the audacity graphic eq I have been able to perceive that the adjusted frequency band does not change much compared to a Nyquist filter with 0.5 bandwidth. Or the audio does not change much because the bands of this effect with narrower?