3-1 Department of Electrical Engineering McGill University 16/10/2006 Experiment 3 Scalar Quantizer 1 Purpose In this experiment, we explore several methods to discretize the amplitude of an analog signal, for example a recorded speech signal. Some measures will be introduced to compare the original signal with the processed signal to determine the effect of the quantizer. In general, it is desirable to minimize (in some sense) the amount of distortion for a given number of quantizer output levels. 2 Background Theory 2.1 Definition A quantizer is a memoryless non-linear device, which has discrete output levels, usually a finite number. A quantizer is completely specified in terms of its input-output characteristic by input decision levels and output levels. As shown in Eq (1),output level yk occurs if the input value lies in the interval defined by the decision levels, xk and xk-1, x k −1 < x ( n ) ≤ x k ⇒ y ( n ) = Q [ x ( n )] = y k (1) The purpose of a quantizer is to allow the output levels to be represented by a digital code. As such, the number of output levels is a power of two, i.e. two raised to the power of the number of bits needed to represent the output levels. The binary code can be used for digital transmission, for example. Quantizers are convenient for modelling the operations of an A/D and D/A converter pair. From a signal representation point of view, the output level is meant to closely represent the input value. The staircase quantizer characteristic is used to approximate a line of unit slope. The quantizer characteristic wanders around this line. 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 Output Output 3-2 0 0 −0.2 −0.2 −0.4 −0.4 −0.6 −0.6 −0.8 −0.8 −1 −1 −0.5 0 Input 0.5 −1 1 −1 −0.5 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 −0.2 −0.4 −0.4 −0.6 −0.6 −0.8 −0.8 −1 −0.5 0 Input (c) 1 0.5 1 0 −0.2 −1 0.5 (b) Output Output (a) 0 Input 0.5 1 −1 −1 −0.5 0 Input (d) Figure 1: Some input-output relationships for symmetric quantizers: a) Uniform mid-tread; b) Uniform mid-riser; c) Non-uniform mid-tread; d) Non-uniform mid-riser 2.2 Quantizer types Different types of quantizers are shown in Fig. 1. The output levels can be uniform or nonuniform. In addition if the quantizer is symmetric about the origin, then there are two cases: a mid-tread characteristic and a mid-riser characteristic. For the mid-tread characteristic, the origin lies at the mid-point of stair “tread”; for the mid-riser characteristic, the origin lies at the mid-point of a stair “riser”. Of course, the definition of the quantizer is general enough not to require any symmetry at all. 3-3 2.3 Quantization Error Quantization error is defined as: e q ( n ) = x ( n ) − Q [ x ( n )] (2) where x(n) is the input and Q[x(n)] is the quantized output. Based on certain assumptions, the quantization error is proportional to the quantizer step size. Since the quantizer has a finite number of output levels, input signals much larger than the largest output level cannot be represented accurately - the signal is in the overload or clipping region. Coarse quantization occurs when the effective dynamic range of the input signal is much smaller than the dynamic range of the quantizer. It is desired that the dynamic range of the input signal, which is proportional to its standard deviation, match the range of the quantizer in order to avoid frequent clipping or coarse quantization. The performance of the quantization depends mostly on how well the step size and the upper and lower limits match the input signal. We need to encode large signals as well as small signals. In other words, this will mean that we need a small step size for small inputs and a large step size for large signals. The quantization error may be considered to have two components, the granular error and the overload error. Granular error occurs when the input analog signal is within the range of the quantizer. Overload error occurs when the range of the signal exceeds that of the quantizer. In the granular region, the error magnitude is of the order of the step sizes in the quantizer, while in overload, large differences between signal and quantizer output can occur. Fig. 2 shows a uniform quantizer and a non-uniform quantizer. For the uniform quantizer, the error remains below ± 12 the step size for input levels below 1 - this is the granular noise region. Signals with levels above 1 get into the overload region. For the non-uniform quantizer, in the granular region, the maximum error depends on the step size. For the example, the maximum error is smallest near the origin. For a non-uniform quantizer, the beginning of the overload region is not well defined, but could be considered to start at half a step above the maximum output level. 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 Output Output 3-4 0 0 −0.2 −0.2 −0.4 −0.4 −0.6 −0.6 −0.8 −0.8 −1 −1 −0.5 0 Input 0.5 −1 1 0.5 0.5 0.4 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0 −0.1 −0.2 −0.2 −0.3 −0.3 −0.4 −0.4 −1 −0.5 0 Input 0 Input 0.5 1 0 −0.1 −0.5 −0.5 (b)Non-uniform Quantizer Error Error (a) Uniform Quantizer −1 0.5 −0.5 1 (c) Error - Uniform Quantizer −1 −0.5 0 Input 0.5 1 (b)Error - Non-uniform Quantizer Figure 2: Quantization Error 2.4 Optimal Quantization Usually an optimal quantizer is referred to a quantizer which minimizes the variance of the quantization error, defined for a quantizer with N output levels as: { } N xi E eq2 = ∑ ∫ ( x − y i ) 2 p ( x)dx i =1 xi −1 (3) 3-5 where p(x) is the probability density function of the input signal and N is the number of output levels. Two extra decision levels are defined as x0 = − ∞ and xN = ∞ . In general such a quantizer has non-uniform step sizes, with a smaller spacing in regions in which the probability density function is relatively large. It is straightforward to show that for a given set of output levels {yi}, having the decision levels lie mid-way between the output levels minimizes the error. With such a choice, an input signal is quantized to the nearest output level. To minimize the variance of the quantization error for a given set of decision levels, the output levels should be the centroid of the probability density function between the decision levels. An optimal (minimum error variance) quantizer is one, which the decision levels lie mid-way between output levels and the output levels are the centroids of the regions between decision levels. 2.5 Uniform Quantization A quantizer is uniform if the distance between adjacent output levels (the step size Δi) is constant and is equal to Δ. Under this constraint, the quantizer is specified by a step size and an offset. If we further constrain the quantizer to be symmetric, only the step size is to be chosen. Consider a symmetric uniform quantizer for an input signal whose magnitude is bounded by xmax. • The step size which minimizes the maximum error is equal to: Δ= 2 ⋅ x max N (4) where the number of output levels can be expressed as N = 2R where R is the number of bits in the quantizer. This choice of Δ avoids quantizer overload. • With no overload, the quantization error takes values in the following range: − • Δ Δ ≤e≤ 2 2 For a large number of output levels, and a signal which is changing, the quantization error is often assumed to have uniform distribution, ⎧1 ⎪ p e ( x) = ⎨ Δ ⎪⎩0 • (5) Δ 2 otherwise if | e |≤ (6) For a uniformly distributed error, the variance of the quantization error is: σ e2 = x2 Δ2 = max 2 12 3 ⋅ N (7) 3-6 2.6 Robust Quantization The most common means for transforming an amplitude-continuous random input signal into a discrete amplitude input is uniform quantization. However, for a signal with a non-uniform probability density function, a non-uniform quantizer matched to that probability density results in a low error variance. Robust quantizers try to give good performance for a variety of input signals. In particular, consider quantizing voice signals at a telephone switching office. Some customers speak softly, while others speak loudly. Also customers far away from the central office will suffer more attenuation that customers near to the exchange. Consider designing a quantizer whose performance is largely independent of the “loudness”. We choose small quantizer steps for small signals and larger steps for larger signals, with the goal of having the signal-to-quantization noise ratio be about the same for the two cases. This results in a quantizer with non-uniform step sizes. A general non-uniform quantizer can be achieved by a combination of a compressor, uniform quantizer and expander. The signal x is processed using a non-linear compressor characteristic c(⋅) , for example a logarithmic function, before being quantized by a uniform quantizer. The quantized signal is then expanded using the inverse c −1 (⋅) to the compression function. These operations are shown in Fig. 3. The compressor characteristic c(⋅) is sometimes called the (compressing and expanding) companding law. The most common methods for nonuniform quantization are μ-law (used in North American telephony) and A-law (used in Europe) companding. These companding laws are logarithmic in nature and result in a robust quantizer, i.e. one whose performance, which is relatively insensitive to the statistics and volume of the input signal. This usually entails a trade-off. An optimal quantizer for a given input signal will outperform a compromise quantizer designed to accommodate a variety of input signals. However, the compromise quantizer may do better if the input signal deviates from the assumed statistics. The compression characteristic function for the μ-law quantizer is: c( x) = x max log e (1 + μ | x | / x max ) sgn( x) log e (1 + μ ) c −1 ( x) = x max 1 μ [(1 + μ ) | xˆ|/ xmax − 1] sgn( x) (8) (9) 3-7 C −1 (.) C (.) x compressor (a) C (x) Q(C ( x)) uniform quantizer (b) c(x) y expander c(x) xmax xmax c(.) -xmax xmax x Q[c(x)] -1 c (.) (d) (c) y x y Q[c(x)] Figure 3: The use of compression function c(x) to realize a nonuniform quantizer characteristic: (a) The input passes through the compressor function defined in the text (b) As an example, a mid-riser uniform quantizer is applied to the signal at the output of the compressor (note that the vertical axis in this plot corresponds to the input of the quantizer) (c) An expander function maps the output levels to the final output (d) The combination of the last three stages can be used to build a non-uniform quantizer such as a μ-law Quantizer 3-8 2.7 Adaptive quantization In the last section, robust quantizers were introduced to achieve relatively uniform performance for different types of input signals. Specifically, the performance is relatively constant for a range of signal input levels. An alternate approach is to use the adaptive companding approach introduced for analog transmission. Such a scheme is used for Dolby noise reduction for cassette tapes. For a quantizer, the adaptive companding operation can be viewed either as a normalization of the signal before quantization, or as the equivalent change in quantizer step size. The means to reduce overload and granular distortions is to make the quantizer step size follow the local behaviour of the input signal. The decoder can derive scaling information either implicitly or explicitly. In the latter case, the step size or normalization information is explicitly transmitted as side information to the decoder. In the former, step size information is derived from the transmitted signal. In the absence of transmission errors, the step size information can be determined both by the encoder and the decoder without the necessity to transmit it explicitly. Figure 4 shows block diagram of an adaptive quantizer. In this model, the input of a uniform quantizer is normalized to reduce granular distortion. To avoid the need to send auxiliary information to the decoder, the output of the quantizer is utilized to update the normalization factor, σ(n). Since the decoder also receives the output of the quantizer, the step size information can be extracted from the received signal. The form of adaptation where no side information is sent across the communication channel is usually called self-adaptive quantizer. x(n) • x ( n) σ ( n ) • 3 Bit Uniform Quantizer update σ[n] z (n) Channel r (n) Χ y (n) estimate σ[n] Figure 4: Block Diagram of the Adaptive Quantization 3 Preparation: • For your preparation, read Oppenheim and Schafer [1], Section 4.8.2 and 4.8.3 or Proakis and Manolakis [2], Section 9.2. and 9.2.3. • Bring a walk-man stereo headphone for listening to speech files. Walk-man headphones come with mini-plugs that will match PC headphone jacks. 3-9 1. Sketch the quantization error vs. input signal level for a four level mid-riser and a four level mid-tread quantizer. Compare mid-riser and mid-tread quantizers in terms of the quantizer error characteristics, specifically consider low amplitude signals. Note that the outer quantization levels (for a symmetrical quantizer) should be Δ/2 below the maximum signal amplitude. Explain why. 2. Read the help file for ‘quantiz.m’ file in Matlab. Explain the terms ‘codebook’ and ‘partition’. 3. What step size would you specify for a 1-bit quantizer to minimize the meansquare quantization error for a Gaussian input signal with unit variance?(Hint: exploit symmetry in setting up your integral and then differentiate.) What would be the step size if the variance is σ2 instead of unity? 4. Repeat previous part for sine-wave input with unit amplitude. (Hint: You need to determine the probability distribution function (pdf) of a sine-wave with random phase. You can define a uniform random variable θ, defined in the interval [-π, π) then determine the pdf of sin(θ). 5. Specify a 3-bit symmetric uniform quantizer with a step size Δ equal to 1/2. In order to fully specify a quantizer, you should specify decision levels as well as output levels. Repeat this part for a 3-bit symmetric uniform quantizer to handle an input signal with unit maximum input level. 6. Consider a symmetric uniform quantizer with 32 levels designed with an overload point of xmax. Fig. 5 shows a plot of SQNR in dB (see Section 4.3) against signal level for signal with uniformly distributed amplitude. The signal level is given as the normalized value σ/xmax expressed in dB. Theoretically, at what value of σ/xmax does the peak occur? What is the asymptotic value of SQNR for large σ/xmax? Theoretically, for each halving of the signal level (6 dB decrease) below the peak value, what is the decrease in SQNR? What causes the “wiggles” in the curve? What happens to the SQNR for very small values of σ/xmax? 7. Using Fig. 3, explain how you can compute the decision levels and the output levels of μ-law quantizer from the decision levels and the output levels of a uniform quantizer. Specify a 3-bit non-uniform μ-law quantizer with unit maximum input level and μ equal to 7. Repeat this part for μ equal to 255. In each case you should specify the decision levels as well as the output levels of your quantizer. What value of μ corresponds to a uniform quantizer? 8. Read Appendix 3-C carefully and explain the following terms: SQNR, SQNR(m) and SQNRseg. 3-10 30 SQNR (dB) 20 10 0 -40 -30 -20 -10 Signal Level (dB) 0 10 20 Figure 5 SQNR vs. signal level for a symmetric 32-level uniform quantizer with a uniformly distributed input signal 4 Experiment: Because this experiment is quite involved, you should read and think through the whole task before charging ahead. Organize your processing steps into stages. Coordinate with your partner; you might consider dividing the sub-tasks between the two of you. Plan ahead the various points in the system where you want the signals monitored. This would facilitate your debugging and understanding. 4.1 Source Generation: You will use your own generated signals as well as a recorded speech signal to analyze several quantizers that you will implement. Using Matlab you will generate discrete Sine wave and Gaussian input signals. Verify the correctness of your signals by looking at a histogram of the signal levels. These should agree with the probability density functions for sine and Gaussian signals. As a part of the experiment, you will also use a speech signal “speech.wav”, available on the web page. 4.2 Uniform Quantization: • Implement a 3-bit symmetric uniform quantizer designed to handle an input signal with unit maximum level. First, use the MATLAB function “quantiz.m” directly to 3-11 specify your quantizer. Then use the procedure described in Appendix 3-A to generate a SIMULINK quantizer block • You may use DSP Blockset>Sources>Sine Wave to generate a sine-wave as input. Set the frequency to 0.01 and sampling frequency to 1 Hz and the amplitude to 2. You can also write your own MATLAB script to generate such a signal. • Plot the input-output characteristics of your quantizer. An acceptable plot should not contain any hysteresis close to the center. • Determine the quantization error. Give a comment on the type of error you observe (granular, overload error). • Plot the Histogram to determine the distribution of the error. Give a comment on the distribution. • Determine the quantization error as a function of the input. This can be generated by obtaining the X vs. Y plot. Specify the granular and overload noise in your plot. 4.3 Quantization Distortion Measure One measure of quantization distortion is signal-to-quantization-noise ratio SQNR. To compute this, one must first obtain the quantization “noise” by subtracting the output signal from the original input. SQNR can be defined as the ratio in dB between the power of the input signal and the power of the quantization noise, given as follows: ⎛P SQNR = 10 log10 ⎜⎜ in ⎝ Perr ⎞ ⎟⎟ ⎠ (10) NON-SEGMENTAL SQNR • Construct in Simulink an “SQNR meter” module that accepts two input signals. One input is the error or the noise signal and the other is the original reference signal. In order to obtain the error signal, subtract the processed signal from the quantizer output. • Find the power of the original and error signals, by treating each signal as a single block. • Using aforementioned blocks, determine the power ratio of the original and the error signal and consequently find SQNR in dB scale. SEGMENTAL SQNR • Design a method, in either Simulink or Matlab, to take segments of data. Compute the power of each segment, and perform a segmental division of the original reference signal and the error signal. • Find the SQNR, in dB scale. The average of all the segments is the segmental SQNR of the reference signal against the error signal. 3-12 • To test the performance of both the measures compute the SQNR for a Gaussian signal of sufficiently large length. Compare the two SQNR measures and judge, which is the better one. 4.4 Quantizer Performance Plot A Quantizer performance plot shows SQNR (in dB) as a function of input signal power (in dB). Clearly a robust quantizer should maintain its high SQNR for a wide range of input signal power. Using SQNR meter designed previously, determine performance plots of different quantizers. • You need to generate input signals with different power levels. You may instead create a composite signal containing different segments with increasing power levels. This signal may be generated in Matlab and imported from workspace to Simulink. To import a signal from workspace use the following block; DSP Blockset>Sources>From Workspace. It is preferred to have increasing segmental power in powers of ten. WHY? • Use the segmental SQNR meter to determine SQNR(m) for each segment of your signal. • Sketch the quantizer performance plot for the 3-bit uniform quantizer you built in Section 4.2 for the composite sine-wave input signal. Explain intuitively what values for SQNR you expect to see when the input power level is very small or very large. Verify your answer using the performance plot you obtained. • Determine the performance plot for the composite Gaussian input. Comment on your result (explain different sections of the plot). 4.5 Robust quantizer In this experiment, we use a μ-law compander to implement a Non-uniform quantizer. The idea behind it is to use a compression characteristic function and its inverse to reshape the uniform quantization. These equations were given in the background theory, (8) and (9). • Using a cascade of the Table Lookup Block (found in Simulink> Lookup Tables>Lookup Table), uniform Quantizer Block, and Table Lookup Block implement a 3-bit μ-law quantizer. Set xmax to one, and design your intermediate uniform quantizer to have unit maximum output level. For hints on how to set up a non-uniform quantizer built around a uniform quantizer, check Appendix 3-B. Try two different values for μ, 7 and 255 for example. • Find the performance plot (SQNR vs. input power in dB) for a sine-wave as well as a Gaussian input signal for your non-uniform quantizer. • Which value of μ is most appropriate for 3-bit quantizer? Compare to input signals’ PDF. 3-13 4.6 Adaptive quantization Now we explore adaptive quantization, aiming to gauge its improvement over uniform and non-uniform quantization. Speech signals are not stationary, i.e. its statistics vary from one time epoch to the next. Over a short time epoch, say 20 ms, speech may be considered stationary. In uniform and non-uniform quantization, the quantizer step size and the limits of the quantizer are tuned for the long-term statistics of speech; they are compromise values that are not the best for any particular short segment of speech. In the most general ADPCM coders, both the step size and the limits predictor coefficients are adapted to track changing signal statistics. In the adaptive quantizer that you are about to design, the step size is adjusted based on the standard deviation of previous quantized samples. Figure 6 shows a simplified block diagram of the adaptive quantizer. Note that in this model the channel impairment is ignored and the output of the standard deviation updating block is directly used to determine the final output y(n). x(n) • x ( n ) σ ( n) • 3 Bit Uniform Quantizer Q[ x(n)] Χ y (n) update σ[n] Figure 6: Block Diagram for Adaptive Quantization • Design standard deviation updating block such that it satisfies the following conditions: σ n +1 = M (Q[ x(n)])σ n (11) where M (⋅) is a function of the quantizer output levels. • You can implement M(Q[x(n)]) using look-up table block. The input values of the look-up table are uniform quantizer output levels. The output values of the table are initially set to one. 3-14 • For an input signal which is assumed to never exceed xmax the estimate σ is allowed to vary over a 100:1 range, preventing it from getting too small or too large, 0.01x max < σ n < x max (12) Use an appropriate non-linear block such as ‘saturation’ to keep σ in the appropriate range. • Find the performance plot for sine-wave and Gaussian input. For each type of input make appropriate changes to the output values of the look-up table to get the best results possible. • Compare the performance of uniform, non-uniform and adaptive quantizer for sinewave and Gaussian inputs. It would be useful if you overlay the plots and compare them for each input. This can be done in Matlab by using the ‘hold on’ and ‘hold off’ functions. For details read through the help files of the respective functions in Matlab. 4.7 Speech test signal • Apply the audio file speech.wav to all three quantizers. Find the SQNR(m) for each frame of 20 ms of the speech signal as well as SQNR and SQNRseg for each quantizer (see Appendix 3-C). Note that the sampling frequency of the original speech.wav is 16kHz. You will have to compute the number of samples per segment to obtain a frame length of 20ms. Compare the results. • For each quantizer, evaluate the quality of the quantized speech signal by listening to it after processing. Provide a subjective comparison between the original speech and the quantized one. In speech processing, objective measures such as SQNR are meaningful only to the extent they correlate well with subjective listening quality. Ascertain whether such correlation exists for this experiment. • Use “wavread” command in MATLAB to read in the speech.wav signal. • You can listen to your output on the earphones that you brought to the lab by invoking the following command in the MATLAB prompt: Sound(file_name) 5 Report (A) Considering data transmission subjected to channel error, compare adaptive quantizer and other types of quantizers in terms of performance. (B) Give a comment on subjective test of the speech. Compare your subjective test results with SQNRseg results for three different types of quantizers that you examined in this experiment. Are the results consistent? (C) Compare the three different quantizers examined in this lab in terms of performance and complexity. 3-15 3-A Using the Quantizer Block Matlab has a built in m-file (quantiz.m) for a generic quantizer. Read the help file for this function in Matlab. In Matlab parlance, a codebook is essentially a range of data that specifies the boundaries of the input signal vector. A partition is a vector of output levels chosen to describe the mapping of the input signal to decision levels. In the case of the uniform quantizer the decision levels are described in equations 13 and 14. Once you have designed the vectors you can use MATLAB’s ability to convert the function into a block to be used in Simulink. For more details on this see 3-A.1. Based on the following theory and quantiz function one can design the codebook and partition vector to generate either a mid-tread or a mid-riser uniform quantizer. Δ= x max − x min N (13) The decision levels ({xi}) and the output levels ({yi}) are xi = x min + (i + 1)Δ for 0 ≤ i ≤ N − 2 1 y i = x min + (i + )Δ 2 for 0 ≤ i ≤ N − 1 (14) 3-A.1 How to make your own block out of a *.m file and import in Simulink Simulink has the provision to import a Matlab function as either a Matlab function or an S-function. The benefits of using an S-function are directly related to its ease of manipulation and speed of processing functions. S-functions can also be used to run Cfiles as blocks in Simulink. In order to implement an S-function you will have to: • Copy ‘sfuntmpl.m’ in the working directory. This is a template m-file that guides you how to assign and define variables. You can see demonstrations and examples of how to use and write S-functions as M-files under Simulink>UserDefined Functions->S-function examples. MATLAB supports two types of Mfile S-functions, “Level-1” and “Level-2”. Even though Level-1 functions might be easier to write, their usage is deprecated and they are provided for backwards compatibility only. • Modify and assign variables within the sfuntmpl.m file. • Save it as ‘file_name.m’. • In Simulink, load the following block; o Simulink>User-Defined Functions>S-Function • Within the s-function block, you will call ‘file_name’ in the ‘S-function name’ field. The partition and the codebook must be specified in the ‘S-function parameters’ field. You may also consider importing the Matlab function into Simulink by using the Matlab Function block provided in the following path: Simulink>User-Defined Functions>Matlab Function. 3-16 3-B Non-uniform Quantizer A non-uniform quantizer can be directly implemented using “quantiz.m” function in MATLAB. You only need to specify the decision levels (partitions) and the output levels (codebook) to specify your quantizer. Figure 3 shows implicitly how to derive the decision levels and the output levels of a μ-law quantizer from a uniform quantizer. Note that you only need to use c −1 ( x) function given in Eq. (9) to convert the decision levels and the output levels of a uniform quantizer to those of a μ-law quantizer. 3-C Quantization Distortion Measurement One measure of quantization distortion is signal-to-quantization-noise ratio (SQNR). To compute this, one must first obtain the quantization “noise” by subtracting the reconstructed quantizer output from the original input. SQNR can be defined as the ratio in dB between the power of the input signal and the power of the quantization noise, given as follows: ⎛P SQNR = 10 log10 ⎜⎜ in ⎝ Perr ⎞ ⎟⎟ ⎠ Since the conventional SQNR measure does not penalize the bad rendition of weak signals, we need another form of measure, which is the segmental SQNR (\SQNRseg). This measure belongs to the class of SQNR refinements. It will recognize the fact that the speech signal is non-stationary and that the same amount of noise has different perceptual values depending on the ambient signal level. The segmental SQNR is based on dynamic time weighting: specifically, a log-weighting that converts component SQNR values to dB values prior to averaging, so that very high SQNR values corresponding to well-coded large-signal segments do not camouflage coder performance with the weak segments as in conventional SQNR. The segmental SQNR is defined as: SQNRseg (dB) = E{SQNR(m) (dB)] (15) where SQNR(m) is the conventional SQNR for segment m, and the expectation is implemented as a time average over all segments of interest in the input sequence. An appropriate segment length in speech work would be in the order of 16-20 ms. Segments representing silences in speech may be considered as either important or not by the user. Table 1 shows the calculations for two frames. Segment Number m=1 m=2 Input signal Power 10 1 Error signal Power 1 1 SQNR (m) 100 1 3-17 SQNR (m) dB 20 0 Table 1: SQNRseg and conventional SQNR The resulting SQNR's are calculated as shown in the equations below. SQNR = 100 + 1 2 SQNRseg = 20dB + 0dB 2 (17dB) (16) (10dB) (17) Reference: [1] A.V. Oppenheim and R.W. Schafer with J.R. Buck, Discrete-Time Signal Processing. rentice Hall, 2nd ed., 1999. [2] J.G. Proakis and D.G. Manolakis, Digital Signal Processing, Prentice-Hall, third ed., 1996.