Thursday, 22 September 2016

Controlling sound propagation with DSP - some simulations

Background

One of the coolest ideas the Kii Audio speakers have, that I'm very impressed by, is the directional control of sound distribution, achieved by means of phase control of signals via the DSP. Basically

  • For frequencies up to 250Hz, they achieve a cardioid distribution, minimising rear and side reflections of bass frequencies
  • For mids/highs, they also achieve an effective point source, focused on the midrange unit, which a) ensures a more coherent wavefront for the listener, improving transient response b) again reduces reflections that otherwise interfere with the original transmission
All via DSP magic... How do they do that? I want to know... And I happen to have a couple of mid/bass units knocking around from the unfinished van speakers project, maybe I could do something with them... But what? I need to think about how this could work first.

So I started to try to draw some interference patterns at a specific frequency, using coloured pencils and a compass. Well, it was probably therapeutic (I"d had a pint or two with Mick for lunch!), but didn't really get me anywhere. The only way to explore this in any way usefully is obviously to do it on a computer, where parameters can be easily changed, and graphs/pictures saved etc. At this point, lacking funds to purchase MatLab, gnuplot is your friend! [I've since looked up MatLab, and you can get a student basic version for £29+VAT, or the whole schemozzle for £55+VAT - not bad really!].

Basics

OK, so gnuplot has a magnificent CLI :-), just the ticket! I stole a demo function for sinc(x,y) in 3D, and chopped out bits I didn't want, experimented with ranges, the surface iso line density and so on. Here's some of the results...
Basic wave propagation from single source

2 sources, separated by 1 wavelength

2 sources, 2 wavelengths

2 sources, 3 wavelengths
This isn't really moving me on much, but it was pretty interesting and a good start for late in the evening after the lunchtime pint had worn off! What about a 3rd source, located behind the other two?


3 sources, 2 level 1 wavelength apart, 1 to rear 2 wavelengths from axis 

3 sources, 2 level 2 wavelengths apart, 1 to rear 4 wavelengths from axis 
All very pretty, but not really achieving much. I think I need to introduce some considerably shorter differences, and some adjustment of relative phase.

The gnuplot code that does this is variations on the following - this produces the very first image:
# set terminal png transparent nocrop enhanced size 450,320 font "arial,8"
# set output 'surface1.16.png'
set dummy u, v
set view 70, 20, 1, 1
set samples 51, 51
set isosamples 101,101
set style data lines
set ztics -1.00000,0.25,1.00000 norangelimit
set xlabel "X axis"
set xlabel  offset character -3, -2, 0 font "" textcolor lt -1 norotate
set xrange [ -1.00000 : 1.00000 ] noreverse nowriteback
set ylabel "Y axis"
set ylabel  offset character 3, -2, 0 font "" textcolor lt -1 rotate by -270
set yrange [ -1.00000 : 1.00000 ] noreverse nowriteback
set zlabel "Z axis"
set zlabel  offset character -5, 0, 0 font "" textcolor lt -1 norotate
set zrange [ -5.00000 : 5.00000 ] noreverse nowriteback
sinc(u,v) = sin(sqrt(u**2+v**2))
GPFUN_sinc = "sinc(u,v) = sin(sqrt(u**2+v**2))"
x = 0.0
## Last datafile plotted: "$grid"
w = 2 * pi
splot [-10*w:10*w] [-10*w:10*w] sinc(u,v)
Of course, some of this is not relevant, since I cribbed it from a demo, but I can sort that later if required. The function name is left as "sinc" since it isn't important.

Now I'm trying to decide what fractional wavelength to use, and what the effects of adding sine waves is anyway - here's a plot of sin(x), sin(x-w/4) and their sum, mapped onto sqrt(2)*sin(x-w/8) - exactly the same signal, but bigger and phase shifted by the difference between the originals! Clearly  the physical separation is important - can I see this?

sin(x), sin(x-w/4), their sum and sqrt(2)*sin(x-w/8)
Breakthrough - at least in how to think about this! Rather than be concerned about the specific frequency, and the actual physical separation of the bass units, I have merely to concern myself with the required relative distance between woofers to achieve a cardioid response. This is because the DSP can vary the phase/effective distance between woofers by frequency!! Cool... I wonder if Linkwitz has anything about this...



Monday, 19 September 2016

DSP Filter thoughts

I'm reading lots about DSP-implemented filters...

Initial Post

This thread has a lot of useful thoughts from people who appear to be pretty clued-up.

Linear phase - all frequencies are delayed equally, so all bands are essentially in phase across all the outputs of a N-way crossover. However, I think (TBC) that the phase may shift across frequencies, it's just linear rather than non-linear... Also [1] says
"Linearity in phase response requires symmetry in impulse response." 
which is of course the gotcha that brings on the pre-ringing - see below.

Minimum phase - frequencies are differentially delayed through a crossover, that's effectively how it works.

The choice of linear-phase (implemented using FIR approach) or minimum-phase (generally implemented using IIR approach) is potentially critical, although since I haven't heard the two compared in otherwise equal settings, I don't know how important it is to me.

The Rational Audiophile (RA) swears by linear-phase, FIR-based, time-aligned approach. Logically, this appears to make sense - there's no way that time alignment can be ignored for a start. However, strong FIR-based filters have a significant amount of pre-ringing, which comes from the mathematics and construction of the filter. Pre-ringing (essentially, some amount of "pre-echo"-like noise preceding an impulse) is possible because FIR filters essentially "look into the future" to perform their work i.e. if the current sample is X, then they will lookahead into the input from X for N samples where N is the "number of taps". Thus the future can affect the present - in the real world, the signal is delayed by (at least) N samples e.g. if sample rate is 44KHz, then a 44 tap filter (in practice, they are usually much larger) will cause a delay of 1msec (at least - actual processing takes real time too).  So - the RA says he has a delay of 500msec, which implies FIR filters of maybe 22k taps, which is a Big Number. What happens to the pre-ringing? Is it audible?

There is a paper on this referred to by the forum posts above [1]. This claims
"The results of the listening experiment were analysed with auditory correlates of group delay distortion (phase errors) and smoothed third-octave spectrum (magnitude error). These correlates explain the results of the listening tests to some extent, but with high-order linear-phase FIR crossover filters, correlation seemed not to always exist. Thus auditory analysis that was based on the function of hearing was used for analysis. It seemed to show qualitatively the reasons for perceived phase errors.

It was discovered that high-order, linear-phase FIR crossover filters offer apparently ”ideal” properties in magnitude and phase reproduction for crossover filters, but they cause clearly audible degradations as ”ringing” in the audio samples, when the flight-time difference between low- and highpass outputs is not zero. The crossover frequency between low- and highpass bands being 3 kHz, it was noticed on the grounds of the listening experiments that filter orders above 600 produce audible errors with linear-phase FIR crossover filters. "
Hmm. Of course, I now need to read the paper, because I'm not sure what is meant by "flight-time difference", which I'm sure is explained within. "Filter orders above 600" refers to the number of taps - 22K is a HUGE number compared with that! The minimum number of taps for a specified db/octave roll-off is highly dependent on the frequencies involved too, so one could vary the taps for different bands, and then apply specific sample-count delays to those bands using smaller tap sizes.

Reading the Paper

The paper is a bit early postgrad, and written by someone whose first language is not English, although that's only an observation not a criticism, on the basis that I'm not sure if some of the ambiguities are intellectual or linguistic!

There's a great summary of the properties required of a crossover:
To conclude all these demands for crossover filters and their transfer functions, we end up with the following goals, as Linkwitz [6], and Lipshitz and Vanderkooy [7] did in their articles:
1. Flatness in the magnitude response. That is, the output signals from woofer and tweeter sum up to unity on the main listening axis; there are no dips or peaks at any frequency.
2. Adequately steep cutoff rates of the low- and highpass filters. This is to ensure that the drivers operate on their optimal range, and to minimize the interference between the drivers.
3. Phase difference is zero between the woofer output and the tweeter output at the crossover frequency. This prevents tilting in the loudspeaker’s radiation pattern.
4. Ideal polar response of the loudspeaker by having the same phase difference between outputs at all frequencies. That is, the reproduction of the loudspeaker is symmetrical as a function of angle and it requires the same group delay from low- and highpass filters.
Other points:

  • A considerable phenomenon with steep cutoff rates in the FIR case is the ringing of their off-axis response - how does this work? Why would there be a change in the physical speaker behaviour because of a steep cutoff?? The screen shot shows the writer's simulation of 
    • 3.21 An on-axis impulse response of two drivers summed - lovely!
    • 3.22 Impulse responses of two drivers summed with 0.2msec delay between them i.e. off-axis. Hmm.
 

  • The temporal resolution of ear was discovered to be approximately 2.5 ms for signals having identical energy spectra and differenting only by phase. This experiment was done by Patterson and Green in 1970
    • OK... which is 6.6 inches, which is a heck of a lot. Do we REALLY hear time-alignment, unless the difference is egregious?
  • Schouten has defined the recognition of an ”auditory object” to depend on the following factors [48]:
    • 1. Sound periodicity in the range from 20 to 20000 Hz vs. noise-like, irregular sound
    • 2. Waveform is constant vs. waveform fluctuates as a function of time; fluctuations are similar/dissimilar
    • 3. Other aspect of sound, like spetrum or periodicity is changing as a function of time 
    • 4. What are the preceeding and the following sounds like?
  • From the audio engineer’s point of view, group delay distortions have been used as a measure of phase errors for a long time. The most comprehensive paper on the group delay matters in the audio field is probably the paper by Lipshitz, Pocock and Vanderkooy [14], supported by [15, 16, 17, 18, 19, 20, 21, 22]. Hoshino and Takegahara [49] have defined the permissible values for group delay at high frequencies to be roughly 2 ms from 10 kHz, though this has more importance in general audio processing than in crossover design, because usually the crossover frequencies are way below 10 kHz. A recent study defines the audible value of group delay to be 1.6 ms [22]. Møller et al. describe the group delay errors as ”ringing” or ”pitchiness” and importantly state that ”the ringing is detected in the individual ear and not as part of binaural processing”
  • Localization means judging the direction and distance of a sound event... There are differences in signals arriving at the ears, and the concepts of inter-aural time difference (ITD) and inter-aural level difference (ILD) between the ears are of the greatest importance.
  • "The delay between low- and highpass outputs was implemented to simulate the elevation of the listening angle, because most of the problems exist, when the vertical angle is changed. With quite a normal separation of drivers of a two-way loudspeaker (0.25 m), the delay was limited to 0-0.5 ms to simulate far-field elevation angles between 0 and 45 degrees"
    • Hmm - assuming 0.25m, 3m to listener, right angle triangle, path length is ~10mm different, or 0.3msec. Let's read on...
    • "The woofer was 78cm, and the tweeter was 92 cm above the floor" i.e. 0.14m different!
  • "The large number of different scenarios forced to cut out inaudible (to the author at least) samples to make the test reasonable in size and duration"
    • Aha - so samples pre-filtered by author to simplify - assumes author can hear all differences others cannot, not v.v.
  • "Qualitative inspections from the subjects suggested that the ringing of FIR crossovers was highly critical to the listening place. Slight changes in subject’s head position could make the phenomenon either audible or inaudible. There were also differences between test subjects. Remarkable is that the errors were clearly audible with a real signal and a real loudspeaker in a listening room. This suggests carefulness in designing and using digital crossover filters, especially linear phase FIR crossovers with higher orders."
    • He's using delays of 0.03msec i.e. <= 1mm difference in woofer/tweeter location, on a 2000tap FIR on the simulated test
    • So it's not surmising that small head movements can make a big difference in the loudspeaker case
Given what this paper says, you'd have to be deficient if you weren't to consider some of the points, at least to the extent of seeing what makes a difference for you.

Thursday, 15 September 2016

Commercial options

Whilst researching this digital audio business, I've bumped into a number of interesting commercial options in the active speaker area - thanks largely to therationalaudiophile.wordpress.com and comments therein.

Kii Audio THREE


Kii Audio provide the Kii THREE, which is quite a tour de force in the active speaker arena. Kii was formed by Bruno Putzeys (MolaMola, Hypex, Grimm - a real BSD in the amp and digital processing sphere), Bart van der Laam (DSP expert) and a couple of other guys for product management and production control.

Very small for such a premium product (16"x16"x8" or so), each box contains 6 (yes, that's 6!) 250W Class D amps, 4 woofers (two at the back, one each side), a mid and a tweeter (both in the front). The DSP is the heart of things, providing crossovers, equalisation and a "phased array" mechanism for the woofers that tailors the bass off-axis output to suit the speaker's location or your taste. There's also a "motional feedback" mechanism on the woofers to correct distortion. Pretty hairy stuff, and obviously only possible in the digital domain.

I went to hear the Kii THREEs (not sure how important the Capitalisation is but all their literature uses them ;-) ) at Purite Audio, Keith Cooper's home-run audio dealership. Excellent guy, yes a dealer, been in the business a relatively long time, but at least pretty open and friendly in person. A house full of interesting audio! We listened to the Kiis for maybe 4 hours (!), sitting on a comfy couch, my selection of music (Janet Baker, Mahler, Joe Jackson's Body and Soul (a revelation!), and others). I was massively impressed by the capability of the speakers - see comments below.

Good things

  • Wonderful natural non-boxy sound
  • Great imaging
  • Very natural unforced bass
  • Ran ridiculously loud with no strain or effort (had to turn down after we realised we couldn't hear each other!)
  • Real people in real acoustic spaces for those recordings that attempt to portray that

Drawbacks

  • £8000+! But then, you wouldn't need any preamps or amps...
  • Only accept AES/EBU (professional standard digital wire protocol) at the moment, so require something to convert e.g. Weiss INT202 or similar, which Keith reckoned he'd throw in (not insignificant, maybe £800 retail!). There is a Grimm-alike desktop console for other input protocols coming apparently, but no idea when.
  • Possibly small hot spot, at least in the room and conditions I auditioned - Keith didn't get the same impression sat on the other end of the couch - no different from Quads then!
  • Is that all?! Where's my credit card...
So, a revelatory experience. Fortunately I controlled myself, and ran away before ordering on the spot. However, these are definitely on the list. I could sell the Chords, the Quads  (for £200 probably!) and presumably the Naim CDS2 which I won't eventually need. Cheap!

Code Acoustics System-1

CONTROL-1 DSP/Amp Box
SYSTEM-1 Speakers

Descriptions available here, these look a bit more home-made than the Kiis, and there's no provenance for the designer/builder. Basically, a separate 6-channel DSP/Amp box, with "normal" boxes and speakers, I assume, since there's nothing on the website to indicate otherwise. About £5k, with a money back guarantee, not unexpected from someone trying to launch a business and product with no provenance. The Control-1 has a bigger range of inputs, USB, AES, SPDIF, TosLink and 6? XLR balanced analogue inputs. Not sure what those last are for, I guess all will become clear shortly.

I haven't heard these yet, but I'm expecting to arrange a home demo with the manufacturer/designer/sales person Ceri shortly. Ooh!! My initial reaction is "how different are these to something I could build myself'? And then again, how necessary is the Kii bass directionality control? And all of these are more expensive than the Linkwitz LX-Mini with his subwoofers added, which I also haven't heard, which do in-room behaviour control with the physical characteristics of the chassis speakers and enclosures.

Other Choices

There are lots more active options around, most of which I haven't really explored, for various reasons
  • Grimm LS-1 - also available from Purite, but EXPENSIVE!!
  • Manger - also more expensive, and not sure they are better than Kiis, for example, although not listened to them
  • Genelecs - more pro and probably expensive
  • Divialet Phantom - Not seen any of these around
  • etc...!

Monday, 11 July 2016

The mobile subwoofer sideshow...

I've been pootling along in my van a lot recently, usually on the way to a beach to indulge in some windsurfing and possibly subsequent fish and chips, and enjoying listening to my iPod on Shuffle - what an amazing collection of music!

However, the stereo is currently limited to two small Infinity "digital ready" speakers mounted in the dash. As usual, "digital ready" means raucously shouty and harsh in the top end, whilst being little and dash-mounted, the bottom end is non-existent. This means I have to have them far too loud for any useful effect. So...

I realised that I have two Rear channels on the stereo not currently in use. So let's put them to use! Rather than an actual subwoofer, how about something that adds a bit to the stereo effect whilst supporting much better bass, albeit not necessarily too thumps? Make sure that the boxes involved are sufficiently small, and they can go under the seats in the van, for simplicity of re-use and effectiveness of bottom end. No need for tweeters, I'm not looking for full-range, just something to fill out the bottom and mid a bit.

A fair bit of research at Falcon Acoustics and Wilmslow Audio websites, lots of runs of ISD Online (since WinISD is necessarily only available for Windows!), and some more searching, usefully including the hifitest.de website with a build using the selected mid/bass unit, and I'm trying out something self-brewed.

The Monacor SPH-5M appears to offer a reasonably priced woofer-ish object that can be used in a sealed box or a ported box to taste, with reasonable power handling and sensible box sizes i.e. sealed 6 litres, ported 10-20 litres, so comfortably sized for stashing behind the seats in the van. There are others available that might do better, but hey... I can always construct a pair of bookshelf speakers with them if I don't like it.

And I even got them cheaper than expected at Audiomate.co.uk, being delivered tomorrow. All I have to do is source some MDF (hifitest used 16mm MDF, but my choices are 12 or 18 - too light or too heavy!), some bass port tubes (probably Wickes finest black plastic drainpipe, 40mm), and some terminals (I suspect whatever I can find cheapest, possibly at the Shop on the Bridge). I already have wire. Hurray. And I can dick about measuring them, maybe even build both sealed and ported versions to see which I prefer!

Thursday, 7 July 2016

Setting up the speakers in active mode

Having (almost) got myself an active speaker setup (need to check out the effectiveness of my DPDT switch for passive/active switching, suspect inductance still across woofer :-( ), now it's time to set the whole thing up.

I'm using the approach suggested by this blog post, which is basically
  • Measure the chassis speakers separately in the box
    • Easy to do this now, since I can easily turn one or the other off
  • For each speaker
    • Adjust response using speaker-specific equalisation, noting carefully the off-axis response and keeping this as smoothly degrading as possible
  • Set up the crossover, and measure both together
    • Some additional effort is required to ensure they are integrated properly
  • Make timing adjustments to ensure the impulse response is the same on both units
Here's my first pass at a setting for the tweeter - I started with this because the tweeter is definitely not affected by any remaining passive crossover components. I shall move the testing outside to reduce reflections, and probably re-do it, but it's illustrative and good practice (as is "I need to practise doing this").
REW plots for tweeter response before/after
You can see that there is a pretty stonking (5dB!) rise from 6k to 10k, which I've EQ'd out. I've also flattened out the bottom end a bit - the blogger mentioned above reckons you need to be pretty flat to 2 octaves above/below crossover frequency, but this tweeter isn't going to do that! Hey, take what you can...

Tweeter on and off-axis response after EQ
Looking at the off-axis response, it looks ok to me. It's quite surprising how the top end holds up.

EQ settings
I've been using AULab to do this, because it's simple (hah!! relatively...) and has graphical interfaces. I tried several EQ tools - High Shelf filter, Parametric, but Graphic EQ provided the most flexibility. I can't believe how easy it is to tweak it and re-test - just imagine how horrible it would be with any kind of passive arrangement! Bleuch.

However, the last measurement I made produced extremely distorted sound, so I saved the AULab document, presumably with all in/out and plug-in settings, and restarted it. However, on reloading the document, I discover that AULab is insisting on Soundflower or Saffire in/out, rather than Soundflower in/Saffire out - to get that I would have to create a new document, which means recreating all the Graphic EQ settings. Sigh. Oh for a text config file and some CLI! The AULab config file is actually XML, but it's pretty impenetrable, and of course, it presumably reflects the same in/out arrangement. Maybe I should raise a bug with Apple?

Right, time to move outside, do some more measurement.


Wednesday, 6 July 2016

Routing Audio on a Mac - :-) or maybe :-( - no, :-) !

I am using Apple's AULab to implement my first pass at crossovers for the A100s:
  • Define an AULab document with one stereo input, two stereo outputs each 
    • Input so far has been AUGenerator, which plays sound files; great as a first pass
    • Outputs are set to my Focusrite Safire, channels 1-2 (woofer) and 3-4 (tweeter)
  • Configure an AUCrossover on each of the outputs
    • HiPass for the tweeter
    • LoPass for the woofer
  • Wire Safire
    • Channel 1 to amp LH channel (woofer)
    • Channel 3 to amp RH channel (tweeter)
  • Play audio file to check configuration
AULab Document for 2-Way Crossover, Soundflower or MP3 input
AU Crossovers (currently Butterworth!)
This seems to work ok, as far as I can tell there are different signals coming out of the appropriate inputs.

However, on closer listening, ALL inputs are coming out of ALL outputs - not good if I'm looking for two separate sets of signals, especially for the tweeter!

How to fix this??

<<<<<<<< Long pause (many days!!) whilst I calm down, amongst other things >>>>>>>>

OK. I've located the Saffire Control application, and looked at that. I have to click on the "soundcard" button, which makes the Saffire behave just like a simple 8-way soundcard. Hurray! The button is down on the right hand side of the panel below.
Setting Soundcard mode in the Saffire Control panel
Now to get the REW software to route its testing signals to the AULab.

Lots of struggling with this... Hours, in fact! Until I notice that there is a choice in the AULab software for configuring the input, which has as its last two channels Soundflower 1&2... Sorted. Set REW output to Soundflower 1, job done. The other channels are from the Saffire inputs.
Selecting Soundflower as input in AULab
Next problem - got a great setup, lots of good equalised curves for tweeter, but some distortion on last couple of runs. Saved AULab document, exited AULab, restarted, reloaded doc -  and now it's lost the Saffire output!! Everything is via Soundflower - suboptimal. If I make the default Saffire, then I can't set the input to Soundflower. Bah!!

Thursday, 30 June 2016

Active Loudspeaker!

A bit of an anti-climax, perhaps, but I've now got an active Boston A100 :-o.

I removed the original back terminal plate, hot glued onto the inside of a hole in the back of the speaker. I then removed the fuse and terminals from the board, so I could reglue it back inside the box to support the original crossover components. I then wired up a DPDT switch and the new "biwire" terminal block, so that the speaker can be used active of passive at the throw of a switch. The hole in the back of the speaker was too wide for the new block, so I filled it with a piece of 18mm chipboard (actually from some old G-Plan furniture shelves we scrapped a few months ago! Very decorative...).

Taking out the old terminal panel

Refitting the old panel with the original crossover components

The original hole filled to fit the new terminal block

New terminal block, with separate woofer/tweeter wires, also shows active/passive switch

Setup with Safire DAC, Myst stereo amp and speaker
The original crossover is shown below diagrammatically - I used an online tool which is a bit pants but hey...
Original Speaker wiring

And this is the revised version, which allows the woofer and tweeter to be completely separate.

Active/Passive switching circuit
Except that now I look at that, I see a massive inductor wired permanently across the woofer terminals... Albeit through a few caps and a resistor. Damn... Will this have an effect? Arguably, I should disconnect the entire old crossover network. That requires another or different switch. Later - I have other difficulties!