Class UnitConverters
Inheritance
UnitConverters
Assembly: AudioAnalysisTools.dll
public class UnitConverters
Constructors
|
Improve this Doc
View Source
Initializes a new instance of the UnitConverters class.
IMPORTANT NOTE: segmentDuration should be the duration spanned by the spectrogram image, not the actual duration recording.
Given one frame per pixel column, the spectrogram duration = frameCount * seconds/frame.
Declaration
public UnitConverters(double segmentStartOffset, double segmentDuration, double nyquistFrequency, int imageWidth, int imageHeight)
Parameters
| Type |
Name |
Description |
| Double |
segmentStartOffset |
Segment start relative to start of the recording.
|
| Double |
segmentDuration |
Set the time-scale. The spectrogram time-span. Typically 60 seconds.
|
| Double |
nyquistFrequency |
Sets the frequency scale.
|
| Int32 |
imageWidth |
Pixel width = number of time frames.
|
| Int32 |
imageHeight |
Pixel height = the number of frequency bins.
|
|
Improve this Doc
View Source
Initializes a new instance of the UnitConverters class.
Use this constructor or the next one when you have sample rate of recording from which spectrogram is derived.
This constructor assumes that the step size equals the frame size.
Enables calculations independent of the image size.
Declaration
public UnitConverters(double segmentStartOffset, int sampleRate, int frameSize)
Parameters
| Type |
Name |
Description |
| Double |
segmentStartOffset |
Start time in seconds of the current recording segment.
|
| Int32 |
sampleRate |
Sample rate of the recording segment.
|
| Int32 |
frameSize |
The window or frame size.
|
|
Improve this Doc
View Source
Initializes a new instance of the UnitConverters class.
Use this constructor or the above when you have sample rate of recording from which spectrogram is derived.
Enables calculations independent of the image size.
Supplied with the frame overlap rather than the step size.
Declaration
public UnitConverters(double segmentStartOffset, int sampleRate, int frameSize, double frameOverlap)
Parameters
| Type |
Name |
Description |
| Double |
segmentStartOffset |
Start time in seconds of the current recording segment.
|
| Int32 |
sampleRate |
Sample rate of the recording segment.
|
| Int32 |
frameSize |
The window or frame size.
|
| Double |
frameOverlap |
Fractional overlap of frames.
|
|
Improve this Doc
View Source
Initializes a new instance of the UnitConverters class.
Use this constructor or the next one when you have sample rate of recording from which spectrogram is derived.
Enables calculations independent of the image size.
Declaration
public UnitConverters(double segmentStartOffset, int sampleRate, int frameSize, int stepSize)
Parameters
| Type |
Name |
Description |
| Double |
segmentStartOffset |
Start time in seconds of the current recording segment.
|
| Int32 |
sampleRate |
Sample rate of the recording segment.
|
| Int32 |
frameSize |
The window or frame size.
|
| Int32 |
stepSize |
THe step size which is LTE frame size.
|
Properties
|
Improve this Doc
View Source
Declaration
public double FrameOverlap { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public int FrameSize { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public double HertzPerFreqBin { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public int NyquistFrequency { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public int SampleRate { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public double SecondsPerFrame { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public double SecondsPerFrameStep { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public double SegmentStartOffset { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public LinearScale SpectralScale { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public int StepSize { get; }
Property Value
|
Improve this Doc
View Source
Gets the temporal scale. Measured in seconds per pixel.
To converts seconds to pixels.
From converts pixels to seconds.
Declaration
public LinearScale TemporalScale { get; }
Property Value
Methods
|
Improve this Doc
View Source
Declaration
public SpectralPoint ConvertPointToSpectralPoint(Point point, double value)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Point |
point |
|
| Double |
value |
|
Returns
|
Improve this Doc
View Source
Declaration
public int FrameFromEndTime(double endTime)
Parameters
| Type |
Name |
Description |
| Double |
endTime |
|
Returns
|
Improve this Doc
View Source
Declaration
public int FrameFromStartTime(double startTime)
Parameters
| Type |
Name |
Description |
| Double |
startTime |
|
Returns
|
Improve this Doc
View Source
Declaration
public double GetEndTimeInSecondsOfFrame(int frameId)
Parameters
| Type |
Name |
Description |
| Int32 |
frameId |
|
Returns
|
Improve this Doc
View Source
Returns the number of frames for the passed duration in seconds.
Do the calculations in signal samples.
TODO: Question should we do round or floor?.
Declaration
public int GetFrameCountFromSecondsDuration(double seconds)
Parameters
| Type |
Name |
Description |
| Double |
seconds |
The elapsed time.
|
Returns
| Type |
Description |
| Int32 |
The number of frames.
|
|
Improve this Doc
View Source
Declaration
public int GetFreqBinFromHertz(double hertz)
Parameters
| Type |
Name |
Description |
| Double |
hertz |
|
Returns
|
Improve this Doc
View Source
Declaration
public double GetHertzFromFreqBin(int bin)
Parameters
| Type |
Name |
Description |
| Int32 |
bin |
|
Returns
|
Improve this Doc
View Source
Declaration
public double GetHertzHighFromFreqBin(int bin)
Parameters
| Type |
Name |
Description |
| Int32 |
bin |
|
Returns
|
Improve this Doc
View Source
Gets a rectangle suitable for drawing.
Declaration
public RectangleF GetPixelRectangle(ISpectralEvent event)
Parameters
| Type |
Name |
Description |
| ISpectralEvent |
event |
The event to get the border for.
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.RectangleF |
The rectangle representing the border.
|
|
Improve this Doc
View Source
Declaration
public RectangleF GetPixelRectangle(ISpectralPoint point)
Parameters
Returns
| Type |
Description |
| SixLabors.ImageSharp.RectangleF |
|
|
Improve this Doc
View Source
Gets the top and left of an event, in a fashion suitable for drawing.
Declaration
public PointF GetPoint(ISpectralEvent event)
Parameters
| Type |
Name |
Description |
| ISpectralEvent |
event |
The event to get the point for.
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.PointF |
The point.
|
|
Improve this Doc
View Source
Declaration
public PointF GetPoint(ISpectralPoint point)
Parameters
Returns
| Type |
Description |
| SixLabors.ImageSharp.PointF |
|
|
Improve this Doc
View Source
Declaration
public PointF GetPointCentroid(ISpectralPoint point)
Parameters
Returns
| Type |
Description |
| SixLabors.ImageSharp.PointF |
|
|
Improve this Doc
View Source
Returns the duration in seconds of the passed number of frames.
NOTE: In the case where frames are overlapped, the last frame in any sequence is longer than the frame step.
This correction becomes sgnificant when the frameCount is small.
Declaration
public double GetSecondsDurationFromFrameCount(int frameCount)
Parameters
| Type |
Name |
Description |
| Int32 |
frameCount |
The number of frames.
|
Returns
| Type |
Description |
| Double |
Duration inseconds.
|
|
Improve this Doc
View Source
Gets the width and height of an event.
Declaration
public SizeF GetSize(ISpectralEvent event)
Parameters
| Type |
Name |
Description |
| ISpectralEvent |
event |
The event to get the size for.
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.SizeF |
The size.
|
|
Improve this Doc
View Source
Declaration
public double GetStartTimeInSecondsOfFrame(int frameId)
Parameters
| Type |
Name |
Description |
| Int32 |
frameId |
|
Returns
|
Improve this Doc
View Source
Declaration
public float HertzToPixels(double seconds)
Parameters
| Type |
Name |
Description |
| Double |
seconds |
|
Returns
|
Improve this Doc
View Source
Declaration
public double PixelsToHertz(float pixels)
Parameters
| Type |
Name |
Description |
| Single |
pixels |
|
Returns
|
Improve this Doc
View Source
Declaration
public double PixelsToSeconds(float pixels)
Parameters
| Type |
Name |
Description |
| Single |
pixels |
|
Returns
|
Improve this Doc
View Source
Declaration
public double RecordingRelativeToSegmentRelative(double seconds)
Parameters
| Type |
Name |
Description |
| Double |
seconds |
|
Returns
|
Improve this Doc
View Source
Declaration
public float SecondsToPixels(double seconds)
Parameters
| Type |
Name |
Description |
| Double |
seconds |
|
Returns
|
Improve this Doc
View Source
Declaration
public double SegmentRelativeToRecordingRelative(double seconds)
Parameters
| Type |
Name |
Description |
| Double |
seconds |
|
Returns
|
Improve this Doc
View Source
Declaration
public void SetBounds<T>(T event, Oblong source)
where T : SpectralEvent
Parameters
| Type |
Name |
Description |
| T |
event |
|
| Oblong |
source |
|
Type Parameters
Extension Methods