Class FFTViewModel
View model for an FFT block: surfaces its live metrics and lets the user change the window function, output mode and dB parameters at runtime.
Inherited Members
Namespace: MOSAIC.ViewModels.SignalProcessing
Assembly: MOSAIC.dll
Syntax
public class FFTViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging, IDisposable
Remarks
Threading: the block raises INotifyPropertyChanged events from its processing
thread. CommunityToolkit's generated setters and OnPropertyChanged are thread-safe —
Avalonia marshals the change notifications to the UI thread — so no explicit Dispatcher
hop is needed here. The block subscription is released in Dispose().
Constructors
FFTViewModel(FFT)
Declaration
public FFTViewModel(FFT fft)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT | fft |
Fields
AllChannelsLabel
Declaration
private const string AllChannelsLabel = "All (avg)"
Field Value
| Type | Description |
|---|---|
| string |
ChannelPrefix
Declaration
private const string ChannelPrefix = "Ch "
Field Value
| Type | Description |
|---|---|
| string |
_dbFloor
Declaration
[ObservableProperty]
private double _dbFloor
Field Value
| Type | Description |
|---|---|
| double |
_dbRef
Declaration
[ObservableProperty]
private double _dbRef
Field Value
| Type | Description |
|---|---|
| double |
_disposed
Declaration
private bool _disposed
Field Value
| Type | Description |
|---|---|
| bool |
_fft
Declaration
private readonly FFT _fft
Field Value
| Type | Description |
|---|---|
| FFT |
_selectedChannelOption
Declaration
[ObservableProperty]
private string _selectedChannelOption
Field Value
| Type | Description |
|---|---|
| string |
_selectedOutputMode
Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("IsDbMode")]
private FFT.OutputMode _selectedOutputMode
Field Value
| Type | Description |
|---|---|
| FFT.OutputMode |
_selectedWindow
Declaration
[ObservableProperty]
private FFT.WindowType _selectedWindow
Field Value
| Type | Description |
|---|---|
| FFT.WindowType |
Properties
AvailableOutputModes
Output modes offered to the user, taken straight from the block's enum.
Declaration
public IReadOnlyList<FFT.OutputMode> AvailableOutputModes { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<FFT.OutputMode> |
AvailableWindows
Window functions offered to the user, taken straight from the block's enum.
Declaration
public IReadOnlyList<FFT.WindowType> AvailableWindows { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<FFT.WindowType> |
Block
The underlying block, exposed so the view can bind its spectrogram.
Declaration
public FFT Block { get; }
Property Value
| Type | Description |
|---|---|
| FFT |
BlockStatus
Live execution status, surfaced to the status badge.
Declaration
public BlockStatus BlockStatus { get; }
Property Value
| Type | Description |
|---|---|
| BlockStatus |
ChannelCount
Declaration
public int ChannelCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
ChannelOptions
Declaration
public ObservableCollection<string> ChannelOptions { get; }
Property Value
| Type | Description |
|---|---|
| ObservableCollection<string> |
DbFloor
Declaration
[ExcludeFromCodeCoverage]
public double DbFloor { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
DbRef
Declaration
[ExcludeFromCodeCoverage]
public double DbRef { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
FftDescription
Declaration
public string FftDescription { get; }
Property Value
| Type | Description |
|---|---|
| string |
FftSize
Declaration
public int FftSize { get; }
Property Value
| Type | Description |
|---|---|
| int |
FrequencyResolution
Declaration
public double FrequencyResolution { get; }
Property Value
| Type | Description |
|---|---|
| double |
IsDbMode
Whether the dB controls should be visible (only when the mode is dB).
Declaration
public bool IsDbMode { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Name
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
OutputBins
Declaration
public int OutputBins { get; }
Property Value
| Type | Description |
|---|---|
| int |
SelectedChannelOption
Declaration
[ExcludeFromCodeCoverage]
public string SelectedChannelOption { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
SelectedOutputMode
Declaration
[ExcludeFromCodeCoverage]
public FFT.OutputMode SelectedOutputMode { get; set; }
Property Value
| Type | Description |
|---|---|
| FFT.OutputMode |
SelectedWindow
Declaration
[ExcludeFromCodeCoverage]
public FFT.WindowType SelectedWindow { get; set; }
Property Value
| Type | Description |
|---|---|
| FFT.WindowType |
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
OnBlockPropertyChanged(object?, PropertyChangedEventArgs)
Declaration
private void OnBlockPropertyChanged(object? sender, PropertyChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | |
| PropertyChangedEventArgs | e |
OnDbFloorChanged(double)
Executes the logic for when DbFloor just changed.
Declaration
private void OnDbFloorChanged(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value that was set. |
Remarks
This method is invoked right after the value of DbFloor is changed.
OnDbFloorChanged(double, double)
Executes the logic for when DbFloor just changed.
Declaration
private void OnDbFloorChanged(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that was replaced. |
| double | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of DbFloor is changed.
OnDbFloorChanging(double)
Executes the logic for when DbFloor is changing.
Declaration
private void OnDbFloorChanging(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value being set. |
Remarks
This method is invoked right before the value of DbFloor is changed.
OnDbFloorChanging(double, double)
Executes the logic for when DbFloor is changing.
Declaration
private void OnDbFloorChanging(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that is being replaced. |
| double | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of DbFloor is changed.
OnDbRefChanged(double)
Executes the logic for when DbRef just changed.
Declaration
private void OnDbRefChanged(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value that was set. |
Remarks
This method is invoked right after the value of DbRef is changed.
OnDbRefChanged(double, double)
Executes the logic for when DbRef just changed.
Declaration
private void OnDbRefChanged(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that was replaced. |
| double | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of DbRef is changed.
OnDbRefChanging(double)
Executes the logic for when DbRef is changing.
Declaration
private void OnDbRefChanging(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value being set. |
Remarks
This method is invoked right before the value of DbRef is changed.
OnDbRefChanging(double, double)
Executes the logic for when DbRef is changing.
Declaration
private void OnDbRefChanging(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that is being replaced. |
| double | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of DbRef is changed.
OnSelectedChannelOptionChanged(string)
Executes the logic for when SelectedChannelOption just changed.
Declaration
private void OnSelectedChannelOptionChanged(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value that was set. |
Remarks
This method is invoked right after the value of SelectedChannelOption is changed.
OnSelectedChannelOptionChanged(string?, string)
Executes the logic for when SelectedChannelOption just changed.
Declaration
private void OnSelectedChannelOptionChanged(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that was replaced. |
| string | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of SelectedChannelOption is changed.
OnSelectedChannelOptionChanging(string)
Executes the logic for when SelectedChannelOption is changing.
Declaration
private void OnSelectedChannelOptionChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedChannelOption is changed.
OnSelectedChannelOptionChanging(string?, string)
Executes the logic for when SelectedChannelOption is changing.
Declaration
private void OnSelectedChannelOptionChanging(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that is being replaced. |
| string | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedChannelOption is changed.
OnSelectedOutputModeChanged(OutputMode)
Executes the logic for when SelectedOutputMode just changed.
Declaration
private void OnSelectedOutputModeChanged(FFT.OutputMode value)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT.OutputMode | value | The new property value that was set. |
Remarks
This method is invoked right after the value of SelectedOutputMode is changed.
OnSelectedOutputModeChanged(OutputMode, OutputMode)
Executes the logic for when SelectedOutputMode just changed.
Declaration
private void OnSelectedOutputModeChanged(FFT.OutputMode oldValue, FFT.OutputMode newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT.OutputMode | oldValue | The previous property value that was replaced. |
| FFT.OutputMode | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of SelectedOutputMode is changed.
OnSelectedOutputModeChanging(OutputMode)
Executes the logic for when SelectedOutputMode is changing.
Declaration
private void OnSelectedOutputModeChanging(FFT.OutputMode value)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT.OutputMode | value | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedOutputMode is changed.
OnSelectedOutputModeChanging(OutputMode, OutputMode)
Executes the logic for when SelectedOutputMode is changing.
Declaration
private void OnSelectedOutputModeChanging(FFT.OutputMode oldValue, FFT.OutputMode newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT.OutputMode | oldValue | The previous property value that is being replaced. |
| FFT.OutputMode | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedOutputMode is changed.
OnSelectedWindowChanged(WindowType)
Executes the logic for when SelectedWindow just changed.
Declaration
private void OnSelectedWindowChanged(FFT.WindowType value)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT.WindowType | value | The new property value that was set. |
Remarks
This method is invoked right after the value of SelectedWindow is changed.
OnSelectedWindowChanged(WindowType, WindowType)
Executes the logic for when SelectedWindow just changed.
Declaration
private void OnSelectedWindowChanged(FFT.WindowType oldValue, FFT.WindowType newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT.WindowType | oldValue | The previous property value that was replaced. |
| FFT.WindowType | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of SelectedWindow is changed.
OnSelectedWindowChanging(WindowType)
Executes the logic for when SelectedWindow is changing.
Declaration
private void OnSelectedWindowChanging(FFT.WindowType value)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT.WindowType | value | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedWindow is changed.
OnSelectedWindowChanging(WindowType, WindowType)
Executes the logic for when SelectedWindow is changing.
Declaration
private void OnSelectedWindowChanging(FFT.WindowType oldValue, FFT.WindowType newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| FFT.WindowType | oldValue | The previous property value that is being replaced. |
| FFT.WindowType | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedWindow is changed.
RebuildChannelList()
Rebuilds the channel dropdown to match the block's current channel count, preserving the current selection where possible.
Declaration
private void RebuildChannelList()