Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Speaker Lab

Post any examples or modules that you want to share here

Speaker Lab

Postby steph_tsf » Sun Aug 04, 2013 2:39 pm

The aim is to show how simple and effective DSP is, when applied to speakers.

Let's begin with the Speaker Lab Player. This is a simple .mp3 player featuring :
- BiQuad IIR filter
- FIR filter
- A/B switch
- VU-meters

Currently, I'm using Logitech z120 speakers. For reproducing the experiment, you need those speakers. They are widely available, and inexpensive. This is the only required hardware for running the Speaker Lab Player.

The BiQuad IIR filter serves as Linkwitz Transform, compensating the low frequency resonance and deep bass 2nd order high-pass attenuation of the closed-box speaker. In case you don't know what's a Linkwitz Transform, please check section 9 here http://www.linkwitzlab.com/filters.htm

The FIR filter serves as linearizer above 300 Hz or so.

The dB knobs are there for equalizing the listening levels.

The A/B switch enables you to compare the unprocessed sound against the processed sound.

The VU-meters are there for showing if you get close to digital saturation.
Attachments
Speaker Lab - Player v1.fsm
(29.12 KiB) Downloaded 1673 times
Speaker Lab - Player (400).png
Speaker Lab - Player (400).png (28.93 KiB) Viewed 40874 times
Last edited by steph_tsf on Fri Aug 16, 2013 1:08 am, edited 6 times in total.
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Speaker Lab

Postby steph_tsf » Sun Aug 04, 2013 2:50 pm

Here are a few z120 BiQuad filters you can select as Linkwitz-Transform.
Unzip the file in the directory where you have the .fsm.
Select one of those BiQuads upon pressing the Load BiQuad ... button.

The BiQuad labelled as MODEL is not to be used as Linkwitz Transform.
Such file is there, only for documentary purpose.
This is the BiQuad modelling the z120 resonance and low frequency roll-off.

Here are a few z120 FIR filters you can select as linearizers above 300 Hz.
Unzip the file in the directory where you have the .fsm.
Select one of those FIRs upon pressing the Load FIR ... button.

Would be nice if you could share your listening impressions.
Attachments
Logitech z120.jpg
Logitech z120.jpg (7.42 KiB) Viewed 40944 times
Logitech z120_FIRs.zip
(2.6 KiB) Downloaded 1655 times
Logitech z120_BiQuads.zip
(1.2 KiB) Downloaded 1631 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Speaker Lab

Postby steph_tsf » Sun Aug 04, 2013 4:42 pm

Here are the z120 frequency responses, uncorrected (above) and corrected by the BiQuad + FIR (below)
The green plot is the impulse response, when corrected.

I will now describe my listening experience.

Clearly, obviously, the z120 cannot deliver sound at a high intensity, especially when a heavy Linkwitz Transform gets selected.

What's a "heavy" Linkwitz Transform, actually?
When selecting a xx dB Linkwitz Transform, the medium/high frequencies get attenuated by xx dB, with the deep bass remaining unattenuated.
Doing so, the deep bass inherits a relative boost of xx dB without ending up with digital saturation.
I'm not talking about digital saturation within Flowstone, using Floats.
I'm talking about digital saturation, just before the D/A conversion, where the audio sample is supposed to be within the (-0.99, +0.99) range.
Avoiding digital saturation, is the reason why the Linkwitz Transform appears to decrease the listening level.

If the low frequency content is low, you may add some gain after the BiQuad + FIR, at your own risk.
There is a knob for this.

When you select the 0dB Linkwitz Transform, all you do is to rub out the z120 bass resonance, without asking for any deep bass extension. The 0 dB Linkwitz Transform preserves the listening level. You should try it in first place.

When you select the 18dB Linkwitz Transform, you rub out the z120 bass resonance, and you ask for a 18 dB linear deep bass extension. The 18 dB Linkwitz Transform will thus decrease the listening level by 18 dB. If you now ask a 18 dB gain after the BiQuad + FIR, you probably will :
- cause digital saturation before the A/D converter in case there is a heavy deep bass content, and
- ask the z120 to exceed their Xmax in case there is a heavy deep bass content.

If you listen in a very quiet environment, at a distance of 50 cm or so from the Logitech z120, you'll get a decent listening level even when selecting a 12 dB Linkwitz Transform.

I will now describe a quite addictive experiment.

Select the 18 dB Linkwitz Transform, providing a 18 dB linear bass extension compared to the genuine z120 frequency response.
Select the 256 samples FIR, providing an amplitude + phase linearizer with a 172 Hz resolution.
As general result, you get an essentially flat frequency response and flat phase from 100 Hz to 12 kHz, without any discontinuity or bump.
Set the volume in the Speaker Lab Player, high enough, a few decibels before digital saturation.
Set the physical z120 volume knob a few decibels before audible distortion.
Check there is no distortion when there is a heavy deep bass content. Reduce the physical z120 volume knob, if required.
After doing this you'll be disappointed by the listening level, quite low now.
Take the two z120 speakers in your hands, and apply them on your ears like a headphone.
Maintain a distance of 5 cm or so between your ears and the z120, so there is no cavity resonance taking place.
You should now be happy with the listening level, unless you suffer from some hearing loss.
Now listen carefully to the sound.

Such addictive experiment illustrates what DSP is, applied to speakers.

Upon finishing the Speaker Lab Player, I found the processed sound quite dull, compared to the genuine unprocessed Logitech z120 sound. In their genuine state, the Logitech z120 deliver a quite "round" and "punchy" sound. When looking at their frequency response curve, there is no mystery. The "round" impression comes from the 220 Hz + 8 dB boost, and the "punchy" impression comes from the diffuse 3 kHz + 5 dB resonance.
So yes, when applying the Linkwitz Transform 0dB for rubbing out the bass resonance, and when applying a 64-tap or 128-tap FIR for linearizing the the medium/high frequencies, the resulting sound appeared quite dull to me.
I then applied the 12 dB Linkwitz Tranform for recovering the deep bass range. After equalizing the listening level with the unprocessed sound, I started realizing there could be an advantage in favor of the processed sound.
I played with the Linkwitz Transform, comparing the 12 dB one, with the 9 dB and the 15 dB ones.
Selecting one BiQuad, then another, comparing the result, all this took a few minutes.
During all this time, my ear and hearing system became accustomed to the new sound.
I then listened the speakers only 5 cm away from my ears, like described above.
As a matter of curiosity, I reverted back to the genuine z120 unprocessed sound.
I managed to carefully equalize the listening levels, for better comparing.
To my great astonishment, the genuine z120 unprocessed sound brutally appeared as fundamentally flawed.
Switching a few times between the processed sound and the unprocessed sound, I started understanding how loudspeakers can play "false". By saying "false", I'm of course not talking about the notes, as a 1 kHz remains a 1 kHz, processed or unprocessed. Actually, I'm talking about the way sound textures do evolve over time.

Taking about one week-end (today and yesterday), comparing the processed sound against the unprocessed sound, using a lot of different recording material, I finally understood what was happening.

The unprocessed sound prevents you from following the sound textures, when they rapidly evolve from one note to another. And this includes the human voice. There appears to be a semi-transparent curtain between the sound, and you. When the sound is highly non-static, such curtain appears to be alive, dynamically modifying the sound, making it difficult to follow.
The unprocessed sound textures, as soon as they start to move, appear to be garbled.
On the other hand, the processed sound textures remain consistent and identifiable, easy to follow, and this remains especially true when they evolve over time. The digital signal processing executed by the Speaker Lab Player appears to remove such "semi-transparent curtain".

Would be nice, if you reproduce the experiment at your side, and leave some comments here.

- special thanks to MyCo, author of the sequential-load FIR
- special thanks to Nubeat7, author of the knobs (a few mods from me, like loading them from a file).

Thanks again,
Steph
Attachments
z120 Pre-Apo (showing impulse from z120 corrected) (400).png
z120 Pre-Apo (showing impulse from z120 corrected) (400).png (19.22 KiB) Viewed 40940 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Speaker Lab

Postby steph_tsf » Sun Aug 04, 2013 6:53 pm

Now comes the time to tell how the various FIR filters got designed.

This is very simple indeed.

1.
Decide about the target response curve, the one from the Logitech z120 after they get corrected.
Say you want a 2nd order lowpass, Butterworth, with a cutoff at 10 kHz or so.
You need to compute the corresponding impulse response and use it as reference.
For getting such impulse response using Flowstone, use the "Impulse" primitive, send the signal into a 2nd order lowpass Butterworth (one BiQuad), and grab the output using the signal "Analyze" primitive, grabbing the 256 first samples, storing them into a Float Array. The longer the grab, the more precise the correction will be. Grabbing 256 samples at a 44.100 Hz sampling frequency means a 5.8 ms signal duration. There is no use in grabbing more samples. Grabbing more samples, we run the risk embedding signal reflections into the grab. If this is the case, on top of correcting the loudspeaker emission, we will correct the room resonances. The issue with correcting the room resonance, is that the correction will only be valid at a particular listening point.

2.
Compute the impulse response of the genuine Logitech z120 speakers, using the 5-channel FFT-based Audio Analyzer described in another thread on Flowstone forum. Setup the analyzer for a 256-tap FFT. For doing so you need a mike, a mike preamplifier, and a loopback cable.

3.
Translate the two above impulse responses into the frequency/phase domain using a 256-tap FFT.

4.
Compare the target gain/phase with the Logitech z120 gain/phase, frequency bin per frequency bin.
As the FFT is a 256-tap one, you get 129 frequency bins, each outputting a gain value, and a phase value.
Such comparison is the design sheet for the super-resolution gain/phase equalizer that you are going to build.
For each frequency bin,
- the gain correction equals the target gain divided by the Logitech z120 gain
- the phase correction equals the target phase minus the Logitech z120 phase

5.
Translate the correction gain/phase into time domain using a 256-tap iFFT (inverse FFT).
This is the impulse response of the correction.
Wait a minute ... "the impulse response" ...
Those are thus the coefficients of the FIR implementing the correction.
Job done.

This is the bare idea. For getting this working optimally, two extra-features need to be added.

6.
The FIR filter, having a frequency resolution equal to Fs/N (Fs=44.100 and N=256), cannot correct the bass range with a decent precision. With a 256-tap FFT, the FIR can barely make a difference between frequencies that are 170 Hz apart. For avoiding the FIR to apply a correction at the lowest frequencies, we need to apply a "mask" before generating the filter design sheet. The "mask" simply consists of specifying that the correction gain will be 0 dB and the correction phase will be 0 degree for the first frequency bin, or possibly for the first and second frequency bins. This way the FIR only introduces corrections above 300 Hz or so.

7.
The FIR, materializing an impulse response having a finite length, may be associated to a proper "window" putting the emphasis on the leading edge. This is important, as the leading edge contains most of the energy in case of an impulse response, on which everything gets based here. The aim of the "window" is to progressively extinct the impulse response trailing edge, whatever the design sheet asks for.

Attached are the control screens, visualizing the various impulse responses and correction needed.
- green curves : genuine, uncorrected Logitech z120
- blue curve : target, obtained from stage 1
- red curves : corrections required from stage 5, actually there are two sets or red curves, the non-windowed correction, and the windowed correction.
- black curve : corrected Logitech z120.

Now you are watching, what you just listened at.
You know where the FIR filters are coming from, and how they got designed.
Remember this is the design stage.

When listening to the music, the above scheme is of course not executed. The only thing that gets executed when listening to the music, is the resulting 256-tap FIR filter, the one that you select using the "Load FIR ..." button in the Speaker Lab Player.

Steph
Attachments
FIR design - Target 2nd order lowpass Q 0.707 (300).png
FIR design - Target 2nd order lowpass Q 0.707 (300).png (24.4 KiB) Viewed 40932 times
FIR design - Target 1st order lowpass (300).png
FIR design - Target 1st order lowpass (300).png (23.06 KiB) Viewed 40932 times
Last edited by steph_tsf on Sun Aug 04, 2013 10:57 pm, edited 4 times in total.
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Speaker Lab

Postby steph_tsf » Sun Aug 04, 2013 7:05 pm

Want to experiment the Speaker Lab - Designer ?
Here is the corresponding .fsm
Attachments
Speaker Lab - Designer.fsm
(635.19 KiB) Downloaded 1570 times
FIR design - impulse - FFT & compare - iFFT (500).png
FIR design - impulse - FFT & compare - iFFT (500).png (88.38 KiB) Viewed 40931 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Speaker Lab

Postby martinvicanek » Mon Aug 05, 2013 7:01 am

Interesting. One question: how flat is the mic frequency response? Do you need a dedicated, expensive device?
I haven't actually listened, but by the look at your spectra it seems that with the 10 kHz Butterworth LP you are cutting treble perhaps more than necessary. Could that be a reason for your first perception of the processed sound as dull?
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: Speaker Lab

Postby steph_tsf » Mon Aug 05, 2013 8:31 am

Hello Martin, yes indeed, you are right.
The correction made by the FIR filter is function of the microphone transfer function.
The Butterworth target lowpass in the FIR filter design got setup on purpose, for avoiding the FIR filter asking for gain in the treble range extremity. Look the tiny red curve.
A factor explaining the corrected sound appearing dull, may be the polar radiation pattern of the Logitech z120, quite directive above 5 kHz due to the membrane diameter, larger than a dome tweeter. The measuring mike that's just in front of the Logitech z120 speaker pickups a certain amount of treble energy, however at an offset of 30 degree or 45 degree, the treble energy is much lower. Bear in mind that the ear is integrating the sound coming from all directions. In a normal living room, as soon as you are not just in front of the speakers, the reflected sound contribution may become dominant. Treble will be in deficit, when dealing with a directional speaker.
Such theory may explain the addictive attribute of listening the Logitech z120 like headphones, only 5 cm away from the ears. Listening this way, you'll find nobody qualifying the corrected sound as dull. Your ear is now at the place of the measuring microphone, and the reflected sound contribution becomes negligible.
I won't comment on the measuring mike and preamp, beyond the fact that this is an electret condenser mike factory wired as 3-terminal (not the usual Panasonic WM61A tweak), hooked on a standard low noise preamp designed and made by me, powered by a 9V battery. I just bought a few Panasonic WM61A on eBay. Someday I'll make detailed comparisons, hoping they are not fakes. I also have the Behringer C-2 and B-5 at disposition (20 mm condenser capsule needing phantom power), hooked on a USB audio interface featuring the mike preamp and phantom power. This is all standard, affordable audio gear, nothing esoteric.
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Speaker Lab

Postby steph_tsf » Fri Aug 16, 2013 1:18 am

This is Player v2.
Attachments
Speaker Lab - Player v2.png
Speaker Lab - Player v2.png (18.67 KiB) Viewed 40811 times
Speaker Lab - Player v2.zip
(837 Bytes) Downloaded 1581 times
Speaker Lab - Player v2.fsm
(30.33 KiB) Downloaded 1573 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Speaker Lab

Postby steph_tsf » Fri Aug 16, 2013 1:41 am

Here is Speaker Lab v1.0.
There are two different incarnations.

DSP before DAC
One can hear and see the correction.
The DAC to ADC latency needs to be compensated.
Unfortunately, such latency is hard to compensate, as it exhibits sudden variations when Windows must process audio as background task, and at the same time write a file to disk or draw many lines on the screen.

DSP after ADC
One can see the correction, not hear the correction.
The DAC to ADC latency doesn't need to be compensated.
Attachments
Speaker Lab v1.0.png
Speaker Lab v1.0.png (41.27 KiB) Viewed 40810 times
Speaker Lab (DSP before DAC) v1.0.fsm
(565.4 KiB) Downloaded 1542 times
Speaker Lab (DSP after ADC) v1.0.fsm
(1.11 MiB) Downloaded 1697 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: Speaker Lab

Postby steph_tsf » Thu Aug 22, 2013 1:24 pm

Client/Server Speaker Lab, running on two separate computers.
The advantage : both x86 PCs can have relaxed specifications.
The disadvantage : need to setup the corresponding TCP/UDP Flowstone blocks ...

p.s.
As the DC doesn't get conveyed through the reference channel, one need to be careful with the first frequency bin.
A possibility is to rely on the Client -> Server data link for conveying the missing piece, however the Client -> Server latency will cause trouble, and even more trouble will be caused by the USB+DAC+ADC+USB latency. The DC bin arriving through the Client -> Server link won't correspond to the actual audio data, sampled by the ADC and sent to the Analyzer using USB.
Attachments
Speaker Lab (Client-Server).jpg
Speaker Lab (Client-Server).jpg (27.89 KiB) Viewed 40773 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm


Return to User Examples

Who is online

Users browsing this forum: No registered users and 110 guests