1. Field of the Invention
Embodiments of the present invention generally relate to a method and apparatus for loudspeaker cutoff detection.
2. Background of the Invention
For applications such as room equalization, loudspeaker equalization and bass management, it is sometimes necessary to measure the frequency response of the loudspeakers. If the low-frequency cutoff of the loudspeakers can be determined, this information can be used to effectively apply bass management, i.e. remove poorly reproduced frequencies and route them to a better loudspeaker such as a subwoofer. However the measured spectrum of a loudspeaker usually contains irregularities caused by reflections and noise, making cutoff detection difficult.
Therefore, there is a need for an improved loudspeaker cutoff detection method and apparatus.
Embodiments of the present invention relate to a method and apparatus for enhancing cutoff detection of a loudspeaker. The method comprising retrieving a loudspeaker model cutoff and model error, generating a probability distribution of the cutoff frequency based on the retrieved models, and utilizing the generated probability distribution to enhance the detection of the cutoff of the loudspeaker.
So that the manner in which the above recited features of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to embodiments, some of which are illustrated in the appended drawings. It is to be noted, however, that the appended drawings illustrate only typical embodiments of this invention and are therefore not to be considered limiting of its scope, for the invention may admit to other equally effective embodiments. In this application, a computer readable processor is any medium accessible by a computer for saving, writing, archiving, executing and/or accessing data. Furthermore, the method described herein may be coupled to a processing unit, wherein said processing unit is capable of performing the method.
Bass management refers to routing the low frequency part of the signal to the most effective transducer, typically a subwoofer. Thus, the upper cutoff frequency of the subwoofer and lower cutoff frequencies of the other loudspeakers are usually known. If a subwoofer is not available, a technique, such as bass-boost (creates the sensation of more bass) may be applied. Such technique may be utilized when the loudspeaker cutoff is known to be too high. For these and other applications, it is useful to be able to estimate the lower cutoff frequency of regular loudspeakers.
The measurement may be the same as loudspeaker equalization. Loudspeaker equalization refers to filters applied to a signal which are designed to compensate for the loudspeaker response. Generally, a known test signal is applied to the loudspeaker. The output is picked up by a microphone with a known frequency response. The unknown system, such as, amplifier, loud-speaker, environment, may be tested by applying a known test signal and recording the output. The frequency response may be derived using standard techniques. This measured frequency response, used primarily to design equalization filters, in principle may be used for several addition purposes including distance detection, polarity detection and cutoff detection. However, the spectrum of the measured system is typically not smooth, as shown in
The basic approach of this method is to generate a probability distribution of the cutoff frequency based on a model of loudspeaker cutoff and a Gaussian model of error. The error is the difference between the model and measurement. The error is caused by several factors, such as, background noise, measurement error, and room and speaker reflections. Such error may effect choosing the wrong model function.
The background noise and measurement error are likely to be approximately Gaussian. However, assuming the loudspeaker model is accurate, the largest source of error is usually the room and speaker reflections, which are generally non-Gaussian. Using a Gaussian error model may lead to relatively straight forward mathematical formulations.
After the loudspeaker model and error model are set, a probability distribution for the cutoff frequency remains, which may also require utilizing cutoff frequency as one of the parameters, applying Bayes' Theorem and eliminating the other “nuisance” parameters. Finally, this distribution can be analyzed and action taken based on the result.
A closed-box loudspeaker system model is
where QTC is the total Q of the system at fC, with fC being the resonance frequency of closed-box system, and TC is the time constant 1/2πfC. The frequency response of this model is
and the magnitude response is
Now the cutoff frequency ωc is defined as the point at which
Using this constraint and solving for TC/QTC we have
Substituting (7) into (3) gives
eliminating the QTC parameter and introducing the cutoff ωc as a new parameter.
Equation (8) takes two parameters, TC and ωc, and one variable ω which represents a frequency. Since the data is taken at discrete bin frequencies, we will usually index this variable with k as ωk to mean the frequency at the kth bin which can be interpreted in Hz depending on sampling rate and FFT size. To remain neutral during calculation frequency is measured in bins, i.e. ωk=k. However in this paper the sampling rate is always 48 kHz and the FFT size is always 32,768 giving a conversion factor of ≈1.46475 Hz per bin. It is also convenient to write the cutoff frequency ωc on the same scale so that ωc=ωk when c=k. However c need not be restricted to be an integer.
The TC parameter determines the shape of the model frequency response once ωc is fixed. However the effect of TC depends on ωc. For instance a given value of TC may make the frequency response peaky for some an and very flat for other ωc. This is due to the fact that scaling ωc and ω by the same amount α in (8) gives
However making the substitution u−ωcTC in (8) gives
so that after scaling ω and ωc by α it becomes the case that
and the shape is persevered.
Note that u should be constrained to physically realizable values derived from the constraint TC/QTC≧0 from (7). We also have from (7) that
so completing the square we have
w
c
4
T
C
4+2ωc2TC2+1≧1 (14)
and
(wc2TC2+1)2≧2. (15)
Thus
ωc2TC2+1≧√{square root over (2)} (16)
and finally
u=ω
c
T
C
≧√{square root over (√{square root over (2)}−1)}≈0.643594252905582742. (17)
Thus, u cannot be less than the critical value ≈0.6436.
Another important value of u is that which makes the frequency response maximally flat. A flat response is often a goal in loudspeaker design, so the value of u that achieves this will likely be a good value for a loudspeaker model.
The maxiflat value of u can be found by plugging the denominator of (1) into the quadratic formula and making the discriminant 0 as follows:
Equation (10) may need to be scaled by an amplitude A in order to best fit the data. This is important since generally the amplitude of the data is unknown. Thus we can define our basic model to be
Substituting (22) into (23) gives
as a maxiflat loudspeaker model depending only on parameters of amplitude A and cutoff frequency ωc.
By error we mean the difference between the model and the measured value. For this error, a gaussian model is assumed. Letting D represent our data, which is the squared magnitude of a measured loudspeaker spectrum X, letting dk represent the data at frequency bin index k, i.e. dk=|X[k]|2, letting mk, A, u and ωc represent the model and parameters used in (23) and letting I represent our models for loudspeakers and error, the likelihood for a particular set of parameters can be expressed as
where σk is the standard deviation of the noise at index k. Here the “noise” is really the error at each frequency bin which can be frequency dependent. These σk can be treated as a set of additional parameters, but for now we will assume these are known since doing so doesn't affect the rest of the derivations. The σk can be thought of as a weighting on the frequency, a smaller σk value indicates more certainty about the dk value and thus the error at that frequency counts more. As a frequency weighting, these σk can also be modified to force the algorithm to weigh some frequencies more than others. Conversely, if there is no reason to emphasize the contribution at any frequency, all σk can be set to the same value.
Equation (25) is called the likelihood of the parameters, since the data is fixed and the parameters can vary. It can be interpreted as saying that the probability of the data given the loudspeaker model, gaussian noise model, and a set of model parameters is just the product of the independent probability densities that gaussian noise makes up the difference between the model with those parameters and the data. The parameter values which maximize the probablity of the data are those that minimize the sum of the squared differences with the data, and are known as the least squares solution.
Bayes' Theorem follows directly from the definition of conditional probability as follows:
where A and B can be basically any statements for which conditional probability makes sense. Applying (26) to (25) gives
Thus, in addition to the likelihood P(D|A, u, ωc, I) given by (25), we need a prior probability P(A, u, ωc|I) and a normalizing term P(D|I) in order to get our posterior probability P(A, u, ωc|D, I). However another step is then to eliminate the “nuisance” parameters A and u to give the posterior probability of the cutoff frequency P(wc|D, I). The elimination of A as a “nuisance” parameter can be achieved by exact marginalization.
Let {θ} be a set of parameters, A be a scale (amplitude) parameter, dk be the kth data value and mk be the model value at index k with parameters {θ}. Then using the gaussian error model we have
Note that parameter A appears as a scale term outside of the model itself, which only takes parameters {θ}. Then we have
From Bayes' Theorem we have
with the integration ranges and prior probabilities appropriately chosen for the parameters. We would like to marginalize A.
So, if we choose a flat prior for P(A|I) and a range of (−∞, ∞) we have
Thus, the marginalization leaves a new equation for the likelihood of the parameters as follows:
where mk is short for the model mk(u, ωc).
Since there are only two remaining parameters, this can be shown in a 2-dimensional graph. For the spectrum shown in
Exact marginalization over u looks very difficult and numerically integrating over u also seems computationally expensive. However u doesn't affect the shape of the speaker rolloff very much beyond some low values which cause a large resonance in the model spectrum, as indicated by
In this example we have
The prior P(ωc|I) can be thought of as a weighting based on our belief about what likely values of ωc should be. This can be flat over a reasonable range, or have some proprietary shape based on many loudspeaker evaluations. It is also useful to make the prior P(ωc|I) discrete with the same set of frequencies bins used for the data. Thus the prior can state P(ωc|I)=0 if c≠k for all frequency bin indexes k, effectively sampling the continuous probability density at some subset of frequency bins. Since the same prior is built into the normalizing denominator, this is a way to move from a continuous distribution to a discrete one defined only at bin frequencies.
A high level implementation of this method is shown in
For implementation it is useful to take the log of (29) which gives
which can be considered as
Since log(x) is a monotonically increasing function of x and the constant term doesn't affect the location of the maximum value, one approach is just to find the ωc which maximizes (31), ignoring the constant term. If a uniform probability is assumed for the prior probability P(ωc|I), then this term can be left out as well.
A block diagram of this implementation is given in
If the results are stored for further processing, it is often desirable to convert the values to a probability distribution summing to 1. A way of doing this is shown in
Although any loudspeaker model function can be used in principle, an implementation of the loudspeaker model is given by (23).
While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.