Klippel Near Field Scanner on a Shoestring

@ 3ll3d00d

Instead of building an .EXE why not just have a no install/portable version ?;)

That's what we are thinking for our test LP software, but It still involves an installed Python environment. I have yet to find anything that the Anaconda distribution leaves out and several folks have had good results without having to be savvy to the gory details (everything simply click and run).
 
We would need to resort to the C# code to debug that.
OK I'll get something together

I made a start on some animated charts and thought a vid might be interesting to see the whole thing in action

It seems you can't embed youtube vids in this forum so head to this vid on youtube, I seem to have broken a few of the bits in the last minute today so ignore that bit :)
 
Last edited:
We would need to resort to the C# code to debug that.

a test case to reproduce

Code:
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Numerics;


namespace Smooth
{
    class Program
    {
        static double[] parse(String input)
        {
            var lines = input.Split('|');
            var n = lines.Length;
            var vals = new double[n];
            for (var i = 0; i < n; i++)
            {
                vals[i] = Double.Parse(lines[i]);
            }
            return vals;
        }
        
        static void Main(string[] args)
        {
            double[] dataIn = parse("3.72526296e-05|5.09016873e-05|6.63042274e-05|8.34622579e-05|1.02298897e-04|1.22588259e-04|1.43873918e-04|1.65384019e-04|1.85999733e-04|2.04478233e-04|2.20575230e-04|2.38870409e-04|2.74201035e-04|3.42342845e-04|4.41093709e-04|5.41365150e-04|5.90392959e-04|5.86344944e-04|5.85859271e-04|6.14657646e-04|6.47684903e-04|7.15555761e-04|7.82675127e-04|7.16797402e-04|7.56132818e-04|6.93179605e-04|6.65578126e-04|5.70543066e-04|6.78094958e-04|5.18569639e-04|5.20194636e-04|5.68871826e-04|6.99442756e-04|8.01558009e-04|9.02082084e-04|7.05317036e-04|6.13709079e-04|7.04141267e-04|7.79495030e-04|6.34446944e-04|6.02785733e-04|4.88566812e-04|3.41827165e-04|4.42934164e-04|4.74154089e-04|3.92026914e-04|5.35163214e-04|4.68319409e-04|5.28945306e-04|2.33644852e-04");
            double[] freqs = parse("20.|23.02790799|26.51422731|30.52835934|35.1502125|40.47179295|46.59903621|53.65391591|61.77687193|71.12960612|81.89830125|94.29732727|108.57350879|125.01103851|143.9371346|165.72855457|190.81909527|219.7082284|252.97104337|291.2696955|335.36658736|386.13954578|444.59929651|511.90958454|589.41034051|678.64435438|781.38798741|899.68653379|1035.89493585|1192.72466332|1373.29769001|1581.20864218|1820.59635598|2096.22626831|2413.58528128|2778.99098875|3199.71743921|3684.13993865|4241.90177584|4884.1061891|5623.53739595|6474.91508564|7455.18744063|8583.86852026|9883.42672265|11379.73205804|13102.57113719|15086.24012671|17370.22747503|20000.");
            int numpts = freqs.Length;
            for (var i = 0; i < 6; i++)
            {
                Console.WriteLine(">> Smooth " + i + " - " + numpts);
                double[] copy = (double[])dataIn.Clone();
                MeasCalcs.Smooth(copy, freqs, numpts, i);
                int nans = 0;
                foreach (double j in copy)
                {
                    if (Double.IsNaN(j))
                    {
                        nans++;
                    }
                }
                Console.WriteLine("Smooth " + i + " NaNs: " + nans);
            }
            System.Threading.Thread.Sleep(20000);
        }
    }

    class MeasCalcs
    {
        [DllImport("MeasCalcs.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern void Smooth(double[] dataIn, double[] freqs, int numpts, int atype);
    }
}

I realised I was using freqs.Length-1 in my code but this function already accounts for that in the definition (i.e. the arrays are declared as 0:NumPts-1 so I don't need to -1 this time). This reduces the number of NaNs but doesn't completely eliminated them, CB Moore seems particularly troubled.
 
Last edited:
Bessel & Hankel functions.

Here's an explanation of Bessel and Hankel functions for Aaron and others without formal maths experience, to provide some context and intuition about how the 3d version will work.
First topic is to expand on a comment in a previous post, about complex numbers.
The use of complex numbers in this application seems a bit mysterious at first, since no one ever measured a sound pressure level of (square root of minus 1) pascals at time (t).
It's a consequence (or artifact) of our technique of Separation of Variables.
We have separated the time variable component out, into a peak amplitude and a phase.
Turns out that complex numbers are a convenient way to handle this.
It makes some sense, a complex number has 2 components and so can represent an amplitude and a phase.
Once we identify how the amplitude and phase are represented, it all works beautifully with our normal rules of arithmetic.
In fact it works so seamlessly that even so perceptive a mathematician as R. Penrose (FRS, Wolf prize, Dirac medal etc. etc.) says it's almost miraculous.
So don't worry, after a while a complex number starts to feel like a single entity, not a pair of numbers.
We needed that topic clear because Bessel and Hankel functions can work on complex numbers, and we use that.

Next to Bessel functions, then Hankel a bit later.
Bessel functions can be formally defined as the solutions of a Differential Equation of a certain form.
It's "of a certain form" because there is a parameter, once we set that parameter then we have a specific DE and each specific equation has a whole set of solutions.
That parameter is called the Order of the Bessel function and can itself be complex.
That's not just complex, it's too complicated, let's keep it real, literally.
Mathematicians like to define and work with very abstract entities.
Then they can do one proof and it automatically applies to all the special cases.
But that's not how it was worked out, they started with simple cases and then slowly broadened the ideas, and that's the way to understand the maths.
So Bessel himself started with functions of order 1,2,3...
These are the radial solutions of a round drum-head, often shown as THE "Bessel Functions"
They are also the wave equation in cylindrical co-ordinates for a line source.
There are 2 kinds, related in a way similar to the Sine and Cosine functions.
They are usually denoted by J and Y and the order is shown with a subscript, like J1 and Y1.
They are NOT what we need!
More in the next post, so this one is not too unwieldy.

Best wishes
David
 
Last edited:
What we need are "Spherical" Bessel Functions.
These turn out to be essentially Bessel Functions of order 1/2, 3/2, ....
But when they are called "Spherical Bessel Functions" then it is usual to use a different convention to keep the subscript a nice whole number.
So the equivalence of a Spherical Bessel Function to a "normal" Bessel Function of fractional order is a bit obscured.
(There is a small normalization constant so they are not exactly "equal")
Whereas the Bessel Functions of order 1,2,.. are not quite periodic the SBF look rather familiar, as seen >HERE<.
For instance
j0 is just Sin(x) / x
and
y0 is -Cos(x) / x

Just our usual Sin and Cos with a radial decay, in our variables 1/r
How understandable is that!

Best wishes
David
 
Last edited:
added an interactive polar view which varies with the mouse position on the freq axis

polar.png

@gedlee what are the next steps on the analysis side of things? I have some rough edges in the gui code but otherwise I think I am up to date with the data analysis.
 
added an interactive polar view which varies with the mouse position on the freq axis

View attachment 693109

@gedlee what are the next steps on the analysis side of things? I have some rough edges in the gui code but otherwise I think I am up to date with the data analysis.

Now I can foresee that being very useful!
 
@Dave.

I can tell you are very versed in the field of mathematics. Low level calculus is a very distant memory for me 35 years ago. So I appreciate the time you took to write what is involved to a very limited degree.

So you are incorporating the angular and time plus SPL in one set of interrelated equations that represent those numbers and manipulating them via another set of equations? Clear as mud I know. Can you tell that this was really aimed at me??? LOL

I remember doing phaser calculations and vector calculations. All a distant memory. I have to brush up on this stuff again. Working with a program that I do not understand is not a good way to go about trying to understand the data output.

Differential calculus for dummies may be a start I guess. Then move on up to really hard stuff.

Earl I stand in awe of your memory! I was reading your papers on Bandpass enclosure designs from the 80's in the 80's. If you still got it you are doing very well.

I guess it's a case of use it or loose it. At one time I was quite an accomplished musician to. Now I fool around at it. Keep up sight reading music so that I don't completely loose it!
 
...I appreciate the time you took to write what is involved

Pleased to be able to help, I am not actually very skilled but these explanations help make it clearer in my own mind too.

one set of interrelated equations that represent those numbers...

The sound field of the speaker must satisfy the Wave Equation, which can be formulated in a rather abstract way.
But for practical calculations we need to express it in some specific coordinate form, for instance spherical coordinates (in R, theta, phi) or Cartesian coordinates (in X,Y,Z)
Those coordinate forms (and a few others) are particularly convenient, they make it easier to handle the Wave Equation because the equation (and thus the solution) can be broken into a number of simpler parts that are just multiplied.
The mathematical process to do this is called Separation of Variables.
The solution has a time variable part, theta and phi variable parts (that express the angular dependence) and the radial variable part (spherical Bessel functions discussed above).
Earl has done the work to express the measurements in terms of these components.
Once we have them then they can be shown and manipulated in various ways.
Which is what "d00d" has done his impressive work on.
But Earl's work does not cover the phi dependence so that's the next step.

Best wishes
David
 
@gedlee what are the next steps on the analysis side of things? I have some rough edges in the gui code but otherwise I think I am up to date with the data analysis.

Let me work through the smoothing issue and then we can move on. It may take me awhile as I am into another "home" project at the moment.

@Dave.

Earl I stand in awe of your memory! I was reading your papers on Bandpass enclosure designs from the 80's in the 80's. If you still got it you are doing very well.

I guess it's a case of use it or loose it. At one time I was quite an accomplished musician to. Now I fool around at it. Keep up sight reading music so that I don't completely loose it!

"Use it or lose it" is true of almost anything. I have always sought to advance my math understanding working through ever more complex levels. When I ran out of acoustic problems, I moved on to the far more complex quantum mechanics ones. I have spent the last year on Quantum Field theory and before that General Relativity. I believe that the waveguide problem could be formulated as a problem in Spatial Tensor analysis (Reiman Space akin to General Relativity), but never did work that out. I read some books on Hilbert Space and Topology. I did discover that there is a transform that when applied to the waveguide problem yields a problem/solution set in a square space. The Higher Order Modes that are so difficult in the Helmholtz equation in say Oblate Spheroid coordinates are then just the higher modes in a square space like a room. Transform back and you have all the Higher Order modes.

It is widely believed that not extending ones brain continuously as we age promotes dementia. I'd like to avoid that if at all possible!!
 
It is widely believed that not extending ones brain continuously as we age promotes dementia. I'd like to avoid that if at all possible!!

Earl most of us are demented enough already. We don't need anymore help!

@Dave Zan
Pleased to be able to help, I am not actually very skilled but these explanations help make it clearer in my own mind too.

I can tell you have it in your mind. And getting it out so that others can understand it is the hard part. Believe me I know. I work as a consultant I have to be able to explain things to people well enough that they can understand. And there are some topics that I feel very unable to do so. Higher order mathematics being chief in that category.
 
Spherical Bessel functions to Spherical Hankel functions.

OK, we have the spherical Bessel functions, of two kinds, and those kinds are related in the same way as Sin and Cos.
And there is a radial dependence.
We saw the first of the functions were basically Sin and Cos and dropped radially as 1/r
For the next we have
j1 = Sin(r) / r^2 - Cos(r) / r
and
y1 = -Cos(r) / r^2 - Sin(r) / r
and then the ones after have terms that drop off as 1/r^3 , 1/r^2 and 1/r, and so on.
So the extra terms drop off faster as the distance increases.

When we add Sin and Cos functions in different proportions in effect we alter the phase.
Similarly here we can add the Bessel functions of first and second kind to alter the phase.
It turns out to be convenient to "pre-mix" a particular combination of the two Bessel functions.
That combination is one part jn and i parts yn.
This produces a solution that corresponds to a wave that travels out from the source, whereas the individual Bessel function corresponds to a stationary wave solution.
If we use 1 - i then we have a solution that corresponds to wave that travels in to the source.
These pre-mixed combinations of (spherical) Bessel functions are called the (spherical) Hankel functions.
But the same results can be obtained from the (s.) Bessel functions because, as already pointed out, they are complex functions and we just have to use complex coefficients.

Best wishes
David
 
Hopefully we come to the point.

We have now seen the various components of the solution, and they all look kind of similar.
The time function is composed of Sin and Cos (t) and harmonics.
The angular functions are (more or less) Sin and Cos (phi) and (theta), called spherical harmonics.
And the radial function is a drop off that depends on radius times (more or less) Sin and Cos (r), called spherical Hankel functions.
Since all the components are similar to Sin and Cos that means we can do essentially a Fourier analysis not just on the time frequency (as we are all familiar) but on both of the angular dependencies, and the radial function too.
Of course we have a Nyquist limit on the time samples and a similar requirement to spatially sample the angular frequencies.
But we only plan to sample the radial variable at two points to calculate all the radial components, how can that be?:scratch2:

Turns out the spherical coordinate system is rather special.
The separation of variables of the wave equation leads to solutions expressed as multiplicative factors.
F(t,r,theta,phi) = Ft(t)Fr(r)Ftheta(theta)Fphi(phi)

And since each individual function is created as a sum of components (harmonics) we expect it to look a bit like
F(t,r,theta,phi) = ∑ functions of time ∑ functions of r ∑ functions of theta ∑ functions of phi

But if you look at Earl's earlier note you will see that the non-time summation, in spherical coordinates, is actually
∑ (functions of theta) (functions of r)
not
∑ (functions of theta) ∑ (functions of r)
So it's a little simpler and we only need 2 radial samples (the second is needed only to separate the in and out waves)
This will only work in three co-ordinate systems, whereas separation of variables is possible in more.
At least, that's if I correctly understand a letter by Putland in the JAES that is related to this.

Best wishes
David
 
The angular functions are (more or less) Sin and Cos (phi) and (theta), called spherical harmonics.
Since all the components are similar to Sin and Cos that means we can do essentially a Fourier analysis not just on the time frequency (as we are all familiar) but on both of the angular dependencies, and the radial function too.
This is not quite correct. The phi angles can be Fourier Transformed as they ARE simply sine and Cosine, but the theta angles are not. They are Legendre polynomials and not pure sine and cosine.
This will only work in three co-ordinate systems, whereas separation of variables is possible in more.
At least, that's if I correctly understand a letter by Putland in the JAES that is related to this.

Best wishes
David

I don't understand this or why anything about the Putland discussion is relevant here. The separation of incoming from outgoing can be done in 2D as well, but only if the source is ationary and the mic rotates.