Test and measurement

Octave Bands <smart-octave-bands>

OctaveBands displays the level in each octave or third-octave band as a bar, with the frequency-weighted overall level and a limit curve the bands are checked against: the display of a sound level meter and of a vibration survey.

<smart-octave-bands> · 19 properties, 7 methods, 2 events · source/modules/smart.octavebands.js

Usage in Blazor

The Razor component is <OctaveBands> in Smart.Blazor.Industrial: every property is a parameter in PascalCase, every event an EventCallback<Event> named On<Event> whose ev["Detail"] is the typed detail class, and the methods are called on the @ref. String choices are enums. In a Blazor Web App (.NET 8 and later) the page needs an interactive render mode, for example @rendermode InteractiveServer; a statically rendered component stays empty.

@using Smart.Blazor.Industrial
@* .NET 8 and later: an interactive render mode, on the page or for the whole app *@
@rendermode InteractiveServer

<OctaveBands @ref="octaveBands" Resolution="octave"
    OnLevelsChange="OnLevelsChange" />

@code {
    OctaveBands octaveBands;

    void OnLevelsChange(Event ev)
    {
        OctaveBandsLevelsChangeEventDetail detail = ev["Detail"];
    }

    // Task<bool> Push(object block)
    void Call() => octaveBands.Push(new { });
}

Properties

ParameterType, defaultDescription
Resolution
resolution
OctaveBandsResolution
third
Sets or retrieves the band width: whole octaves or third octaves.
SampleRate
sampleRate
int
48000
Sets or retrieves the sample rate of pushed blocks, in samples per second. A band is shown only when all of it lies below half the sample rate. A value that is not a positive number analyses nothing: push() returns false, the header says so, and one console warning names the value; assigned levels are still shown.
Size
size
int
0
Sets or retrieves the FFT size a pushed block is analysed with. 0 uses the block's own length. Held to 16,777,216 at most.
FrequencyMin
frequencyMin
double
20
Sets or retrieves the centre frequency of the lowest band shown. Set above frequencyMax, the two are swapped, with one console warning, rather than leaving the chart empty.
FrequencyMax
frequencyMax
double
20000
Sets or retrieves the centre frequency of the highest band shown. Bands whose upper edge lies above half the sample rate are not shown whatever this says: at a sample rate of 8 kHz the 4 kHz third-octave band, which runs to 4.49 kHz, would be summed from the bins that exist and read low.
Weighting
weighting
OctaveBandsWeighting
Z
Sets or retrieves the frequency weighting applied to each band and to the overall level: Z (none), A or C, per IEC 61672.
Reference
reference
double
1
Sets or retrieves what reads as 0 dB: 1 for dB re one unit of the signal, 0.00002 for dB SPL of a signal in pascal.
Unit
unit
stringSets or retrieves the signal's unit, so a level reads dBV or, with the 20 µPa reference, dB SPL.
Averaging
averaging
OctaveBandsAveraging
fast
Sets or retrieves the exponential time weighting of the bars: none, fast (125 ms) or slow (1 s), as a meter's.
PeakHold
peakHold
bool
true
Keeps the highest level of each band as a marker.
Levels
levels
IEnumerable<object>Sets or retrieves the level of each band in dB, in the order of bands(). Assigned by an application with its own filter bank, or computed by push.
Limit
limit
IEnumerable<object>Sets or retrieves the limit the bands are checked against: a level per band in dB, or [{ frequency, level }] points interpolated across the bands on the log axis. A band above its limit is drawn in the exceeded colour and counted in the header. A null or non-numeric per-band value is no limit for that band; a point that is not an object with a frequency and a level is skipped. Either is said once in a console warning.
LevelMin
levelMin
doubleSets or retrieves the bottom of the level axis in dB. Null follows the data. With levelMax set below it, the two are swapped; set equal, the axis follows the data. Either is said once in a console warning.
LevelMax
levelMax
doubleSets or retrieves the top of the level axis in dB. Null follows the data. Fixes the axis together with levelMin.
ShowOverall
showOverall
bool
true
Shows the overall level in the header.
ShowGrid
showGrid
bool
true
Shows the grid lines at the level ticks.
Paused
paused
bool
false
Drops pushed blocks while set.
Label
label
stringSets or retrieves the title shown in the header and used in the accessible name.
PrecisionDigits
precisionDigits
int
1
Sets or retrieves the number of decimals in levels, held to 0 to 20.

Methods

MethodDescription
Task<bool> Push(object block)Analyses a block of samples into band levels and shows them, with averaging and peak hold applied. Samples that are not numbers are analysed as zeros, and never passed off as clean: the header shows how many, levelsChange carries the count, and the console says so once per run of such blocks. Returns false, and analyses nothing, when the analyser is paused, when Smart.DSP is not loaded, when the block is not an array of at least two samples or has no number in it, or when the sample rate is not a positive number.
block any The samples, as an array or a typed array.
Task<IEnumerable<object>> Bands()Returns the bands shown: [{ centre, low, high, label, index }], centres on the IEC 61260 base-10 series, between frequencyMin and frequencyMax, and only bands whose upper edge lies below half the sample rate.
Task<int> Overall()Returns the overall level: the levels of the bands summed on energy, in dB, or NaN with no levels.
void Clear()Clears the levels and the peaks.
void ResetPeaks()Drops the held peaks.
Task<string> Describe()Returns a sentence describing what the analyser shows, as used in its accessible name: the bands, the overall level, the highest band and the number above the limit (exceededSummaryOne for one).
void Invalidate()Redraws the plot on the next animation frame, so that many changes between two frames cost one draw.

Events

Every event is an EventCallback<Event>; Event is a dictionary and ev["Detail"] converts to the detail class named under the event.

EventDescription and detail
OnLevelsChange
levelsChange
OctaveBandsLevelsChangeEventDetail
This event is triggered after a pushed block has been analysed.
Levels IEnumerable<double> The level of each band, in dB.
Overall double The overall level, in dB.
InvalidSamples string How many samples of the block were not numbers and were analysed as zeros; 0 for a clean block.
OnBandClick
bandClick
OctaveBandsBandClickEventDetail
This event is triggered when a band is clicked.
Index int The band.
Centre double Its centre frequency.
Label string Its nominal frequency.
Level double Its level.
Peak double Its held peak.

Types

enum OctaveBandsResolution

OctaveBandsResolution.Octave "octave" OctaveBandsResolution.Third "third"

enum OctaveBandsWeighting

OctaveBandsWeighting.Z "Z" OctaveBandsWeighting.A "A" OctaveBandsWeighting.C "C"

enum OctaveBandsAveraging

OctaveBandsAveraging.None "none" OctaveBandsAveraging.Fast "fast" OctaveBandsAveraging.Slow "slow"

CSS variables

The component declares 4 CSS variables; the CSS page shows how to set them.

--smart-octave-height --smart-octave-plot-background --smart-octave-grid-color --smart-octave-axis-color