Class FrequencyScale
Inherited Members
Namespace: AudioAnalysisTools.DSP
Assembly: AudioAnalysisTools.dll
Syntax
public class FrequencyScale
Constructors
| Improve this Doc View SourceFrequencyScale(FreqScaleType)
Initializes a new instance of the FrequencyScale class. CONSTRUCTOR.
Declaration
public FrequencyScale(FreqScaleType fst)
Parameters
| Type | Name | Description |
|---|---|---|
| FreqScaleType | fst |
FrequencyScale(FreqScaleType, Int32, Int32, Int32, Int32)
Initializes a new instance of the FrequencyScale class. CONSTRUCTOR Calling this constructor assumes either Linear or Mel is required but not Octave.
Declaration
public FrequencyScale(FreqScaleType type, int nyquist, int frameSize, int finalBinCount, int hertzGridInterval)
Parameters
| Type | Name | Description |
|---|---|---|
| FreqScaleType | type | |
| Int32 | nyquist | |
| Int32 | frameSize | |
| Int32 | finalBinCount | |
| Int32 | hertzGridInterval |
FrequencyScale(FreqScaleType, Int32, Int32, Int32, Int32, Int32)
Initializes a new instance of the FrequencyScale class. CONSTRUCTION OF OCTAVE Frequency Scales IMPORTANT NOTE: If you are converting Herz scale from LINEAR to OCTAVE, this conversion MUST be done BEFORE noise reduction WARNING!: Changing the constants for the octave scales will have undefined effects. The options below have been debugged to give what is required. However other values have not been debugged - so user should check the output to ensure it is what is required. NOTE: octaveToneCount = the number of fractional Hz steps within one octave. A piano octave contains 12 steps per octave. NOTE: Not all combinations of parameter values are effective. nor have they all been tested. The following have been tested: nyquist=11025, linearBound=125 t0 1000, octaveToneCount=31, 32. nyquist=11025, linearBound=125, octaveToneCount=31. nyquist=32000, linearBound=125, octaveToneCount=28.
Declaration
public FrequencyScale(FreqScaleType type, int nyquist, int frameSize, int linearBound, int octaveToneCount, int hertzGridInterval)
Parameters
| Type | Name | Description |
|---|---|---|
| FreqScaleType | type | Scale type must be an OCTAVE type. |
| Int32 | nyquist | sr / 2. |
| Int32 | frameSize | Assumes that frame size is power of 2. |
| Int32 | linearBound | The bound (Hz value) that divides lower linear and upper octave parts of the frequency scale. |
| Int32 | octaveToneCount | Number of fractional Hz steps within one octave. This is ignored in case of custom scale. |
| Int32 | hertzGridInterval | Only used where appropriate to draw frequency gridlines. |
FrequencyScale(Int32, Int32, Int32)
Initializes a new instance of the FrequencyScale class. CONSTRUCTOR Calling this constructor assumes the standard linear 0-nyquist freq scale is required.
Declaration
public FrequencyScale(int nyquist, int frameSize, int hertzGridInterval)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | nyquist | |
| Int32 | frameSize | |
| Int32 | hertzGridInterval |
FrequencyScale(Int32, Int32, Int32, Int32)
Initializes a new instance of the FrequencyScale class. CONSTRUCTOR Call this constructor when want to change freq scale but keep it linear.
Declaration
public FrequencyScale(int nyquist, int frameSize, int finalBinCount, int hertzGridInterval)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | nyquist | |
| Int32 | frameSize | |
| Int32 | finalBinCount | |
| Int32 | hertzGridInterval |
Properties
| Improve this Doc View SourceBinBounds
Gets or sets the bin bounds of the frequency bands for octave scale bin id in first column and the Hz value in second column of matrix.
Declaration
public int[, ] BinBounds { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32[,] |
FinalBinCount
Gets or sets number of frequency bins in the final spectrogram.
Declaration
public int FinalBinCount { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
GridLineLocations
Gets or sets the location of gridlines (first column) and the Hz value for the grid lines (second column of matrix).
Declaration
public int[, ] GridLineLocations { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32[,] |
HertzGridInterval
Gets or sets herz interval between gridlines when using a linear or mel scale.
Declaration
public int HertzGridInterval { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
LinearBound
Gets or sets top end of the linear part of an Octave Scale spectrogram.
Declaration
public int LinearBound { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Nyquist
Gets or sets half the sample rate.
Declaration
public int Nyquist { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
ScaleType
Gets or sets the scale type i.e. linear, octave etc.
Declaration
public FreqScaleType ScaleType { get; set; }
Property Value
| Type | Description |
|---|---|
| FreqScaleType |
ToneCount
Gets or sets number of bands or tones per octave.
Declaration
public int ToneCount { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
WindowSize
Gets or sets frame size for the FFT.
Declaration
public int WindowSize { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
WindowStep
Gets or sets step size for the FFT window.
Declaration
public int WindowStep { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Methods
| Improve this Doc View SourceDrawFrequencyLinesOnImage(Image<Rgb24>, FrequencyScale, Boolean)
Declaration
public static void DrawFrequencyLinesOnImage(Image<Rgb24> bmp, FrequencyScale freqScale, bool includeLabels)
Parameters
| Type | Name | Description |
|---|---|---|
| SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> | bmp | |
| FrequencyScale | freqScale | |
| Boolean | includeLabels |
DrawFrequencyLinesOnImage(Image<Rgb24>, Int32[,], Boolean)
Declaration
public static void DrawFrequencyLinesOnImage(Image<Rgb24> bmp, int[, ] gridLineLocations, bool includeLabels)
Parameters
| Type | Name | Description |
|---|---|---|
| SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> | bmp | |
| Int32[,] | gridLineLocations | |
| Boolean | includeLabels |
GetBinIdForHerzValue(Int32)
returns the binId for freq bin closest to the passed Hertz value.
Declaration
public int GetBinIdForHerzValue(int hertzValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | hertzValue |
Returns
| Type | Description |
|---|---|
| Int32 |
GetBinIdInReducedSpectrogramForHerzValue(Int32)
returns the binId for the grid line closest to the passed frequency.
Declaration
public int GetBinIdInReducedSpectrogramForHerzValue(int herzValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | herzValue |
Returns
| Type | Description |
|---|---|
| Int32 |
GetLinearBinBounds()
Returns an [N, 2] matrix with bin ID in column 1 and lower Herz bound in column 2.
Declaration
public int[, ] GetLinearBinBounds()
Returns
| Type | Description |
|---|---|
| Int32[,] |
GetLinearFreqScale(Int32, Int32)
THis method assumes that the frameSize will be power of 2 FOR DEBUG PURPOSES, when sr = 22050 and frame size = 8192, the following Hz are located at index: Hz Index 15 6 31 12 62 23 125 46 250 93 500 186 1000 372.
Declaration
public static double[] GetLinearFreqScale(int nyquist, int binCount)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | nyquist | |
| Int32 | binCount |
Returns
| Type | Description |
|---|---|
| Double[] |
GetLinearGridLineLocations(Int32, Int32, Int32)
T.
Declaration
public static int[, ] GetLinearGridLineLocations(int nyquist, int herzInterval, int binCount)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | nyquist | |
| Int32 | herzInterval | |
| Int32 | binCount |
Returns
| Type | Description |
|---|---|
| Int32[,] |