Fundamental purpose of the present invention provides a kind of sound signal coding/decoding method based on small echo, so that when the music of wideband audio signal handled, under the situation of same employing psychoacoustic model, undistorted compressibility (on the relative meaning) is significantly improved than common MPEG.
The present invention mainly is the improvement at MPEG wideband audio compression algorithm, replace traditional bank of filters with wavelet technique, auditory properties in conjunction with people's ear, realize high-gain, high quality audio encoding, and solved wavelet technique and be applied to the filtering in the audio compression encoding and decoding and improve several key problems such as budget speed.For reaching this purpose, sound signal is carried out the coding/decoding operation as follows.Cataloged procedure:
(1) adopts into sound signal from microphone or other incoming line
(2) through the low pass filter filters out high-frequency signal
(3) after the analog-digital converter conversion, become digital signal PCM stream
(4) digital signal enters digital signal processor, moves into 128 new samples in Buffer Pool, simultaneously
From Buffer Pool, shift out 128 samples the oldest (this Buffer Pool length is 1250 points)
(5) with the sequence in this Buffer Pool respectively with 16 wavelet analysis wave filter (realities of analysis filter
Existing method is explanation separately below) convolution, and carry out critical sampling again, obtain 16 and decompose preface
Corresponding 16 frequency bands of row, because the heterogeneity of subband, the sampling rate again of each subband is to differ
Sample, specific as follows: subband 1~4 sampling respectively is 1 sample, and subband 5~6 respectively is 2
Sample, subband 7~13 respectively are 8 samples, and subband 14~15 respectively is 16 samples, subband
16 is 32 samples;
(6) be a group with the 3*128 point, the sample number in each subband is original three times like this, i.e. son
Being with respectively has 3 samples in 1~4, subband 5~6 respectively has 6 samples, and subband 7~13 respectively has 24
Individual sample, subband 14~15 respectively have 48 samples, and subband 16 has 96 samples; Look for respectively
Go out the scale factor (the same MP2 of method) of each subband, with each subband normalization;
(7) this 3*128 spectrum information of ordering simultaneously, substitution psychoacoustic model (1 or 2) is tried to achieve each
The quantization digit of subband;
(8) quantization digit that obtains according to (4) quantizes the sample in each subband, and quantization method is as follows:
If: the quantization digit of every subband is a, and the sample number of this subband is Num, then the quantification of each sample
Back result is b:
b=a>>(16-Num)
(9) undistorted coding (employing huffman coding);
(10) packing, coding output;
(11) single-chip microcomputer reads in compressed bit stream, writes storage medium.Decode procedure:
(1) single-chip microcomputer reads in compressed bit stream from storage medium or PC;
(2) import compressed bit stream into DSP;
(3) input coding sequence unpacks and Huffman is separated with the order opposite with cataloged procedure, is reduced to 16
Sample on the individual subband pushes 16 Buffer Pools;
(4), remove simultaneously in scale factor with the sample inverse quantization on each subband;
(5) corresponding to the sampling again in the cataloged procedure (2), the sample on each subband is interleave null value, tool
The body number is: insert 127 zero, 2 samples in the subband 5~6 between 2 samples in the subband 1~4
This is inserted 63 zero, inserts 15 zero, subband 14~15 between 2 samples in the subband 7~13
In insert 7 zero between 2 samples, insert 3 zero between 2 samples in the subband 16;
(6) with the sequence in 16 Buffer Pools and composite filter group respectively convolution each get 128 data,
With one 128 point sequences of 16 128 corresponding additions, this sequence is output valve;
(7) export this sequence, form PCM stream;
(8) PCM flows through and forms simulating signal after digital analog converter is changed;
(9) simulating signal is by low-pass filter elimination high-frequency signal;
(10) simulating signal of elimination high-frequency signal is broadcasted through earphone or loudspeaker.
The implementation method that the ripple device is considered in analysis in the above-mentioned cataloged procedure step of the present invention (5) utilizes convolution that linear system is satisfied the characteristics of law of association, and each wavelet filter is carried out convolution algorithm earlier; Each wavelet filter residing position in WAVELET PACKET DECOMPOSITION and synthetic tree is controlled in the influence of consider going up down-sampling on the other hand, can obtain corresponding sub-band division multiphase filter group thus, and its corresponding formula is as follows:
Wherein: S1, D1: input signal;
F1, f2: wavelet decomposition wave filter
Rf1, rf2: wavelet reconstruction wave filter
: down-sampling n is doubly
: up-sampling n is doubly
The implementation method of wavelet reconstruction wave filter is the inverse process of top said analysis filter implementation method during decoding.
When the compressed audio bitstream stream that is obtained by audio frequency wavelet packet scrambler is decoded, decoding speed and memory source there is higher requirement, though to be wavelet algorithm have the mathematical property of the many DCT of being superior to algorithms but be difficult to practical bottleneck place for this, the invention provides a fast algorithm of wavelet reconstruction in the wavelet packet demoder, repeatedly insert the characteristic of 0 value according to needs in the restructuring procedure of small echo, for reducing the calculated amount of wavelet reconstruction, utilize the systematicness of subband 0 interpolation, when calculating, avoided the calculating of these 0 interpolation points; For reducing the expense on the storage space, only need to go to store data necessary with a memory buffer.
When the music that the said audio signal compression coding/decoding method based on wavelet transformation of the present invention is applied to wideband audio signal is handled, under the situation that adopts same psychoacoustic model, its undistorted compressibility (on the relative meaning) will be significantly improved than common MPEG, and among the present invention small echo is considered the wavelet technique that has on the fast algorithm in ripple device division methods and the decode procedure than in the past and have breakthrough, overcome the bottleneck problem during small echo is used, made full use of the time-frequency localization and the multiresolution analysis character of small echo and wavelet package transforms.
Below in conjunction with accompanying drawing one embodiment of the present of invention are elaborated.
Present embodiment is used DSP as main arithmetical organ, finishes the Code And Decode algorithm of voice data, with the main logic components of a slice single-chip microcomputer conduct.
Before discussing technical solution of the present invention in detail, the psychoacoustic model that relates to based on the small echo audio compression techniques is provided by following background information.
The Digital Audio Compression Coding technology can obtain high-quality coding effect with lower speed, and its ultimate principle is: the redundance of 1) managing to eliminate sound signal; 2) make full use of human hearing characteristic.The normal person can hear frequency range at 20Hz~20kHz, strength range is-and the sound of 5dB~130dB, and have the ability of differentiating loudness, tone and tone color.The auditory properties of people's ear has related to the problem of aspects such as relevant psychologic acoustics and physiological acoustics.Human hearing characteristic is mainly reflected in the following aspects in the wideband audio Application in Coding: the intensity of the sense of hearing and frequency range characteristic; The high frequency locating features of masking effect and people's ear.The former filters the voice signal below the threshold audiogram in coding, to reduce record information transmitted amount, saves the bit number of coding.Utilize the masking effect principle, the weak signal that is lower than masking threshold can not done coding, to improve the bit utilization factor; And quantizing noise is controlled at below the masking threshold, thereby saved the bit number that quantizes, eliminate the irrelevant degree of the sense of hearing of sound.According to the high frequency locating features of people's ear, in the hyperchannel stereo coding, can reduce the high-frequency information redundancy in a large number to the radio-frequency component special processing, improve compression efficiency.In transition coding, the selection of time domain frame length (being time domain window length) is restricted by the factor of two mutual contradictions: frame length is big more, and then coding gain is high more; And excessive frame length will make time domain resolution reduce, and produces serious " Pre echoes ".Therefore, selecting a suitable frame length, make the inhibition of coding gain and " Pre echoes " all reach the equilibrium point an of the best, is very important.Experiment showed, that when frame length shortens to 2ms~5ms because the forward masking effect, " Pre echoes " can be sheltered by the shock response of its back.For example, when 48kHz sampled, window length was 256 o'clock, and its time domain resolution is 2.7ms, because pre-masking effect, people's ear is discovered less than " Pre echoes ".In psychologic acoustics, a pure tone can be the center with it, and the continuing noise with certain bandwidth is sheltered, if noise power equals the power of this pure tone in this frequency band, this moment, this pure tone was in the critical conditions that can just be heard, and claimed that promptly this frequency band is critical bandwidth (unit is Bark).A typical case of critical band divides as shown in Figure 4.Critical band is the psychologic acoustics foundation of sub-band division in the coding.People's ear to the analysis of sound signal based on critical band, a similar non-equiband bank of filters, widely different in different subbands, sub-band coding has utilized this character exactly and has designed.Therefore, critical band is the psychologic acoustics foundation of sub-band division in the coding.In sub-band coding, the division of subband should be approaching with the width of people's ear critical band as far as possible, so that better adapt to the auditory properties of people's ear.In traditional sub-band coding, this requirement can not access well to be satisfied.Reason is, can relate to the difficulty of some technical elements near the non-equiband bank of filters design of the auditory properties of people's ear.For example, the frequency bandwidth that MPEG divides human auditory system with the Methods of Subband Filter Banks of 32 equibands, as shown in Figure 5.In the division of this subband, comprise a plurality of critical bands at subband of low frequency part, and at HFS, a critical band is divided into a plurality of subbands again, the utilization ratio of subband is very low, can not well approach the auditory properties (especially true in low frequency part) of people's ear.But its advantage is that the advantage of equiband multiphase filter group is that the exponent number of each sub-filter is identical, does not have delay issue in the calculating, and wave filter has anti-aliasing preferably character.Utilize this bank of filters to carry out the audio compression coding, technology realizes going up fairly simple, but the utilization factor of the auditory properties of people's ear is limited, is difficult to realize the undistorted coding of high compression ratio.
Audio compression techniques based on small echo, propose in order fundamentally to solve the above-mentioned bottleneck problem in the conventional audio compressed encoding, wavelet analysis is a very fast branch of mathematics of development in recent years, ability with the analysis of signal time-frequency localization and multiscale analysis, in limited sub-band division, based on the sub-band division of small echo can be better near the critical band of people's ear, be the psychological auditory properties of better utilization people ear, thereby promoted the development of Digital Signal Processing greatly.
According to above principle, in the present invention, utilize the forward masking effect of the sense of hearing, guaranteeing under the higher coding gain, effectively suppress " Pre echoes " phenomenon that causes because of the time domain lack of resolution; Utilize masking effect, determine quantization level, the control quantizing noise makes it to be lower than or as far as possible near the masking threshold of people's ear, realizes undistorted audio coding and the quality that improves audio coding under low code check.A wavelet packet sub-band division example among the present invention as shown in Figure 6.
The said technical scheme of the present invention can be divided into the operation of audio-frequency signal coding and two parts of decoding generally, and its flow process is as follows respectively: cataloged procedure: adopt into sound signal from microphone or incoming line (1); (2) through the low pass filter filters out high-frequency signal; (3) after the AD conversion, become digital signal PCM stream; (4) digital signal enters DSP, utilizes the described algorithm of this patent to carry out compressed encoding, forms compressed bit stream; (5) single-chip microcomputer reads in compressed bit stream, writes storage medium.Decode procedure: (1) single-chip microcomputer is read compressed bit stream from storage medium or PC; (2) import compressed bit stream into DSP; (3) DSP utilizes the described algorithm of this patent to decompress, and forms PCM stream; (4) PCM flows through and forms simulating signal after DA changes; (5) simulating signal is by low-pass filter elimination high-frequency signal; (6) simulating signal of elimination high-frequency signal is broadcasted through earphone or loudspeaker;
In the cataloged procedure, microphone or other incoming line are adopted into sound signal, then through the low pass filter filters out high-frequency signal, are thereafter to become digital signal PCM stream after the analog-digital converter conversion, and these several steps can realize by prior art.
Then, digital signal enters digital signal processor (DSP).In digital signal processor (model that adopts in the present embodiment is TMS320C54XX), to method for processing signals is the technical problem underlying that technical solution of the present invention will solve, and comprises that mainly the wavelet analysis of sound signal is considered the acquisition of ripple device and the acquisition of scrambler.The function of said here analysis and reconfigurable filter and encoder all realizes in DSP.Because the operating process in decode procedure in digital signal processor is the reverse procedure of cataloged procedure, so here the implementation method of wavelet analysis and reconfigurable filter, encoder is set forth in the lump, its processing procedure is as follows respectively:
Cataloged procedure basic among the DSP is as follows, sees accompanying drawing 2:
(1) moves into 128 new samples in Buffer Pool, from Buffer Pool, shift out 128 samples the oldest simultaneously
This (this Buffer Pool length is 1250 points);
(2) with the sequence in this Buffer Pool respectively with 16 wavelet analysis wave filter convolution, and carry out critical
Sampling again obtains corresponding 16 frequency bands of 16 branch solution sequences, because the heterogeneity of subband, each
The sampling rate again of subband is different, and is specific as follows: subband 1~4 sampling respectively is 1 sample,
Subband 5~6 respectively is 2 samples, and subband 7~13 respectively is 8 samples, and subband 14~15 respectively is 16
Individual sample, subband 16 are 32 samples;
(3) be a group with the 3*128 point, the sample number in each subband is original three times like this, i.e. son
Being with respectively has 3 samples in 1~4, subband 5~6 respectively has 6 samples, and subband 7~13 respectively has 24
Individual sample, subband 14~15 respectively have 48 samples, and subband 16 has 96 samples; Find out respectively
The scale factor of each subband (the same MP2 of method) is with each subband normalization;
(4) this 3*128 spectrum information of ordering simultaneously, substitution psychoacoustic model (1 or 2) is tried to achieve each
The quantization digit of subband;
(5) quantization digit that obtains according to (4) quantizes the sample in each subband, and quantization method is as follows:
If: the quantization digit of every subband is a, and the sample number of this subband is Num, then the quantification of each sample
Back result is b:
b=a>>(16-Num)
(6) undistorted coding (employing huffman coding);
(7) packing, coding output.
Decode procedure is opposite with cataloged procedure, and its basic process is as follows, sees accompanying drawing 3:
(1) input coding sequence unpacks and Huffman is separated with the order opposite with cataloged procedure, is reduced to 16
Sample on the individual subband pushes 16 Buffer Pools;
(2), remove simultaneously in scale factor with the sample inverse quantization on each subband;
(3) corresponding to the sampling again in the cataloged procedure (2), the sample on each subband is interleave null value, tool
The body number is: insert 127 zero, 2 samples in the subband 5~6 between 2 samples in the subband 1~4
This is inserted 63 zero, inserts 15 zero, subband 14~15 between 2 samples in the subband 7~13
In insert 7 zero between 2 samples, insert 3 zero between 2 samples in the subband 16;
(4) with the sequence in 16 Buffer Pools and composite filter group respectively convolution each get 128 data,
With one 128 point sequences of 16 128 corresponding additions, this sequence is output valve;
(5) export this sequence.
At present, when utilizing small echo that signal is handled, for further improving frequency resolution, signal need be continued to decompose, common way is to carry out class Mallat algorithm, as shown in Figure 7.Traditional way is successively to decompose and successively synthesize, and its concrete grammar is as described below:
In decomposable process, signal and resolution filter are carried out convolution, carry out down-sampling then, repeat this process until arriving the corresponding subband node of binary tree; In restructuring procedure, then need wavelet coefficient on each leafy node and reconfigurable filter are carried out convolution, carry out up-sampling (being generally zero-adding) then, until the root node of getting back to binary tree.Obviously, can repeatedly introduce truncation error inevitably in the numerical procedure of realizing convolution, the upper and lower sampling after each convolution then can make this error diffusion, repeatedly repeats this process and then can cause error accumulation.When level is dark, error even can be diffused on the whole subband, thus the data on the whole subband all become false data.
The acquisition of wavelet decomposition and reconfigurable filter is by convolution filter in advance among the present invention, utilizes convolution that linear system is satisfied the characteristics of law of association, and each wavelet filter is carried out convolution algorithm earlier; Each wavelet filter residing position in WAVELET PACKET DECOMPOSITION and synthetic tree is controlled in the influence of consider going up down-sampling on the other hand, can obtain corresponding sub-band division multiphase filter group thus.Its corresponding formula is as follows:
Wherein: S1, D1: input signal;
F1, f2: wavelet analysis wave filter
Rf1, rf2: wavelet reconstruction wave filter
: down-sampling n is doubly
: up-sampling n is doubly
If three layers of wavelet packet binary tree of wavelet packet binary tree such as the Fig. 7 of adopting, with subband 2 is that example describes, if the source signal sequence is resSig, the coefficient of dissociation sequence that obtains on the subband 2 is sub2Sig, decomposing the low pass wavelet filter is LD, decomposing the high pass wavelet filter is HD, and * is a convolution algorithm, and then the generation method of this Subband Analysis Filter and this sub-band division sequence is:
Wherein bigFilter2 is the final analysis filter that generates of this subband, up-sampling be between zero insertion, Sub2Sig is the branch solution sequence of this subband of down-sampling.
If low pass wavelet reconstruction wave filter is LR, high pass wavelet reconstruction wave filter is HR, and * is a convolution algorithm, and then the generation method of this sub-band division wave filter and this subband composition sequence is:
Wherein RecFilter2 is the final composite filter that generates of this subband, and Rec2Sig is the composition sequence of this subband, and the corresponding addition of the composition sequence on all each subbands is synthetic sample.
Other Subband Analysis Filter and reconfigurable filter can be obtained by similar method.
In the decode procedure, when the compressed audio bitstream stream that is obtained by audio frequency wavelet packet scrambler is decoded, decoding speed and memory source there is higher requirement, the present invention is according to the characteristics of subband, for reducing calculated amount and storage space, the present invention proposes fast algorithm, this algorithm can greatly reduce calculated amount and storage space, and it provides assurance for the realization of voice data wavelet packet compression scheme.
With as shown in Figure 8 WAVELET PACKET DECOMPOSITION is example, it decomposes the every frame length of sample is 128 points, wherein the 1st~4 subband respectively is 1 sample point, the 5th~6 subband respectively is 2 sample points, the 7th~13 subband respectively is 8 sample points, the 14th~15 subband respectively is 16 sample points, and the 16th subband is 32 sample points.
During synthetic subband, according to a conventional method, each subband interpolation respectively with synthetic wavelet filter convolution after addition, as shown in Figure 9.
Yet this method has inefficent place clearly, and at first each subband all has considerable zero to participate in convolution, and needs a large amount of RAM of system assignment to go to store 16 sequences, obviously lacks and carries out efficient.
Therefore according to the characteristics of wavelet decomposition sequence, utilize the systematicness of subband 0 interpolation, when calculating, avoided the calculating of these 0 interpolation points; Only need to go to store data necessary, therefore greatly reduced storage space with a memory buffer.
The fast algorithm of this patent and usually convolution algorithm all adopt the DB-10 small echo as wavelet basis, the wavelet tree structure all as shown in figure 10, it is as follows that calculated amount that its reconstruct is 128 and ram space take the situation contrast: (filter length is respectively 1144,1144,1144,1144,568,568,136,136,136,136,136,136,136,64,64,28)
Conventional method calculated amount (multiplication)=16* (4* (1144*128)+2* (568*128)+7* (136*128)+2* (64*128)+28*128)=872960*16;
Conventional method ram space=4* (1144+128)+2* (568+128)+7* (136+128)+2* (64+128)+28+128=8868
This paper algorithm computation amount (multiplication)=16* (4* (1144/128*128)+2* (568/64*128)+7* (136/16*128)+2* (64/8*128)+28/4*128)=17408*16
This paper algorithm ram space=4* (1144+128)/128+2* (568+128)/64+7* (136+128)/16+2* (64+128)/8+ (28+128)/4=264
In conjunction with also having many null elements before and after a certain concrete wavelet filter, then its calculated amount can also be significantly low.Realize the core C-false code of fast algorithm of the present invention:
for (ii=0; Ii<sub band number; Ii++) { samplept=sample+ frame length-1; End for (the int i=0 of // sensing Frame; I<sample sequence length; I++) { ConvResult=0; For (int j=0; Sample number in j<this subband; J++) // calculate the initial work location that this time calculate pairing wave filter and input sample sequence //gap is 0 an interpolation number between this sub-band samples.KBegin=((i-j*gap+0x7F) ﹠amp; 0xFFFFFF80); For (int k=kBegin; K<=sub-filter length; The k+=frame length) ConvResult+=sample sequence [k] * sub-filter [k]; }<!--SIPO<dP n="8">--<dp n="d8"/>(* samplept--) +=ConvResult; //End ii loop
In cataloged procedure, after the coding packing output, read in compressed bit stream by single-chip microcomputer, write storage medium, finish the compression encoding process of sound signal.Generally speaking, decode procedure is the opposite sequence of cataloged procedure, single-chip microcomputer reads in compressed bit stream from storage medium or PC, import compressed bit stream into DSP, processing in DSP is explained in the analysis of encoding method in the above, and DSP exports this sequence and forms PCM stream, and PCM flows through and forms simulating signal after digital analog converter is changed, simulating signal is by low-pass filter elimination high-frequency signal, and the simulating signal of elimination high-frequency signal is broadcasted through earphone or loudspeaker.
Present embodiment is just set forth method of the present invention in conjunction with some specific hardware, and the enforcement of technical solution of the present invention is not limited to therewith, and various variations or the improvement that can be made by those of ordinary skills can not depart from the scope of the present invention.