Embodiment
Below will be described in detail a specific embodiment of the present invention with reference to the accompanying drawings.
Fig. 1 illustrates according to beat pick-up unit of the present invention.
In this BPM pick-up unit, simulated audio signal at first is imported in the A/D converter 1.Like this, by A/D converter 1, the simulated audio signal of input just is converted into digital audio and video signals.By the digital audio and video signals that transformed as each BPM detecting device 101,102 ..., the input of 10n.
Fig. 1 illustrates all elements of BPM detecting device 101.Since all BPM detecting devices 101,102 ..., the difference between the 10n only is the parameter difference of its bandpass filter separately, therefore only is shown specifically BPM detecting device 101.
As can be seen from Figure 1, BPM detecting device 101 comprises 3, one timers 4 of 2, one transient detecting devices of a bandpass filter and one-period detecting device 5.Bandpass filter 2 links to each other with A/D converter 1, receives the digital audio and video signals of input.Bandpass filter 2 is designed to a wave filter (high Q) that bandwidth is very little.The centre frequency of bandpass filter 2 is specific frequencies, as 80Hz.For different BPM detecting devices 101,102 ..., 10n, each BP wave filter only is set to a centre frequency.The different center frequency that each BP wave filter in the different BPM detecting devices is set to preferably within the scope of the very high frequency in can the frequency spectrum of audible sound and low frequency, typically is used to monitor musical rhythm instrument, as steps on cymbals and bass drum.
The output terminal of bandpass filter 2 links to each other with transient detecting device 3.The digital signal through filtering that obtains from bandpass filter 2 is imported into transient detecting device 3 and is analyzed by transient detecting device 3.
Fig. 2 is the structured flowchart of transient detecting device.
As can be seen from Figure 2, transient detecting device 3 comprises window integrator 201, threshold circuit 202, switch 203, timer 205 and local maximum value detector 204.Window integrator 201 receives the digital signal through filtering that obtains from bandpass filter 2.With reference to Fig. 3 the detailed process process of this digital signal is described below.
Fig. 3 illustrates according to window integrator of the present invention.
Integrator 201 comprises a multiplier 301, and it is used to receive the supplied with digital signal from bandpass filter 2 outputs.As can be seen from Figure 3, the digital signal of output is at first carried out involution in multiplier 301 from bandpass filter 2.The output terminal of multiplier 301 links to each other with totalizer 304 with delayer 302.The output of multiplier 301 is at first given delayer 302 and is delayed a tw length.Tw length is exactly the length of window integrator.The output terminal of delayer 302 links to each other with multiplier 303.
Like this, the digital signal that has been delayed of delayer 302 output is multiplied by " 1 ", and the output terminal of multiplier 303 links to each other with totalizer 304.As can be seen from Figure 3, the input signal of the output signal of multiplier 303 and delayer 302 is by totalizer 304 additions, and the result of addition delivers to the input end of delay element 305 subsequently in the totalizer 304.
The output terminal of delay element 305 links to each other with input end, constant multiplier 306 and the threshold circuit 202 of totalizer 304 respectively.Like this, the output of delayer 302 is being multiplied by " 1 " back and the input of delayer 302 and output addition of delay element 305, obtains a width and be tw, is used for measuring the rectangular integration window of the average energy value of a frequency range.
Then, the output of delay element 305 and constant factor " C " multiply each other, and that is to say, measured energy value can be adjusted by constant factor " C ".The output terminal of constant multiplier 306 links to each other with switch 203.Like this, the output of constant multiplier 306 is sent to switch 203.In the present embodiment, switch 203 is gate circuits.But the present invention is not limited to this.
Timer 4 gauge tap 203 make it in the time interval of a ts closure once.Export in the constant time period of ts by the tested energy value that constant factor " C " is adjusted.When gate circuit was closed, tested energy value was sent to local maximum value detector 204.
Timer 4 also links to each other with timer 205.Constantly increase the value of timer 205 every ts timer 4, this value will be used in local maximum value detector 204.
Fig. 4 is illustrated in and postpones length and the time relationship between the constant time interval.
The digital signal of output has postponed time span tw by delayer 302 from multiplier 301.Timer 4 produces constant time period t s.In order to make the crossover that produces between the integration window as shown in Figure 4, constant time period t s need be selected shortlyer than postponing length tw.For example, in the present embodiment, constant time ts=0.5* length time delay tw.
Fig. 5 illustrates according to threshold circuit of the present invention.
In order to monitor the averaged energy levels in the frequency band, used the standard peak holding circuit to produce signal threshold value.This threshold circuit 202 comprises comparer 501, delayer 502, constant multiplier 503, delayer 504 and constant multiplier 505.The as can be seen from Figure 5 output of delayer 504 and constant factor C
RelMultiply each other, be imported into again in the comparer 501.In comparer 501, the C of the multiplication by constants factor again after the output from delayer 504
RelEnergy value compare with the tested energy value that from window integrator 201, obtains.Wherein bigger value is sent in the above-mentioned delayer 504, and this value is delayed device 502 delay 5*ts time spans simultaneously.By constant multiplier 503, the output of delayer 502 and constant factor C multiply each other and are sent to local maximum value detector 204.
After the output that Fig. 5 illustrates comparer 501 had been delayed 5*ts, its value multiply by the constant factor C less than 1.0 again.But the time span that postpones is not limited to above-mentioned time span.Only otherwise exceed scope of the present invention, this time span can be modified.
Fig. 6 illustrates the peaked process that is used to detect tested energy value.
With reference to Fig. 6, the output that is divided into different time sections of window integrator 201 is sent in the lag line 601.Lag line 601 comprises 10 delayers 611,612 ..., 620.The energy value of the 5th delayer 615 outputs is known as X (n).Preceding 5 and back 5 tested energy values are known as X (n-5), X (n-4), X (n-3), X (n-2), X (n-1), X (n+1), X (n+2), X (n+3), X (n+4) and X (n+5).Suppose that X (n) is local maximum energy value.
With reference to Fig. 6, in step S61, check tested energy value X (n) at 11 energy value X (n-5), X (n-4) ..., whether be maximal value among the X (n+5).If tested on inspection energy value X (n) is a maximal value in these 11 energy values, then flow process enters step S62.But, if on inspection from delayer 615 the energy value X (n) of output be not maximal value in these 11 energy values, flow process finishes at step S61.
In step S62, check whether energy value X (n) has surpassed the threshold value of threshold circuit output.Detect for fear of under the situation that does not have sound signal to exist, carrying out BPM, will check also whether energy value X (n) is lower than the least energy standard MinLevel of regulation.If energy value X (n) is bigger and bigger than the minimum energy value MinLevel of regulation than threshold value, then flow process enters step S63.Otherwise flow process finishes at S62.
In step S63, two of energy value X (n) front and two tested energy values of back need to satisfy two conditions equally:
X(n-2)<X(n-1)&X(n+1)>X(n+2) (1)
Wherein X (n-2) is the energy value of the output of delayer 613, and X (n-1) is the energy value of delayer 614 outputs, and wherein X (n+1) is the energy value of delayer 616 outputs, and wherein X (n+2) is the energy value of delayer 617 outputs.
In step S63, check whether energy value X (n-1) surpasses energy value X (n-2), and whether energy value X (n+1) surpasses energy value X (n+2).If satisfy the condition of formula (1) definition on inspection in step S63, then flow process enters step S64.Otherwise flow process finishes at step S63.
Native system be for possible maximal value be that the measurement of the BPM value of 158BPM designs.But consider that some percussion instrument in the music signal may produce the transient that is equivalent to 2 times of actual BPM values or 4 times, the minimum interval between two detected transient event should be no less than 90ms.
Therefore, we suppose minimum interval tmin=90ms of the present invention.
In step S64, the value of timer 205 is compared with minimum time value tmin.If on inspection, the value of timer 205 is littler than minimum time value tmin, and then flow process finishes at step S64.Like this, all the local maximal values that produce in time period in tmin that obtain from the transient that is detected previously are left in the basket and disregard.But if the value of timer 205 is bigger than minimum time value tmin on inspection, then flow process enters step S65.
In step S65, to the 3rd, the 4, the energy value of the 6th, the 7 delayer 613,614,616,617 outputs carries out linear attenuation to be handled.Time value Δ t can be handled by this linear attenuation and go to determine.The detailed process process of this linear attenuation describes with reference to figure 7.Then, flow process enters step S66.
In step S66, the time value Δ t that is calculated and the value addition of timer 205.Like this, tested time period t p equates with the value of timer and the time value Δ t sum that is calculated.Afterwards, the time value of tested timer 205 is sent to cycle detection device 5.Then, timer 205 is reinitialized Δ t.
Because be to detect local peaked existence in time period of ts in length only, clearly, the precision of local maximum value position only can be confirmed as ± 0.5*ts (because timer increases with ts in each step).For obtaining the more accurate position of local maximal value, use preceding two and latter two tested energy value of delayer 615 to calculate one 4 linear decay.
Fig. 7 illustrates the process flow diagram that tested energy value in several delayers is carried out linear attenuation.
With reference to Fig. 7, the X-axis express time, Y-axis is represented energy value.As can be seen from Figure 7, two measured value X (n-2) link to each other by straight line with X (n+2) with two measured value X (n+1) with X (n-1).Like this, the intersection point of these two straight lines is just represented local peaked accurate location:
Δt=[5*X(n+1)-4*X(n+2)+X(n-1)-2*X(n-2)]/[X(n-1)-X(n-2)-X(n+2)+X(n+1)] (2)
Fig. 8 illustrates the operational flow diagram of cycle detection device.
With reference to Fig. 8, flow process starts from step S801.At first, in step S801, utilize the tested time interval tp of following formula to be converted into a BPM value earlier:
BPMnew=60/tp (3)
Wherein BPMnew is a new BPM value of determining, tp is the tested time interval of exporting from local maximum value detector.
Suppose that the tested time interval can obtain from a beat, this beat is 1/2,1/4 or 2 times of actual BPM value of detected melody.In view of the BPM detecting device only is used to determine the value of BPM 60 in the scope of 158BPM, so suppose that the BPM value that is below or above this scope is likely the multiple of the BPM value of reality.Based on this reason, for the value that makes BPMnew falls into desirable scope, according to the BPMnew value, the new BPM value BPMnew that determines multiply by the factor 2,4, or 0.5.
Afterwards, flow process enters step S802.In step S802, check whether the new BPM value BPMnew that determines is lower than 60BPM.If it is lower than 60BPM, then flow process enters step S803, otherwise flow process enters step S804.
In step S803, utilize following formula, the new BPM value of determining is doubled:
BPMnew=2*BPMnew (4)
Then, flow process enters step S804.In step S804, check once more whether the new BPM value BPMnew that determines is lower than 60BPM.If it is lower than 60BPM, flow process enters step S805, otherwise flow process enters step S806.
In step S805, the BPM value BPMnew that utilizes formula (4) newly to determine is doubled.Then, flow process enters step S806.
In step S806, check that whether the new BPM value BPMnew that determines is greater than 158BPM.If it is greater than 158BPM, then flow process enters step S807, otherwise flow process enters step S808.
In step S807, utilize following formula, the new BPM value BPMnew that determines is halved:
BPMnew=0.5*BPMnew (5)
Then, flow process enters step S808.In step S808, utilize following formula, can obtain the mean value BPMavr that the BPM value is surveyed in the front:
BPMavr=SUM/NUMBER (6)
Wherein BPMavr is the mean value that the BPM value is surveyed in the front; SUM is front BPM value sum; NUMBER is the number of the BPM value that adds up.
Afterwards, flow process enters step S809.In step S809, the new mean value BPMavr that detects the BPM value of the BPM value BPMnew that obtains and front surveying compare and the absolute value of the difference of definite these two values whether less than currency Δ BPMmax.
If the absolute value of the difference of the new mean value BPMavr that detects the BPM value of the BPM value BPMnew that obtains and front surveying, thinks then that new detection fails greater than the currency of Δ BPMmax.Fail flag FAIL is changed to 1.
If the absolute value of difference is within the scope of currency Δ BPMmax, then flow process enters step S813.Otherwise flow process enters step S810.
In step S813, the BPM value BPMnew that new detection obtains and the BPM value sum addition of front.And the number of the BPM value that adds up increases by 1.Flow process enters step S814 then.
In step S810, check that whether fail flag FAIL is less than value " 2 ".If fail flag FAIL is less than " 2 ", then flow process enters step S812. in step S812, fail flag FAIL be increased 1 and flow process finish at step S812.Otherwise, if in step S810 on inspection fail flag FAIL be not less than 2, then flow process enters step S811.In step S811, the front BPM value sum SUM and the number NUMBER of the BPM value that adds up are both initialized to " 0 ".Flow process finishes at step S811 then.
Return step S814 again, whether the number NUMBER that checks the BPM value that adds up is more than or equal to " 3 ".If it is less than 3, then flow process finishes at step S814.Otherwise flow process enters step S815 and fail flag FAIL is changed to " 0 " again.Flow process enters step S816 then.
In step S816, the mean value BPMavr of the BPM value of utilizing formula 6 to recomputate to survey the front.At last, the number NUMBER of the mean value BPMavr of the BPM value surveyed of front and the BPM value that adds up is sent to display logic unit 6.
Fig. 9 illustrates the operational flow diagram of display logic unit.
With reference to Fig. 1 and 9, display logic unit 6 is at first from each BPM detecting device 101,102 ..., receive the mean value BPMavr of the BPM value of surveying the front in the cycle detection device of 10n and the number NUMBER of the BPM value that adds up.
In step S901, variable " i " is used as the circulation indieating variable and at first is initialized as " 2 ".In addition, variable i best is initialized to " 1 ".
Suppose all BPM detecting devices 101,102 ..., the number NUMBER of the mean value BPMavr of the BPM value that the front among the 10n is surveyed and the BPM value that adds up is stored among array variable BPMavr (i) and the NUMBER (i).This just means that the mean value BPMavr of the tested BPM value in the BPM detecting device 101 is stored among the BPMavr (1) and the number of the BPM value that adds up is stored among the NUMBER (1).The mean value BPMavr of the tested BPM value in the BPM detecting device 102 is stored among the BPMavr (2) or the like.
Store maximal value NUMBER for definite current which BPM detecting device, using a circulation to obtain the indication of maximal value NUMBER.
In step S902, the content among comparison variable NUMBER (i) and the NUMBER (ibest).When having only NUMBER on duty (i) ratio NUMBER (ibest) big, the content in the circulation indieating variable " i " just is stored among the ibest.Below, loop variable " i " is increased " 1 ".Flow process enters step S903 then.In step S903, check whether " i " is equal to or greater than " n ", and wherein " n " adds 1 for the number of BPM detecting device.If " i " is littler than " n ", then flow process is returned step S902.Otherwise flow process enters step S904.
In step S904, check whether the value of the NUMBER (ibest) in the BPM detecting device of storing maximum NUMBER value is equal to or greater than " 3 ".If it is less than 3, then flow process finishes at step S904.But if it is equal to or greater than 3, flow process enters step S905.Then, fixed BPM value BPMavr (ibest) outputs to display unit 7.Like this, the beat number of a melody has just been detected exactly.
Embodiment described above is the beat number that is specially adapted for detecting a melody.In view of this device is mainly used in " DJ equipment ", the BPM detecting device is designed to velocity range between 60 to 158BPM.But the present invention is not limited to this, and it also is suitable for for other detection method, for example detects the method for other sound signal beat number.
Do not depart from the scope of the present invention and conceive and to make many other changes and remodeling.Should be appreciated that to the invention is not restricted to certain embodiments, scope of the present invention is defined by the following claims.