SbSmoothFract32
Overview
Subband smoothing across frequency bins
Discussion
This module performs smoothing across frequency bins. Smoothing is done by averaging multiple bins to the left and right of a particular frequency sample. The smoothing only operates on real data. To smooth complex data it must first be decomposed into real and imaginary components.
The module supports two different forms of smoothing. In linear smoothing (type = 0), N bins to the left and N bins to the right of each bin are averaged, where N is a fixed number. The number of bins N is specified by the parameter .width, and .width is specified in Hz. If a bin is centered at frequency F, then the bins in the range [F-width F+width] are averaged.
In logarithmic smoothing (type = 1), M samples to the left and N samples to the right are averaged. .width then equals the number of octaves to the left and right that are averaged. If a bin is centered at frequency F, then the bins in the range [F*2^(-width) F*2^(width)] are averaged.
The module also checks to make sure that all of the bins to average are within the valid range. That is, the lower bin index is never less than 0 and the upper bin index never exceeds blockSize - 1.
Internally, the module uses a cumulative sum of values to reduce computation time. With this approach, the execution time is always a fixed constant independent of the smoothing width. Several hidden arrays are computed by the set function and used by the process function. startIndex[] and endIndex[] specify the starting and ending index of the cumulative sum to use. oneOverN[k] = 1 / (endIndex[k] - startIndex[k] + 1) and is used to speed up calculation of the average without requiring a divide. The module's process function computes (cumSum[endIndex[k]] - cumSum[startIndex[k]]) * oneOverN[k].
The module also supports a custom smoothing (type = 2). When custom smoothing is engaged, you have to manually set the 3 arrays startIndex[], endIndex[], and oneOverN[].
The parameter .startFreq allows you to specify that certain low frequency bins should not be smoothed. Only bins above .startFreq Hz are smoothed.
The module is designed to work with the wola_analysis_subsystem.m and the sample rate specified equals the decimated subband sample rate.
Type Definition
typedef struct _ModuleSbSmoothFract32
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 type; // Determines which type of smoothing is applied: Linear=0, Logarithmic=1, Custom=2
FLOAT32 startFreq; // Starting frequency for the smoothing operation
FLOAT32 width; // Amount of smoothing
INT32* startIndex; // Starting index for the averaging process.
INT32* endIndex; // Ending index for the averaging process.
fract32* oneOverN; // Precomputed 1/N for averaging.
fract32* cumSum; // Cumulative sum of values from the start of the buffer. This holds 64-bit values.
} ModuleSbSmoothFract32Class;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
type | int | parameter | 0 | 1 | 0:2 | |
startFreq | float | parameter | 0 | 0 | 0:24000 | Hz |
width | float | parameter | 0 | 0.1667 | 0:2400 | |
startIndex | int* | derived | 1 | [257 x 1] | Unrestricted | |
endIndex | int* | derived | 1 | [257 x 1] | Unrestricted | |
oneOverN | fract32* | derived | 1 | [257 x 1] | Unrestricted | |
cumSum | fract32* | state | 1 | [516 x 1] | Unrestricted |
Pins
Input Pins
Name: in
Description: audio input
Data type: fract32
Channel range: 1
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: audio output
Data type: fract32
MATLAB Usage
File Name: sb_smooth_fract32_module.m
M = sb_smooth_fract32_module(NAME, BLOCKSIZE)
Subband smoothing module which performs averaging across frequency
bands. The module supports linear or logarithmic smoothing across
bands and operates on fract32 data. Arguments:
NAME - name of the module.
BLOCKSIZE - initial BLOCKSIZE (the final BLOCKSIZE is taken from the
input wire).
Copyright 2011-2020. DSP Concepts, Inc. All Rights Reserved.