TSpectrogram Class

ComponentTMtxComponentTAnalysisTSpectrumTStaticSpectrumAnalyzerTSpectrogram

type TSpectrogram = class(TStaticSpectrumAnalyzer);

Form vectors from a list of TMarkList's.

Spectrogram expects a TSpectrumAnalyzer or descendant to be connected to its Input property. Each time the Pull method is called on component, the connected components are recalcuated and new spectrum is added to the list of spectrums within the component. There are various support routines avialable to help manage that data. Typical usage scenarios are like this (assuming single channel file):

SignalRead.FileName := YourFile;
SignalRead.OpenFile;
SignalRead.RecordTimePosition := StartingTime;
SpectrumAnalyzer.Input := SignalRead;
Spectrogram.Input := SpectrumAnalyzer;
Spectrogram.PullUntilEnd;//process entire file

Spectrogram.SpectralTimeOffset := StartingTime;
Spectrogram.SpectralSamplingFrequency := 1/SignalRead.FramesPerSecond;

Alternative:

        SignalRead.FileName := YourFile;
        SignalRead.OpenFile;
        SignalRead.RecordTimePosition := StartingTime;
        SpectrumAnalyzer.Input := SignalRead;
        SpectrumAnalyzer.Peaks.TraceMethod := ptAmpltHarmonics;

        Spectrogram.TraceOnly := true;
        Spectrogram.Input := SpectrumAnalyzer;
        Spectrogram.PullUntilEnd;//process entire file

        Spectrogram.Trace.EndTrace;
        Spectrogram.Trace.SpectralTimeOffset := StartingTime;
        Spectrogram.Trace.SpectralSamplingFrequency := 1/SignalRead.FramesPerSecond;

//        Spectrogram.Trace[i].Freq  //TVec contains gathered data
//        Spectrogram.Trace[i].Amplt //TVec contains gathered data

Examples

delphi
SignalRead.FileName := YourFile;
SignalRead.OpenFile;
SignalRead.RecordTimePosition := StartingTime;
SpectrumAnalyzer.Input := SignalRead;
Spectrogram.Input := SpectrumAnalyzer;
Spectrogram.PullUntilEnd;//process entire file

Spectrogram.SpectralTimeOffset := StartingTime;
Spectrogram.SpectralSamplingFrequency := 1/SignalRead.FramesPerSecond;

Properties

NameTypeDescription
ActiveBooleanSet active to false to suppress the propagation of the Pull request and the subsequent call to the Update method.
AmpltTVecStores the amplitude of the spectrum.
AveragesIntegerUsed to store the number of averages made.
BandsTSpectrumBandsAnalyzerHolds the parameters for the frequency bands.
BandWidthDoubleReturns the bandwidth of the spectrum in [Hz].
BandwidthHDoubleReturns the upper bandwidth edge of the signal.
BandwidthLDoubleReturns the lower bandwidth edge of the signal.
BlockAssignBooleanBlock streaming of specific properties when storing only a "template".
ComplexBooleanSet this property to true, to request computation using complex numbers.
ConjExtendBooleanIf True, the conjugate symmetric part of the frequency spectrum is to be computed.
ConjFlipBooleanIf True, the conjugate symmetric part of the frequency spectrum will be placed in 0.5..1.0 Fs (as returned by the FFT), and not between -0.5..0.0 Fs.
ContinuousBooleanIf True, the component will pass on the udpate request to the connected component.
CountIntegerSpecifies the number of the spectrums in the list.
DtDoubleReturns the distance in seconds between two consecutive samples of the signal on which the frequency spectrum is based.
EditorActiveBooleanReturns True, if the component editor is displayed.
FloatPrecisionTMtxFloatPrecisionSet this property to request computation in 32bit/64bit precision with real/complex numbers.
FloatPrecisionLockBooleanSet this property to true to lock changes to FloatPrecision property.
HarmonicsIntegerDefines number of harmonics to be used when calculating statistical parameters from the amplitude spectrum.
HzResDoubleReturns the frequency resolution in Hz.
InputTSpectrumSpecifies Input for the data to the component.
IsDoubleBooleanSet this property to false, to request computation in 32bit floating point precision, 64bit, if true.
IsSpectrumAnalyzerBooleanReturns true, if the descendant class is derived from TSpectrumAnalyzer.
ItemTStaticSpectrumAnalyzerReturns spectrum at index i.
ItemNumberIntegerNumber to label the object when it is an item in the List.
LengthIntegerDefines the length of the spectrum.
LogarithmicBooleanIf true, the stored spectrums will be converted to Logarithmic scale.
LogSpanTLogSpanDefines the span of the logarithmic spectrum in dB.
MainlobeWidthIntegerDefines the width of the main lobe. Each frequency component in the frequency spectrum should theoretically be infinitely thin.
MarksTMarkListStores the frequency, amplitude and phase of selected frequency bins.
MaxAmpltDoubleStores the maximum value of the Amplt spectrum found by the MinMaxAmplt method.
MaxFreqIndexIntegerHolds the index at which the maximum amplitude was found by the MinMaxAmplt method.
MaxPhaseDoubleStores the maximum value of the Phase spectrum found by the MinMaxPhase method.
MaxSpectrumCountIntegerMaximum number of spectrums up to which the spectrogram will grow.
MinAmpltDoubleStores the minimum value of the Amplt spectrum found by the MinMaxAmplt method.
MinPhaseDoubleStores the minimum value of the Phase spectrum found by the MinMaxPhase method.
NarrowBandHDoubleSpecify value other than 0 to indicate the final frequency of the reduce bandwidth.
NarrowBandLDoubleSpecify value other than 0 to indicate the start of the reduced bandwidth.
OnAfterUpdateTNotifyEventThe event is triggered after the call to the Update method.
OnBandsUpdateTNotifyEventIf assigned, this event will be called instead of a call to Bands.Update method.
OnBeforeUpdateTNotifyEventThe event is triggered just before the call to the Update method.
OnDisplayUpdateTNotifyEventThe event is triggered after the OnAfterUpdate event. Use this event to update any associated charts or graphs or result tables.
OnGetInputTNotifyEventIf the Input property is not assigned, the component will call OnGetInput.
OnNotifyUpdateTNotifyEventThe event is called after a call to InternalUpdate, OnAfterUpdate and OnDisplayUpdate from within the Update method.
OnParameterUpdateTNotifyEventThe event is triggered when ParamUpdate method is called. The ParamUpdate method is usually called by component editors when a value was changed by the user and the editor was "Live".
OnPeaksUpdateTNotifyEventIf assigned, this event will be called instead of a call to Peaks.Update method.
PeaksTSpectrumPeaksAnalyzerPointer to the component that manages peak analysis.
PhaseTVecStores the phase of the spectrum.
PhaseModeTPhaseModeThis property determines how to handle the phase of the frequency spectrum.
PhaseRangeTPhaseRangeSpecify the range of the phase spectrum.
PhaseUnitsTPhaseUnitsDefines the units of phase. (radian, degrees).
PipeStateTPipeStateReturns the state of the pipe after the last update.
ReferenceTReferenceListStores a list of components that have to be notified, when this component is destroyed.
ReportTSpectrumReportHolds the parameters needed to generate a spectrum analysis report. Requires that the descriptor property is properly filled up.
SamplingFrequencyDoubleDefines the sampling frequency of the signal on which the frequency spectrum is based.
SamplingTimeDoubleDefines the length of the signal on which the frequency spectrum is based in seconds.
SpectralDtDoubleTime in seconds between consecutive spectrums.
SpectralSamplingFrequencyDoubleSampling frequency with which the spectrums are being sampled. When setting this property Dt is automatically updated.
SpectralSamplingTimeDoubleTotal length in seconds between the first and the last spectrum.
SpectralTimeOffsetDoubleTime in seconds at which the spectrogram starts.
SuspendNotifyUpdateBooleanSet this property to True, to prevent calling OnNotifyUpdate from the Update Method.
TraceTTraceListContaines parameters and results for individual traces.
TraceOnlyBooleanSpecifies to track only marked peaks without entire spectrums.
UsesInputsBooleanSet it to True to indicate, that valid signals will be connected to the Input or Inputs properties.
ZeroPaddingIntegerDefines the level of zero padding of the source signal.

Methods

NameDescription
AddAdd amplitude and phase of the ASpectrum to the current spectrum.
AllowStreamingReturns the negatated value of BlockAssign.
AmpltEst (4)Returns the amplitudes of the frequency spectrum at Freq frequencies.
AmpltSpectrumCompute amplitude spectrum from X.
AssignAssign values of all published properties from Source.
AssignTemplateAssign values of "template-like" published properties from Source.
BandFlipFlip the frequency spectrum on the frequency axis.
ConvergeToMaximum (2)Searches for the closest peaks of the amplitude spectrum.
CopyCopy ASpectrum to the calling spectrum.
CopyAmpltCopies all amplitude spectrums as rows to the destination matrix.
CopyAmpltTransposed (2)Copies all amplitude spectrums as columns to the destination matrix.
CopyPhaseCopies all phase spectrums as rows to the destination matrix.
DeleteDelete the spectrum at index i.
DifferentiateDifferentiate the underlying signal in the frequency domain by scaling each amplitude line with a power of its angular frequency.
DivideDivide the calling the spectrum with ASpectrum.
EditorClassTo be overriden in descendanr classses.
FetchTracesCopies marked values from spectrogram to the Trace property.
FilterPeakFilter the peak at Marks position Index from the signal and recalculate the spectrum.
FreqToFreqIndexComputes range checked array indexes in the spectrum from frequency values.
InputsDirtyIf all Inputs[i] are dirty the function returns true.
InsertInsert spectrum at index.
IntegrateIntegrate the underlying signal in the frequency domain by dividing each amplitude line by a power of its angular frequency, restoring the DC term afterwards.
InternalPullWhen called, the method will pass Update requests recursively to all connected objects.
InvalidateNotifies all connected components that this component has fresh data.
LoadFromStreamLoad the component from Src stream.
LoadTemplateFromFileLoad a template from file.
LoadTemplateFromStreamLoad a template from stream.
LogAmpltCompute the logarithm of the amplitude spectrum and convert to dB.
MarksToStringsConvert marks to strings.
MinMaxCalls MinMaxAmplt and MinMaxPhase.
MinMaxAmpltFind minimum and maximum value of the Amplt spectrum.
MinMaxPhaseFind minimum and maximum value of the Phase spectrum.
MoveMove spectrum from SrcIdx to DstIdx index.
MulMultiply the calling the spectrum with ASpectrum.
NFNoise floor in dB: the mean absolute noise line (lines outside the mark guard bands), relative to the largest marked peak.
ParamUpdateThe method can be assigned to some other component even handler, as a notification that a parameter has changed and that Self should consider a recalculation.
PeakApproximateReturn the peak closest to the Freq frequency.
PhaseEst (4)Returns the phases of the frequency spectrum at Freq frequencies.
PhaseSpectrumCompute phase spectrum from X.
PipeResetRecursively processes all connected components backward and calls Reset method.
PowerSpectrumCompute power spectrum from X.
PullRequest recalculation of the entire chain of all connected components.
PullUntilEndCalls Pull until pipeEnd is returned.
ResetReset the spectrogram and delete the stored data.
RMSRoot-mean-square value reconstructed from the amplitude spectrum.
RMSSpectrumCompute RMS spectrum from X.
RotateRotate spectrums down or up in the list.
SaveTemplateToFileSave template to file.
SaveTemplateToStreamSave template to stream.
SaveToStreamSave the component to Dst stream.
ScaleScale the calling spectrum with Factor.
SetZeroInitialize spectrum to zero.
SFDRSpurious-free dynamic range in dB: the ratio of the largest marked peak to the second-largest marked peak.
SINADSignal-to-noise-and-distortion ratio in dB. Compares the largest marked peak against the noise floor plus every other marked peak.
SizeAssign Length, Complex and SamplingFrequency properties.
SNRSignal-to-noise ratio in dB. Sums the absolute amplitudes of all marked peaks and compares against the sum of the absolute amplitude lines outside the mark guard bands.
SqrSquare the Amplt and Phase of the ASpectrum and copy it to self.
SubtractSubtract ASpectrum from the calling spectrum.
THDTotal harmonic distortion in percent. Returns the RMS of the marked harmonic peaks (all marks after the first, when sorted by frequency, up to Harmonics) relative to the first (fundamental) marked peak.
THDNTotal harmonic distortion plus noise, in percent. Combines the noise floor power with the power of every marked peak except the largest, relative to the largest marked peak.
UpdateRequest recalculation of the data and place the result in Self.
UpdateAllTracesUpdates marks for all spectrums then calls FetchTraces.
UpdateNotifyCall this method only, if SuspendNotifyUpdate is True.
UpdateTraceParametersPropagates settings of Peaks and Bands properties to all spectrums.
ValuesToStringsConvert values to strings.