A kind of method and audio-frequence player device of eliminating sound effect switching noise
Technical field
The present invention relates to the audio signal processing technique field, particularly a kind of method and a kind of audio-frequence player device of eliminating sound effect switching noise.
Background technology
Sound effect technology is exactly on the basis of original music signal, carries out processing such as spatial loop winding mold plan, sound field broadening, dynamic enhancing, makes music effect more rich and varied, and music is pleased people's ear more, brings finer hearing enjoying to the hearer.From waveform, audio can make the waveform of music signal that certain change takes place.
Provide an object lesson below.Figure 1 shows that one section pulse code modulation (pcm) oscillogram that does not add the original audio signal of any audio.Fig. 2 is the PCM oscillogram after original audio signal shown in Figure 1 has added a kind of audio, for making things convenient for description this audio is called audio 1; Fig. 3 is the PCM oscillogram after original audio signal shown in Figure 1 adds another kind of audio, for making things convenient for description this audio is called audio 2.Obviously, great changes have taken place with respect to the waveform profiles of Fig. 1 in the waveform profiles of Fig. 2 and Fig. 3, and the waveform profiles of Fig. 2 and Fig. 3 also has sizable difference.
On portable media player, more or less all used various audio at present.The audio that portable media player on the market is commonly used comprises the most basic 7 kinds of common audios, CLASSIC (classical music pattern), POP (pop music pattern), JAZZ (jazz pattern), ROCK (rock music pattern), NOMAL (general mode), SOFT (soft pattern) and BASS (supper bass pattern); In addition, many companies and research institute also develop the audio that differs from one another separately.
Because audio is varied, a unavoidable problem will appear in actual applications: switch different audios if desired in the music process, owing to there is very big difference between each audio, thereby tangible saltus step appears in the concert that has caused playing out when switching audio, very likely can produce switching noise, its most tangible switching noise is exactly a sound clearly.
The reason that produces switching noise is exactly because the method for different audio processing music is different, thereby there is discontinuous state in the audio frequency PCM data that cause exporting, in other words be exactly can not be level and smooth between the different audios linking, and this shows on the oscillogram to be exactly on the time point that audio switches, and acute variation significantly appears in waveform.With the voice signal that Fig. 1 was lifted is example, if adopt above-mentioned first kind of audio at preceding half section, the second half section is adopted above-mentioned second kind of audio, and then its PCM oscillogram as shown in Figure 4, the place of oval marks is exactly audio switching place among the figure, and acute variation has appearred in this place's waveform as can be seen.The PCM waveform at oval marks place among Fig. 4 is amplified the back observe, as shown in Figure 5, wherein the phenomenon of audio frequency PCM value straight line abrupt change has appearred in the place that identifies of circle, and noise has also produced in that moment.
The existence of switching noise must influence the appreciation of user to music, so need find solution to overcome this problem.A kind of disposal route that adopts when audio switches in the prior art is: two audios move the weighting summation transition simultaneously.That is to say that old audio is also done and generated audio frequency PCM data in the time of switching, the audio frequency PCM data weighting addition of working it out with new audio then allows the weight of old audio reduce at leisure and just can avoid producing switching noise as far as possible like this.The another kind of disposal route of prior art is to adopt the processing means of being fade-in fade-out to walk around this problem to take place: be exactly when switching to new audio, having started the function of fading out earlier allows audio frequency PCM data multiplying factor slowly diminish to zero, and then start the function of fading in, allow audio frequency PCM data multiplying factor slowly become normal value by zero, so just cause a mild transient process, take place thereby avoided the voice data acute variation also can eliminate noise.Though this disposal route has been avoided switching noise, can make the hearer feel that temporary transient interruption appears in music, influences hearer's experience.
For portable media player, require disposal route little to space requirement, it is simple that computing is wanted, and can handle constantly, and power consumption is little.But above-mentioned existing disposal route is all bigger to space requirement, and computing is more complicated also, is not easy to realize on portable media player.
Summary of the invention
In view of this, the purpose of the embodiment of the invention is to propose a kind of method of eliminating sound effect switching noise, and minimum to the storage space requirement, computing is simple.
A kind of method that is used for eliminating sound effect switching noise that the embodiment of the invention proposes at playing audio signal, described sound signal is made of sampled point, and N sampled point constitutes a sliding step, and N is a natural number; This method comprises:
A, the sound signal of first sliding step is decoded, load the audio of current use, decoded this section audio signal is handled and play, and write down the pulse code modulation (PCM) PCM value of this last sampled point of section audio signal;
B, the sound signal of current pending sliding step is decoded, decoded audio signal is loaded audio to be handled, and judge whether to have taken place the audio switching, if then according to the PCM value of last sampled point of the last sliding step that write down, PCM value to each sampled point of current sliding step is carried out interpolation processing, obtains the sound signal of the current sliding step after the interpolation processing; Otherwise execution in step C;
The sound signal of C, the current sliding step of broadcast writes down the PCM value of current last sampled point of sliding step, and goes to step B.
According to a further aspect in the invention, another object of the present invention is to provide a kind of audio-frequence player device, this equipment has eliminates the sound effect switching noise function, and it is little to have a requirement storage space, calculates characteristic of simple.
The disclosed a kind of audio-frequence player device of the embodiment of the invention, be used for playing audio signal, described sound signal is made of sampled point, N sampled point constitutes a sliding step, N is a natural number, this equipment comprises the decoding device that is used for decoded audio signal, be used for the decode sound signal that obtains of decoding device is loaded the sound-effect processing equipment that audio is handled, and the playing device play of the sound signal after sound-effect processing equipment handled, it is characterized in that, this equipment also comprises the sampled point pen recorder, is used for the current pulse code modulation (PCM) PCM value of playing last sampled point of sliding step sound signal of recording and reproducing apparatus; Described N is a natural number, the number of expression sampled point;
Judgment means is used to judge whether the audio that described sound-effect processing equipment loads switching has taken place, if then send indicator signal to interpolation processor;
Interpolation processor, be used for when the indicator signal received from judgment means, the PCM value of a sampled point that is write down according to the sampled point pen recorder, PCM to each sampled point of the sliding step sound signal of described sound-effect processing equipment after pre-treatment carries out interpolation processing, and the sound signal after the interpolation processing sends to playing device and plays.
As can be seen from the above technical solutions, write down the PCM value of last sampled point of sliding step sound signal, when the audio switching takes place when, according to the PCM value that is write down the current sound signal that will play is carried out interpolation processing, can so that audio switch before and after the PCM waveform of sound signal keep seamlessly transitting, thereby avoided the audio switching noise.And the required calculated amount of the present invention program is very little, and the storage space that needs is minimum, is highly suitable for using on portable media player.
Description of drawings
Fig. 1 is one section PCM oscillogram that does not add the original audio signal of any audio;
Fig. 2 is that original audio signal shown in Figure 1 uses the PCM oscillogram after audio 1 is handled;
Fig. 3 is that original audio signal shown in Figure 1 uses the PCM oscillogram after audio 2 is handled;
Fig. 4 handles half section use audio 1 before the original audio signal shown in Figure 1, and the second half section is used the PCM oscillogram after audio 2 is handled;
Fig. 5 is that the PCM waveform at oval marks place among Fig. 4 amplifies the observed oscillogram in back;
The audio hand-off process process flow diagram that Fig. 6 proposes for the embodiment of the invention;
Fig. 7 carries out the process flow diagram of interpolation processing for what the embodiment of the invention proposed according to formula (1);
Fig. 8 be to before the original audio signal shown in Figure 1 half section use audio 1 to handle, the second half section uses audio 2 to handle, and the PCM oscillogram that adopts the audio switching handling method of the embodiment of the invention to obtain;
Fig. 9 is that the PCM waveform at oval marks place among Fig. 8 amplifies the observed oscillogram in back;
Figure 10 is the block diagram of a kind of audio-frequence player device of embodiment of the invention proposition.
Embodiment
The core that solves sound effect switching noise will solve audio exactly PCM data acute variation when switching, PCM data smoothingization when in other words will allow audio switch exactly.The embodiment of the invention proposes a kind of occupying little space, and realizes simple sound effect switching noise removing method.Its ultimate principle is: when audio switches, according to the last audio frequency PCM value of audio data block after first audio is handled before the switching of record, do smoothing processing with the audio frequency PCM value of switching back second audio processing, again obtain new audio frequency PCM value, after handling like this, just can avoid the acute variation of data fully when switching audio and noise occur, and in the use of space, also only need a data space, be used to write down last audio value of switching preceding first audio.If sound signal comprises left and right sides two-channel, then respectively each sound channel is all carried out above-mentioned processing.
For making the purpose, technical solutions and advantages of the present invention clearer, the present invention is further elaborated below in conjunction with accompanying drawing.
The audio hand-off process flow process that the embodiment of the invention proposes as shown in Figure 6.Pre-determine sliding step N, N is a natural number, and its implication is the sampled point number of sound signal.Come that according to this sliding step N sound signal is carried out smoothing and handle, being provided with of this length can be adjusted as the case may be.Because sound signal generally all is the audio data frame of pcm encoder, directly the length of audio data frame is set to sliding step usually.
This treatment scheme comprises the steps:
Step 601: the sound signal to first sliding step is decoded, and first audio that loads current use is handled and play decoded this section audio signal, and writes down the PCM value of this last sampled point of section audio signal.
Step 602: the sound signal to current pending sliding step is decoded, and decoded audio signal is loaded audio handle, and judge whether to have taken place the audio switching, promptly switch to second audio from first audio, if then execution in step 603, otherwise execution in step 604.
Step 603: according to the PCM value of last sampled point of a last sliding step that has write down, the PCM value of each sampled point of current sliding step is carried out interpolation processing, obtain the sound signal of the current sliding step after the interpolation processing.The effect of this interpolation processing makes the PCM value of last sampled point of the PCM value of current sampling point and a last sliding step realize seamlessly transitting.
The embodiment of the invention provides a simple smoothing and handles interpolation formula, and is specific as follows:
x′(n)=[1-α(n)]·x(n)+α(n)·y (1)
Wherein y is to use the PCM value of last last sampled point of sliding step of first audio; X (n) is to use the PCM value of n sampled point in the current sliding step of second audio, and n is a sequence number, variation range from 1 to N; α (n) is a smoothing factor, and the span of this smoothing factor is [0,1], requires this smoothing factor α (n) variation pattern to change to 0 with the increase of n from 1 simultaneously.X ' is the PCM value of n sampled point after the interpolation processing (n).
Variation pattern how to choose α generally has following dual mode:
1: successive subtraction method
Successive subtraction method allows α (n) value be decremented to 0 from 1 exactly, and the mode of successively decreasing can be a lot; For example: can adopt following formula to calculate α (n):
2: the multiplier method
The multiplier method is exactly to allow the α value ceaselessly multiply by one less than 1 greater than 0 factor beta, thereby makes the value of α become 0 by 1; For example adopt following formula to calculate:
α(n)=1·β
n (3)
In the time of N=128, β=0.944 is exactly the 0.5db that at every turn successively decreases.
The detailed process that carries out interpolation processing according to formula (1) comprises the steps: as shown in Figure 7
Step 701: initializing variable n and α.N=0 for example is set, α=1.
Step 702: get the PCM value x (n) of n sampled point of current sliding step, according to formula x ' (n)=[1-α] x (n)+ay calculates the PCM value of n sampled point after the interpolation processing.
Step 703: the value of variable n is added up 1, calculate the value of the variable α of current n value correspondence according to formula (2) or formula (3).
Step 704: whether the value of judging current n greater than N, if process ends then, otherwise return step 702.
Above interpolation processing formula only is used for example, in the practical application, also can adopt the level and smooth interpolation formula of other form.
Step 604: play the sound signal of current sliding step, write down the PCM value of current last sampled point of sliding step, and go to step 602.
Be example still with the voice signal that Fig. 1 was lifted, if adopt above-mentioned first kind of audio at preceding half section, second half section is adopted above-mentioned second kind of audio, if adopt the audio switching handling method of the embodiment of the invention, then resulting PCM oscillogram as shown in Figure 8, can see the waveform of the waveform at oval marks place wherein with respect to the oval marks place among Fig. 4, its wave form varies will relax manyly, and Fig. 9 is the waveform after the waveform with the oval marks place of Fig. 8 amplifies.Can find that the situation of the waveform abrupt change that originally occurs has disappeared in Fig. 9 in Fig. 5.
The embodiment of the invention also proposes a kind of audio-frequence player device, its block diagram as shown in figure 10, this equipment comprises as lower device:
Be used for decoded audio signal decoding device 1001, be used for the decode sound signal that obtains of decoding device 1001 is loaded the sound-effect processing equipment 1002 that audio is handled and the playing device 1003 play of the sound signal after sound-effect processing equipment 1002 handled;
Sampled point pen recorder 1004 is used for the recording and reproducing apparatus 1003 current pulse code modulation (PCM) PCM values of playing last sampled point of sliding step sound signal;
Judgment means 1005 is used to judge whether the audio that described sound-effect processing equipment 1002 is loaded switching has taken place, if then send indicator signal to interpolation processor 1006;
Interpolation processor 1006, be used for when the indicator signal received from judgment means 1005, the PCM value of a sampled point that is write down according to sampled point pen recorder 1001, PCM to each sampled point of the sliding step sound signal of described sound-effect processing equipment 1002 after pre-treatment carries out interpolation processing, and the sound signal after the interpolation processing sends to playing device 1003 and plays.
Preferably, described sliding step is the length of the audio data frame of pcm encoder.
Preferably, described interpolation processor 1006 comprises:
The initialization of variable unit is used for variable n and variable α is set to initial value n=0, α=1;
Computing unit, get the PCM value x (n) of n sampled point of a sliding step sound signal need carrying out slip treated, according to variable n and variable α and formula x ' (n)=[1-α] x (n)+α y, the PCM value x ' that calculates n sampled point after the interpolation processing is (n); Y is the PCM value that the sampled point pen recorder is write down;
The variable assignments unit, be used for described computing unit finish calculate n sampled point PCM value x ' (n) after, the value of variable n is added up 1, and calculates the value of the corresponding variable α of current n value;
Whether judging unit, the value that is used for judgment variable n be greater than sliding step, if then notify the initialization of variable unit that variable n and variable α are reinitialized.
Through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential hardware platform, can certainly all implement, but the former is better embodiment under a lot of situation by hardware.Based on such understanding, all or part of can the embodying that technical scheme of the present invention contributes to background technology with the form of software product, this computer software product can be stored in the storage medium, as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are used so that an apparatus for media playing, particularly portable media player are carried out the described method of some part of each embodiment of the present invention or embodiment.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.