I need a speaker to play broadband white noise for my scientific application. I would like to know whether my relative naive implementation is correct or not. The speakers I use have a large frequency range but the response is not flat, so I need to equalize the sound. What I do is the following:
Software used: Matlab 2016a with Psychtoolbox 3 (latest version) for minimum latency playback.
Hardware used: Windows 10 PC (i5, 8 GB RAM), ASUS soundcard (192 KHz), National Instruments DAS card (250 kHz), profesional microphone, speakers, soundproof box.
- First I generate a
randnarray of a desired length, with the sampling frequency of the soundcard. The normally distributed random values are properly truncated so they don't exceed +1 or -1, which is the maximum range of the input signal, but also in a way that the gaussian distribution is minimally disrupted.
- Then I play the sound through the speaker and I record it with the mic and the NI card (at the card's maximum sampling frequency). I discard the beginning and the end of the signal to ensure that I have something stable, and I divide it in chunks of equal length (I discard whatever reminder they may be). After that I calculate the fft for each chunk, I obtain the absolute value, and I average it for all the chunks. As expected, the amplitude profile is not flat.
- Finally, I generate a new signal in the same way as I did the first time (I could reuse the original, I guess) and I obtain its fft. Then I multiply it point by point with the inverse of the average absolute fft of the recorded signal from the last step, properly interpolated so it has the same number of frequency points, and reflected at the middle frequency so the symmetry is respected. I take the ifft and thus it becomes my equalized signal. When I play and record it, I observe indeed that the frequency response is much flatter than the original signal.
I posted another question that describes the process more extensively. Here I omitted many details to focus just on the equalization part.