Class OctaveFreqScale
Inherited Members
Namespace: AudioAnalysisTools.DSP
Assembly: AudioAnalysisTools.dll
Syntax
public static class OctaveFreqScale
Methods
| Improve this Doc View SourceConvertAmplitudeSpectrogramToFreqScaledDecibels(Double[,], Double, Int32, Double, FrequencyScale)
This method is octave frequency scale equivalent of MFCCStuff.DecibelSpectra(dspOutput.AmplitudeSpectrogram, dspOutput.WindowPower, sampleRate, epsilon) The MFCCStuff method is the proper way to convert amplitude spectrogram to decibels. It converts an amplitude spectrogram to a power spectrogram having specified frequency scale. It transforms the amplitude spectrogram in the following steps: (1) It removes the DC row or bin 0 iff there is odd number of spectrogram bins. ASSUMPTION: Bin count should be power of 2 from FFT. (2) Then reduce the linear scale to an octave scale depending on the sr and required number of bins or filters. (3) It converts spectral amplitudes to power, normalising for window power and sample rate. The window contributes power to the signal which must subsequently be removed from the spectral power. Calculate power per sample. See notes in the MFCCStuff.DecibelSpectra for further exp[lanaitons. These normalisations were adapted from MatLab MFCC code. (4) It converts the power spectrogram to decibels.
Declaration
public static double[, ] ConvertAmplitudeSpectrogramToFreqScaledDecibels(double[, ] amplitudeM, double windowPower, int sampleRate, double epsilon, FrequencyScale freqScale)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | amplitudeM | The amplitude spectrogram. |
Double | windowPower | FFT window power comes from DSP_Frames.WindowPower. |
Int32 | sampleRate | of the original signal. |
Double | epsilon | dependson bit-rate of the original signal. |
Frequency |
freqScale | In this case an octave frquency scale. |
Returns
Type | Description |
---|---|
Double[,] | The decibel spectrogram. |
ConvertAmplitudeToPowerSpectrogram(Double[,], Double, Int32)
Converts Amplitude Spectrogram to Power Spectrogram. Square the amplitude values to get power. Power values must be adjusted for the power in the FFT window and also for the sample rate. Must divide by the window power to remove its contribution to amplitude values. Must divide by sample rate to get average power per signal sample. NOTE: Multiply by 2 to accomodate two spectral components, ie positive and neg freq. BUT the last nyquist bin does not require a factor of two. However this method is called only by octave reduced frequency scales where the nyquist bin is just one of several.
Declaration
public static double[, ] ConvertAmplitudeToPowerSpectrogram(double[, ] amplitudeM, double windowPower, int sampleRate)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | amplitudeM | The frequency scaled amplitude spectrogram. |
Double | windowPower | Power of the FFT window. |
Int32 | sampleRate | The sample rate of the original recording. |
Returns
Type | Description |
---|---|
Double[,] | The Power Spectrogram as matrix. Each spectrum is a matrix row. |
ConvertLinearSpectrogramToOctaveFreqScale(Double[,], FrequencyScale)
Converts a spectrogram having linear freq scale to one having an Octave freq scale. TODO: SHOULD DEVELOP A SEPARATE UNIT TEST for this method.
Declaration
public static double[, ] ConvertLinearSpectrogramToOctaveFreqScale(double[, ] inputSpgram, FrequencyScale freqScale)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | inputSpgram | |
Frequency |
freqScale |
Returns
Type | Description |
---|---|
Double[,] |
GetDataReductionScale(FrequencyScale)
This method assumes that the linear spectrum is derived from a 512 frame with sr = 22050. It is a split linear-octave scale. The linear part is from 0-2 kHz with reduction by factor of 8. The octave part is obtained by setting octave divisions or tone count = 5.
Declaration
public static FrequencyScale GetDataReductionScale(FrequencyScale scale)
Parameters
Type | Name | Description |
---|---|---|
Frequency |
scale |
Returns
Type | Description |
---|---|
Frequency |
a frequency scale for spectral-data reduction purposes. |
GetFractionalOctaveBands(Double, Double, Int32)
Declaration
public static double[] GetFractionalOctaveBands(double minFreq, double maxFreq, int octaveDivisions)
Parameters
Returns
Type | Description |
---|---|
Double[] |
GetFractionalOctaveBands(Double, Int32)
Returns an array of tones in one octave. The units are frequency in Hertz. NOTE: The octave is divided geometrically.
Declaration
public static double[] GetFractionalOctaveBands(double lowerBound, int subbandCount)
Parameters
Type | Name | Description |
---|---|---|
Double | lowerBound | The lower frquency bound of the octave. |
Int32 | subbandCount | The number of tones or frequency bins in the octave. |
Returns
Type | Description |
---|---|
Double[] | The frequency of each tone in the octave. |
GetGridLineLocations(Int32, Int32, Int32[,])
Declaration
public static int[, ] GetGridLineLocations(int nyquist, int linearBound, int[, ] octaveBinBounds)
Parameters
Returns
Type | Description |
---|---|
Int32[,] |
GetStandardOctaveScale(FrequencyScale)
Calculates the parameters for a standard mixed linear-octave frequency scale. IMPORTANT: It assumes that the nyquist, frame size and linear bound have already been set to valid values. What makes this scale "standard" is that the number of octaveDivsions/tones (T) is set equal to number of linear bins. The remainder of the spectrum will be reduced over T-tone octaves. Sensible values for linearUpperBound are 125, 250, 500, 1000. Note that when linearUpperBound = 500, the resulting spectrogram is very similar to the default MelScale. When nyquist=11025 and frameSize = 512, the default MelScale has 64 frequency bins and Linear500-octave has 66 frequency bands.
Declaration
public static FrequencyScale GetStandardOctaveScale(FrequencyScale scale)
Parameters
Type | Name | Description |
---|---|---|
Frequency |
scale |
Returns
Type | Description |
---|---|
Frequency |
LinearToFullOctaveScale(Int32, Int32, Int32, Int32, Int32, Int32)
Returns the index bounds for a full octave scale - from lowest freq set by user to top freq.
Declaration
public static int[, ] LinearToFullOctaveScale(int sr, int frameSize, int finalBinCount, int lowerFreqBound, int upperFreqBound, int octaveDivisions)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sr | Sample rate of the source recording. |
Int32 | frameSize | Frame size of the source recording. |
Int32 | finalBinCount | Final Bin Count. |
Int32 | lowerFreqBound | Lower bound of the octave part of the final scale. |
Int32 | upperFreqBound | Upper bound of the octave scale, most likely the Nyquist. |
Int32 | octaveDivisions | Number of tones/divisions per octave. |
Returns
Type | Description |
---|---|
Int32[,] |
LinearToSplitLinearOctaveScale(Int32, Int32, Int32, Int32, Int32)
Returns a matrix that is used to transform a spectrum having linear Hz scale into a spectrum having an octave freq scale. The returned matrix is size N x 2, where N = the length of the output spectrum. In fact the op spectrum has a split Herz scale - bottom part linear, top part octave scaled. Column 0 of the returned matrix contains the index into linear spectrum. Column 1 of the returned matrix contains the Hertz value of the corresponding index into the linear spectrum.
Declaration
public static int[, ] LinearToSplitLinearOctaveScale(int nyquist, int frameSize, int lowerFreqBound, int upperFreqBound, int octaveDivisions)
Parameters
Type | Name | Description |
---|---|---|
Int32 | nyquist | |
Int32 | frameSize | |
Int32 | lowerFreqBound | |
Int32 | upperFreqBound | |
Int32 | octaveDivisions |
Returns
Type | Description |
---|---|
Int32[,] |