Algorithm for testing frequency sweep parameters by using single-frequency signal combinationTechnical Field
The invention relates to an acoustic testing method, in particular to an algorithm for testing frequency sweep parameters by using single-frequency signal combination.
Background
The measurement of the early frequency characteristics is achieved by a point-by-point mapping method. In the whole measurement process, the amplitude of a signal input to the measured network is kept unchanged, correspondingly output voltages under different frequencies are recorded, and an amplitude-frequency characteristic curve of the network can be drawn on coordinate paper according to obtained data. Obviously, this method is not only cumbersome and time consuming, but also may miss some details on the measured curve due to the insufficiently dense measurement frequency intervals, making the resulting curve less accurate.
In the sweep measurement method, a constant-amplitude sweep signal is added to the input end of a tested circuit, and then an oscilloscope is used for displaying the change of the amplitude of the signal after the signal passes through the tested circuit. Because the frequency of the sweep frequency signal is continuously changed, the amplitude-frequency characteristic of the tested circuit can be directly displayed on the screen of the oscilloscope.
In summary, the existing frequency characteristic test has the following disadvantages: 1. the length of the frequency sweeping signal of the full frequency band is too long; 2. the common single-frequency set is not beneficial to calculation and has longer time; 3. the test does not conform to the hearing habits of the human ear.
Disclosure of Invention
The invention provides an algorithm for testing frequency sweep parameters by using a single-frequency signal combination, which solves the technical problems that the too long time of frequency characteristic testing in the related technology is not beneficial to calculation and the testing does not conform to human auditory sense.
According to one aspect of the present invention, there is provided an algorithm for testing sweep frequency parameters using a single frequency signal combination, comprising the steps of:
s100, generating a sweep frequency signal of a single-frequency signal combination for output;
s200, after the played sweep frequency signal is acquired, dividing the sweep frequency signal by contrasting the generated single-frequency signal combination, and calculating the divided signal in a single-frequency signal mode;
and S300, displaying the calculated acoustic parameters of each single-frequency signal on an xy two-dimensional coordinate graph with the frequency point as an x axis to obtain a result of testing the frequency sweeping parameters.
By adopting the technical scheme, the frequency sweep signal of the single-frequency signal combination is generated for outputting, the same segmentation signal is calculated in a single-frequency signal mode, and the expected frequency sweep signal is set by inputting the preset data, so that the technical problems that the existing frequency characteristic test full-frequency band frequency sweep signal is too long in time, a common single-frequency set is not beneficial to calculation and is very long in time, and the test does not accord with the hearing habit of human ears are solved.
According to another aspect of the present invention, there is provided a system for testing sweep frequency parameters using a single frequency signal combination, comprising:
an input unit for inputting preset data;
the processing unit receives preset data input by the input unit and processes the preset data to obtain a coefficient table;
sending the coefficient table obtained by processing to a variable filter unit and a display unit;
the display unit is used for displaying and processing the coefficient table;
a variable filter unit having n-1 filters, setting parameters of the filters being determined by filter parameters in the coefficient table; the circuit is used for sending the frequency sweeping signal to an output amplifier and outputting the frequency sweeping signal to the circuit;
the back-extraction unit is used for acquiring the signals output by the circuit and sending the signals to the graphic processor;
and the graphic processor is used for processing the signals output by the circuit to obtain acoustic parameters and displaying the acoustic parameters on an xy two-dimensional coordinate graph with the frequency point as an x axis.
Further, the preset data comprises a plurality of groups of frequencies and gains; the user sets the desired swept frequency signal by inputting gain data at a particular frequency point.
Further, the method for processing the coefficient table by the processing unit comprises the following steps:
s1, receiving preset data input by the input unit, and calculating an output waveform amplitude spectrum of a filter;
s2, calculating a synthesis characteristic of the full frequency band of the filter for obtaining the output waveform amplitude spectrum in the step S1, thereby obtaining a synthesis characteristic of n-1 filters, and calculating an error value of the synthesis characteristic of each of the n-1 filters and preset data, so as to obtain an error of the frequency band corresponding to each filter;
s3, determining the types of n-1 filters, including whether three gains of preset data corresponding to three frequency points of a frequency band corresponding to the filters meet preset conditions or not, and determining the filter type as a notch filter if the preset conditions are met; if the preset condition is not met, determining the filter type as a peak filter;
the preset conditions are as follows: the absolute value of the maximum value in all gains in the preset data is smaller than the absolute value of the minimum value or the absolute value of the maximum value and the minimum value are both negative values;
s4, correcting the center frequency of the filter of the notch filter type in n-1 filters, calculating the frequency with the maximum difference value with the preset data in the synthesis characteristic of the filter, judging whether the result of subtracting the center frequency of the filter is a positive value or a negative value, and if the result is the positive value, subtracting a preset correction value from the center frequency of the filter to obtain the corrected center frequency;
if the value is negative, adding a preset correction value to the center frequency of the filter to obtain a corrected center frequency;
s5, correcting the center frequency of the filter of the peak filter type in n-1 filters, calculating the frequency with the maximum difference value with the preset data in the synthesis characteristic of the filter, judging whether the result of subtracting the center frequency of the filter is a positive value or a negative value, and if the result is the positive value, adding a preset correction value to the center frequency of the filter to obtain the corrected center frequency;
if the value is negative, subtracting a preset correction value from the center frequency of the filter to obtain a corrected center frequency;
s6, calculating filter parameters of all filters of n-1 filters, including calculating peak factors of the filters through the correction center frequency of the filters and the bandwidth of the corresponding frequency band, and taking the gain corresponding to the frequency in the preset data with the same frequency of the middle frequency point of the frequency band corresponding to the filters as the filter gain of the filters; taking the corrected center frequency, the peak factor and the filter gain as filter coefficients;
and recording the filter parameters of all the filters of the n-1 filters obtained by calculation to obtain a coefficient table.
Further, the step S1 of receiving the preset data input by the input unit, and calculating the output waveform amplitude spectrum of a filter includes the following steps:
s111, judging whether all gains in preset data meet preset conditions or not; the preset conditions are as follows: the absolute value of the maximum value in all gains in the preset data is smaller than the absolute value of the minimum value or the absolute value of the maximum value and the minimum value are both negative values;
s112, if the requirement is met, the filter type is determined to be a notch filter, the center frequency is determined to be the frequency with the maximum value, and the filter gain is determined to be the maximum value in all gains of the preset data;
s113, if the data do not meet the requirement, determining the filter type to be a peak filter, determining the center frequency to be the frequency of taking the minimum value, and determining the gain of the filter to be the minimum value in all gains of the preset data;
s114, calculating the difference value between the maximum value and the minimum value in all gains in the preset data as a gain difference;
s115, judging whether the gain difference is less than 3 db;
s116, if the gain difference is larger than 3db, taking the difference between the maximum value and the minimum value of all frequencies in the preset data as a temporary bandwidth; calculating a crest factor of the filter using the center frequency and the temporary bandwidth;
s117, if the gain difference is less than 3db, setting the crest factor to a predetermined value without calculating the crest factor;
and S118, calculating an output waveform amplitude spectrum of the filter through the center frequency, the crest factor and the filter gain.
Further, the predetermined value in the step S117 is 0.25 or 0.5.
Furthermore, the n-1 filters correspond to a frequency range, the frequency range is divided into a plurality of frequency bands, each frequency band comprises three frequency points of preset data, each frequency band corresponds to one filter of the n-1 filters, and an error value of a synthetic characteristic of the filter of each frequency band and the preset data is calculated to obtain an error of each frequency band.
Further, the correction amount in steps S4 and S5 is 0.08 times the bandwidth of the error band of the frequency band corresponding to the filter.
The invention has the beneficial effects that:
firstly, shortening the time length of a sweep signal to shorten the test time length and simultaneously ensure that a frequency band can be covered;
secondly, smooth transition from low frequency to high frequency according with the hearing habits of human ears;
thirdly, ensuring that the interference of other frequency bands is avoided; to ensure the test stability.
Drawings
Fig. 1 is a flowchart of an algorithm for testing sweep parameters using a single frequency signal combination according to an embodiment of the present invention;
FIG. 2 is a block diagram of a system for testing frequency sweep parameters using single frequency signal combinations in accordance with an embodiment of the present invention;
FIG. 3 is a flow diagram of a method for a processing unit to process a derived coefficient table according to an embodiment of the invention;
FIG. 4 is a flow chart of the calculation of the output waveform amplitude spectrum of a filter according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an implementation of an algorithm for testing sweep parameters by using a single-frequency signal combination according to an embodiment of the present invention.
Detailed Description
The subject matter described herein will now be discussed with reference to example embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and thereby implement the subject matter described herein, and are not intended to limit the scope, applicability, or examples set forth in the claims. Changes may be made in the function and arrangement of elements discussed without departing from the scope of the disclosure. Various examples may omit, substitute, or add various procedures or components as needed. For example, the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. In addition, features described with respect to some examples may also be combined in other examples.
In this embodiment, an algorithm for testing sweep frequency parameters by using a single frequency signal combination is provided, as shown in fig. 1 and 5, a flowchart according to the present invention is shown, as shown in fig. 1 and 5, and the method includes: s100, generating a sweep frequency signal of a single-frequency signal combination for output; generating a sinusoidal single-frequency signal of y ═ Asin (ω x + φ), decomposing the signal of the whole frequency band into a plurality of sinusoidal single-frequency signals of y ═ Asin (ω x + φ) according to the decomposition of an octave, setting the maximum duration 10s and the minimum period 10T according to T ═ 1/f under the condition of setting the sampling rate, and adjusting the period or duration of the generated single-frequency signals to ensure that the duration of frequency sweeping signals and the test stability achieve the effect of relative balance;
s200, after the played sweep frequency signal is acquired, dividing the sweep frequency signal by contrasting the generated single-frequency signal combination, and calculating the divided signal in a single-frequency signal mode; after data are acquired through back mining, dividing the data according to the number of the data by contrasting the generated single-frequency signal combination according to a one-to-one correspondence principle, and then independently calculating each single-frequency signal;
and S300, displaying the calculated acoustic parameters of each single-frequency signal on an xy two-dimensional coordinate graph with the frequency point as an x axis to obtain a result of testing the frequency sweeping parameters.
The algorithm of this embodiment can be implemented by various forms of systems, and as shown in fig. 2, this embodiment provides a system for testing sweep parameters by using a single-frequency signal combination, including:
aninput unit 1 for inputting preset data, optionally but not limited to: a keyboard, a touch screen;
the preset data comprises a plurality of groups of frequencies (Hz) and gains (db); a user sets a desired frequency sweep signal by inputting gain data at a specific frequency point;
the processing unit 2 receives the preset data input by theinput unit 1 and processes the preset data to obtain a coefficient table;
and sends the coefficient table obtained by the processing to thevariable filter unit 4 and thedisplay unit 5;
adisplay unit 5 for displaying the processed coefficient table;
avariable filter unit 4 having n-1 filters, setting parameters of each filter including a center frequency (f0), a filter crest factor (Q), and a filter gain (G), the setting parameters of the filter being determined by filter parameters in a coefficient table;
thevariable filter unit 4 sends the sweep frequency signal to theoutput amplifier 6 and outputs the sweep frequency signal to the circuit;
theextraction unit 7 is used for collecting the signals output by the circuit and sending the signals to thegraphic processor 8;
and thegraphic processor 8 is used for processing the signals output by the circuit to obtain acoustic parameters and displaying the acoustic parameters on an xy two-dimensional coordinate graph with the frequency point as an x axis.
As shown in fig. 3, the method for processing the coefficient table by the processing unit 2 includes the following steps:
s1, receiving preset data input by theinput unit 1, and calculating an output waveform amplitude spectrum of a filter;
as shown in fig. 4, step S1 specifically includes the following steps: s111, judging whether all gains in preset data meet preset conditions or not; the preset conditions are as follows: the absolute value of the maximum value in all gains in the preset data is smaller than the absolute value of the minimum value or the absolute value of the maximum value and the minimum value are both negative values; (the gain of the preset data may be a positive value or a negative value)
S112, if the requirement is met, the filter type is determined to be a notch filter, the center frequency is determined to be the frequency with the maximum value, and the filter gain is determined to be the maximum value in all gains of the preset data;
s113, if the data do not meet the requirement, determining the filter type to be a peak filter, determining the center frequency to be the frequency of taking the minimum value, and determining the gain of the filter to be the minimum value in all gains of the preset data;
s114, calculating the difference value between the maximum value and the minimum value in all gains in the preset data as a gain difference; for example, the maximum value of all gains of the preset data is +9dB, the minimum value is +4dB, the filter type is a peak filter, and the gain difference is 5.
S115, judging whether the gain difference is less than 3 db;
s116, if the gain difference is larger than 3db, taking the difference between the maximum value and the minimum value of all frequencies in the preset data as a temporary bandwidth; calculating a crest factor of the filter using the center frequency and the temporary bandwidth;
s117, if the gain difference is less than 3db, setting the peak factor to a predetermined value without calculating the peak factor (peak factor Q is 0.25 or 0.5);
s118, calculating an output waveform amplitude spectrum of the filter through the center frequency, the peak factor and the filter gain; the output waveform amplitude spectrum of the filter can be converted into a frequency-gain table and stored in a preset table;
correspondingly obtaining the gain of the frequency in the preset data by the output waveform amplitude spectrum of the filter;
s2, calculating the synthesis characteristic of the full frequency band (20Hz to 20000Hz) of the filter which obtains the output waveform amplitude spectrum in the step S1, thereby obtaining the synthesis characteristics of other n-1 filters, and calculating the error value of the synthesis characteristic of each filter in the n-1 filters and preset data, so as to obtain the error of the frequency band corresponding to each filter;
dividing a frequency range to be set into a plurality of frequency bands, wherein each frequency band comprises three frequency points of preset data, each frequency band corresponds to one filter, and calculating the synthetic characteristic of the filter of each frequency band and the error value of the preset data to obtain the error of each frequency band; for example, a band is composed of 70Hz-130Hz-230Hz, the synthetic characteristics are 70Hz-3db, 130Hz-5db, 230Hz-7db, the preset data are 70Hz-4db, 130Hz-6db, 230Hz-8db, and the error of the band is the sum of the differences of 4db-3db, 6db-5db, 8db-7db, namely 3. Of course the error may also be negative.
And the large error of the evaluation only in frequency points is reduced by evaluating in each frequency band.
S3, determining the types of n-1 filters, including whether three gains of preset data corresponding to three frequency points of a frequency band corresponding to the filters meet preset conditions or not, and determining the filter type as a notch filter if the preset conditions are met; if the preset condition is not met, determining the filter type as a peak filter;
the preset conditions are as follows: the absolute value of the maximum value in all gains in the preset data is smaller than the absolute value of the minimum value or the absolute value of the maximum value and the minimum value are both negative values;
s4, correcting the center frequency of the filter of the notch filter type in n-1 filters, calculating the frequency with the maximum difference value with the preset data in the synthesis characteristic of the filter, judging whether the result of subtracting the center frequency of the filter is a positive value or a negative value, and if the result is the positive value, subtracting a preset correction value from the center frequency of the filter to obtain the corrected center frequency;
if the value is negative, adding a preset correction value to the center frequency of the filter to obtain a corrected center frequency;
s5, correcting the center frequency of the filter of the peak filter type in n-1 filters, calculating the frequency with the maximum difference value with the preset data in the synthesis characteristic of the filter, judging whether the result of subtracting the center frequency of the filter is a positive value or a negative value, and if the result is the positive value, adding a preset correction value to the center frequency of the filter to obtain the corrected center frequency;
if the value is negative, subtracting a preset correction value from the center frequency of the filter to obtain a corrected center frequency;
s6, calculating filter parameters of all filters of n-1 filters, including calculating peak factors of the filters through the correction center frequency of the filters and the bandwidth of the corresponding frequency band, and taking the gain corresponding to the frequency in the preset data with the same frequency of the middle frequency point of the frequency band corresponding to the filters as the filter gain of the filters; taking the corrected center frequency, the peak factor and the filter gain as filter coefficients;
recording the filter parameters of all the filters of the n-1 filters obtained by calculation to obtain a coefficient table;
the correction value is the bandwidth of the error frequency band of the frequency band corresponding to the filter, namely 0.08;
according to the method, the expected frequency sweep signal is set by inputting the preset data, the interference of redundant frequency bands is reduced, and the duration of the frequency sweep signal is shortened by adjusting the frequency sweep signal; the low-frequency to high-frequency smooth transition which accords with the auditory habits of human ears can be tested through the setting of the preset data, namely the low-frequency band and the high-frequency band of the sweep frequency signal can be adjusted according with the auditory habits of human ears.