Class Oscillations2012
NOTE: 21st June 2012.
This class contains methods to detect oscillations in a the sonogram of an audio signal. The method Execute() returns all info about oscillations in the passed sonogram. This method should be called in preference to those in the class OscillationAnalysis. (The latter should be deprecated.)
Inherited Members
Namespace: AudioAnalysisTools
Assembly: AudioAnalysisTools.dll
Syntax
public static class Oscillations2012
Methods
| Improve this Doc View SourceCalculateRequiredFrameOverlap(Int32, Int32, Double)
Calculates the optimal frame overlap for the given sample rate, frame width and max oscillation or pulse rate. Pulse rate is determined using a DCT and efficient use of the DCT requires that the dominant pulse sit somewhere 3.4 along the array of coefficients.
Declaration
public static double CalculateRequiredFrameOverlap(int sr, int frameWidth, double maxOscillation)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sr | |
Int32 | frameWidth | |
Double | maxOscillation |
Returns
Type | Description |
---|---|
Double |
ConvertOscillationScores2Events(SpectrogramStandard, Double[], Int32, Int32, Double, Double, Double, TimeSpan)
Converts the Oscillation Detector score array to a list of Oscillation Events.
Declaration
public static List<OscillationEvent> ConvertOscillationScores2Events(SpectrogramStandard spectrogram, double[] scores, int minHz, int maxHz, double scoreThreshold, double minDurationThreshold, double maxDurationThreshold, TimeSpan segmentStartOffset)
Parameters
Type | Name | Description |
---|---|---|
SpectrogramStandard | spectrogram | |
Double[] | scores | the array of OD scores. |
Int32 | minHz | lower freq bound of the acoustic event. |
Int32 | maxHz | upper freq bound of the acoustic event. |
Double | scoreThreshold | threshold. |
Double | minDurationThreshold | min threshold. |
Double | maxDurationThreshold | max threshold. |
TimeSpan | segmentStartOffset | time offset. |
Returns
Type | Description |
---|---|
List<OscillationEvent> |
DetectOscillations(SpectrogramStandard, Int32, Int32, Double, Int32, Int32, Double)
Detects oscillations in a given freq bin. there are several important parameters for tuning. a) DCTLength: Good values are 0.25 to 0.50 sec. Do not want too long because DCT requires stationarity. Do not want too short because too small a range of oscillations b) DCTindex: Sets lower bound for oscillations of interest. Index refers to array of coefficient returned by DCT. Array has same length as the length of the DCT. Low freq oscillations occur more often by chance. Want to exclude them. c) MinAmplitude: minimum acceptable value of a DCT coefficient if hit is to be accepted. The algorithm is sensitive to this value. A lower value results in more oscillation hits being returned.
Declaration
public static double[, ] DetectOscillations(SpectrogramStandard sonogram, int minHz, int maxHz, double dctDuration, int minOscilFreq, int maxOscilFreq, double dctThreshold)
Parameters
Type | Name | Description |
---|---|---|
SpectrogramStandard | sonogram | A spectrogram. |
Int32 | minHz | min freq bin of search band. |
Int32 | maxHz | max freq bin of search band. |
Double | dctDuration | number of values. |
Int32 | minOscilFreq | minimum oscillation freq. |
Int32 | maxOscilFreq | maximum oscillation freq. |
Double | dctThreshold | threshold - do not accept a DCT coefficient if its value is less than this threshold. |
Returns
Type | Description |
---|---|
Double[,] |
DoDct(Double[], Double[,], Int32)
Declaration
public static double[] DoDct(double[] vector, double[, ] cosines, int lowerDctBound)
Parameters
Type | Name | Description |
---|---|---|
Double[] | vector | |
Double[,] | cosines | |
Int32 | lowerDctBound |
Returns
Type | Description |
---|---|
Double[] |
Execute(SpectrogramStandard, Int32, Int32, Double, Int32, Int32, Double, Double, Double, Double, out Double[], out List<OscillationEvent>, out Double[,], TimeSpan)
Declaration
public static void Execute(SpectrogramStandard sonogram, int minHz, int maxHz, double dctDuration, int minOscilFreq, int maxOscilFreq, double dctThreshold, double scoreThreshold, double minDuration, double maxDuration, out double[] scores, out List<OscillationEvent> events, out double[, ] hits, TimeSpan segmentStartOffset)
Parameters
Type | Name | Description |
---|---|---|
SpectrogramStandard | sonogram | |
Int32 | minHz | |
Int32 | maxHz | |
Double | dctDuration | |
Int32 | minOscilFreq | |
Int32 | maxOscilFreq | |
Double | dctThreshold | |
Double | scoreThreshold | |
Double | minDuration | |
Double | maxDuration | |
Double[] | scores | |
List<OscillationEvent> | events | |
Double[,] | hits | |
TimeSpan | segmentStartOffset |
Execute(SpectrogramStandard, Int32, Int32, Double, Int32, Int32, Double, Double, Double, Double, Int32, out Double[], out List<OscillationEvent>, out Double[,], TimeSpan)
Declaration
public static void Execute(SpectrogramStandard sonogram, int minHz, int maxHz, double dctDuration, int minOscilFreq, int maxOscilFreq, double dctThreshold, double scoreThreshold, double minDuration, double maxDuration, int smoothingWindow, out double[] scores, out List<OscillationEvent> events, out double[, ] hits, TimeSpan segmentStartOffset)
Parameters
Type | Name | Description |
---|---|---|
SpectrogramStandard | sonogram | |
Int32 | minHz | |
Int32 | maxHz | |
Double | dctDuration | |
Int32 | minOscilFreq | |
Int32 | maxOscilFreq | |
Double | dctThreshold | |
Double | scoreThreshold | |
Double | minDuration | |
Double | maxDuration | |
Int32 | smoothingWindow | |
Double[] | scores | |
List<OscillationEvent> | events | |
Double[,] | hits | |
TimeSpan | segmentStartOffset |
GetComponentsWithOscillations(SpectrogramStandard, OscillationParameters, Nullable<Double>, TimeSpan, String)
Declaration
public static (List<EventCommon> SpectralEvents, List<Plot> DecibelPlots) GetComponentsWithOscillations(SpectrogramStandard spectrogram, OscillationParameters op, double? decibelThreshold, TimeSpan segmentStartOffset, string profileName)
Parameters
Type | Name | Description |
---|---|---|
SpectrogramStandard | spectrogram | |
OscillationParameters | op | |
Nullable<Double> | decibelThreshold | |
TimeSpan | segmentStartOffset | |
String | profileName |
Returns
Type | Description |
---|---|
(T1, T2)<List<EventCommon>, List<Plot>> |
GetOscillationScores(Double[,], Int32, Int32, Double)
Converts the hits derived from the oscillation detector into a score for each frame. NOTE: The oscillation detector skips every second row, so score must be adjusted for this.
Declaration
public static double[] GetOscillationScores(double[, ] hits, int minHz, int maxHz, double freqBinWidth)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | hits | sonogram as matrix showing location of oscillation hits. |
Int32 | minHz | lower freq bound of the acoustic event. |
Int32 | maxHz | upper freq bound of the acoustic event. |
Double | freqBinWidth | the freq scale required by AcousticEvent class. |
Returns
Type | Description |
---|---|
Double[] |
RemoveIsolatedOscillations(Double[,])
Removes single lines of hits from Oscillation matrix.
Declaration
public static double[, ] RemoveIsolatedOscillations(double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | matrix | the Oscillation matrix. |
Returns
Type | Description |
---|---|
Double[,] | a matrix. |