Streaming Normalization
A normalization for streaming digital audio signals applies a gain factor according to the maximum sample magnitude in a window of samples and compare the gain factor to prior gain factors to adjust the gain factor for the samples in the window of samples. Adaptation of the gain factor with rapid decreases but slow increases avoids saturation but allows quiet passages.
Latest TEXAS INSTRUMENTS INCORPORATED Patents:
- BAW RESONATOR BASED OSCILLATOR
- Calibration of a surround view camera system
- Processor micro-architecture for compute, save or restore multiple registers, devices, systems, methods and processes of manufacture
- Radar system implementing segmented chirps and phase compensation for object movement
- Electrostatic discharge protection circuit
This application claims priority from provisional patent application Ser. No. 60/308,066, filed Jul. 25, 2001.
BACKGROUNDThe present invention relates to electronic devices, and more particularly to methods and devices for playout of digital audio signals.
Digital audio has become widespread for both stored media (e.g., CDs) and streaming media (e.g., real-time from the Internet). For stored digital audio the entire file is available, so the dynamic range can be assessed. Contrarily, for streaming audio such as over the Internet, only the current portion and the past of the file being played is available, so the future dynamic range, in both the short run and the long run, cannot be assessed. This inhibits optimal usage of the playout system.
SUMMARY OF THE INVENTIONThe present invention provides a normalization for playout of streaming signals; the normalization boosts quite small signal portions to take advantage of system dynamic range but quickly drops the boost in response to increases in the signal magnitude.
Advantages include use of full dynamic range for streaming audio.
BRIEF DESCRIPTION OF THE DRAWINGSThe Figures are heuristic for clarity
Preferred embodiments provide methods of normalization (dynamic automatic gain control) for streaming digital audio; this allows optimal use of the dynamic range of the playout system. The methods analyze incoming samples and determine a normalization based on both the short-term and the long-term characteristics of the received samples. Initially, the normalization is held at 1.0 to learn something about the incoming signal, and thereafter it follows the reciprocal of a long-term average of sample magnitudes except it avoids saturation by rapid decrease for large short-term signal increases.
Generally, after any depacketization of signals to a playout buffer, the preferred embodiments window the incoming samples (window size N) and determine the maximum sample value in the current window of N samples. From the maximum sample value in the current window, compute a current gain factor, gFc, needed to normalize this maximum sample value. For example, the normalization may simply be the ratio of a system arbitrary maximum sample value divided by the maximum sample value of the current window. Use the information in gFc for the current window together with the gFc's of one or more prior windows to compute a normalization gain for the samples of the current window or for a subset of K of the N samples of the current window (including a normalization for a single sample of the current window).
For example, the normalization gain for the current window could be a simple function of the gFc of the current window and the normalization gain of a prior window such as (i) normalization gain of current window equals gFc if gFc is smaller than the normalization gain of a prior window and (ii) normalization gain of the current window is a linear combination of gFc and the normalization gain of a prior window if gFc is greater than the normalization gain of a prior window. That is, the example normalization gain tracks gFc when decreasing (samples increasing in size) relative to prior windows normalization and slowly increases by weighting with gFc when increasing (samples decreasing in size) relative to prior windows.
2. First Preferred Embodiments In a first preferred embodiment system (e.g.,
First, take the variable Count as a counter to indicate the sample to be output to the speakers (digital or a DAC plus analog speakers). Further, presume the circular playout buffer is full and contains 128 samples (two blocks of 64 samples) and thus the sample in the playout buffer to be output is at buffer index Count % 128; where % is the modulo operator and the buffer index lies in the range 0 to 127. Each sample is 16 bits: 1 sign bit and 15 magnitude bits, so the maximum possible sample magnitude is 32K. The decoded stream typically represents audio samples taken at a sampling rate of 44.1 or 48 kHz, so a block of 64 samples covers a little more than 1 millisecond of the original audio signal.
Next, compute a current sample gain gFc by dividing the maximum magnitude 32K by the actual maximum sample magnitude in a window of 64 samples ending at the sample to be read out; that is, compute the maximum of the samples at buffer indices (Count-63)% 128 through Count % 128. Then constrain gFc to the range 1.0 to 3.47; note that gFc varies as the reciprocal of the actual maximum sample magnitude.
Update the normalization. Let gFp denote the normalization applied to the immediately preceding output sample, that is, the sample at (Count-1)% 128. The update method depends upon the relative sizes of gFc and gFp: if gFc≧gFp, then take updated gFp=0.9999984 gFp+0.0000016 gFc; whereas, if gFc<gFp, then take updated gFp=0.03 gFp+0.97 gFc.
Read out the sample at index Count % 128 in the playout buffer and apply (multiply by) the normalization gFp to the output sample.
Increment Count and check Count % 128, if Count % 128 equals 64, read in the next 64 samples to locations 0-63 in the playout buffer; this overwrites already-played-out samples. If Count % 128 equals 0, read in the next 64 samples to locations 64-127 in the playout buffer.
Lastly, repeat the foregoing steps for the next output sample and updated normalization until there are no more incoming samples.
3. Second Preferred EmbodimentA second preferred embodiment is analogous to the foregoing first preferred embodiment plus includes a long-term averaging control of the normalization. In particular, when the average sample magnitude over the last 1024 samples exceeds a level of 5000 (out of the maximum possible sample magnitude of 32K), trend the normalization towards 1.0 by updating gFp=0.9999 gFp+0.0001 and further when gFp<1.03, round down to gFp=1.0.
Code for the second preferred embodiment as applied to RIFF files could be as follows with various file naming, opening, and closing operations omitted for clarity plus some alternatives as to constants and gain adaptations indicated.
wherein the variables prevCount and avgCount count the samples, . . . .
Variations of the foregoing include replacing the normalization update limitation for the case of gFcurrent less than gFpast
with a simpler exact tracking of gFcurrent:
Similarly, for the case of gFcurrent greater than gFpast the rate of fade can be larger by replacing
and the recovery of the normalization after a drop (due to a jump in sample magnitude) could be generally done by:
gFpast=(((gFpast*HistWinSize)+gFcurrent)/(HistWinSize+1));
with HistWinSize taken in the range . . .
Third preferred embodiments modify some of the features of the foregoing preferred embodiments such as the normalization could be held at 1.0 for the first 10 seconds of playout in order to obtain initial sample statistics; that is, until the sample count (e.g., prevCount) reaches some level such as 480K (10 seconds at a sampling rate of 48 kHz). After this initialization: interval, the foregoing adaptations of gFpast would apply.
Further, the updated normalization tracking of the current gain then the current gain is less than the prior normalization could be nonlinear. For example, when for gFpast−gFcurrent <0.01, the update could be exact tracking:
gfpast=gFcurrent;
and when gFpast−gFcurrent >0.01. the update could be tempered:
gFpast−=((gFpast−gFcurrent)/1.03);
Further, the normalization update method could also depend upon the average sample magnitude over the prior 1024 samples. For example, when the average is small, then the rapid update gFpast=gFcurrent tracks samples jumping from small to large; but when the average is large (but less than TriggerLevel) the update could be slower such as gFpast−=((gFpast−gFcurrent)/1.03).
5. ModificationsThe preferred embodiments may be modified in various ways while retaining the feature of normalization for a streaming file.
For example, the various constants could be increased or decreased, such as MaxGainValue, TriggerLevel, InSize (the block size of 64 samples) AvgWindowLength (long-term average window); the current, gain could be computed using the maximum over a larger or smaller window than the block size; the length of the initial normalization=1 period could be expanded or contracted, the normalization may be updated only every second output (so the current gain need only be computed for every second sample) or more, . . .
Claims
1. A method of normalization for a sequence of digital signals, comprising:
- (a) finding a first gain factor for a first block of digital signals of a sequence of digital signals;
- (b) finding a second gain factor for a second block of digital signals; and
- (c) adjusting said second gain factor depending upon said first gain factor.
2. The method of claim 1, wherein:
- (a) said adjusting of step (c) of claim 1 (i) decreases said second gain factor when said second gain factor is greater than said first gain factor and (ii) increases said second gain factor when said second gain factor is less than said first gain factor.
3. The method of claim 2, wherein:
- (a) said adjusting of step (c) of claim 1 (i) decreases said second gain factor by an amount equal to a first constant multiplied by the difference of said second gain factor minus said first gain factor when said second gain factor is greater than said first gain factor and (ii) increases said second gain factor by an amount equal to a second constant multiplied by the difference of said first gain factor minus said second gain factor when said second gain factor is less than said first gain factor, wherein said first constant is larger than said second constant.
4. The method of claim 1, wherein:
- (a) said finding a second gain factor of step (b) of claim 1 uses the maximum digital signal value of the signals in said second block; and
- (b) said finding a first gain factor of step (a) of claim 1 uses gain factors of said first block plus other ones of said digital signals in said sequence of digital signals.
5. The method of claim 4, wherein:
- (a) said second gain factor is constrained to lie in the range 1/0 to K where K is a constant selected from a range of about 2 to 5.
6-8. (canceled)
9. A receiver for streaming signals, comprising:
- (a) a playout buffer to receive input signals;
- (b) a normalizer coupled to said playout buffer, said normalizer including a current gain circuit, a memory for a prior normalization, and a combiner circuit for updating a prior normalization with a current gain; and
- (c) an output coupled to said playout buffer and said normalizer.
Type: Application
Filed: Jan 15, 2008
Publication Date: May 15, 2008
Applicant: TEXAS INSTRUMENTS INCORPORATED (Dallas, TX)
Inventors: Timothy Hankins (Gainesville, FL), Thomas Millikan (Austin, TX), Christopher Scarr (Houston, TX), Jason Kridner (Houston, TX), Gabriel Dagani (Bluffton, OH)
Application Number: 12/014,188
International Classification: H03G 3/00 (20060101);