Skip to content

Commit

Permalink
Added possibility to display maximums for each individual channel on …
Browse files Browse the repository at this point in the history
…the spectrum graph
  • Loading branch information
sadko4u committed Dec 2, 2024
1 parent a07c33b commit 09c6cc8
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 116 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*******************************************************************************

=== 1.0.29 ===
* Added possibility to display maximums for each individual channel on the spectrum graph.
* Added shared memory links for signal analysis.
* Removed the unused 'Hue' parameter for channels.

Expand Down
8 changes: 5 additions & 3 deletions include/private/plugins/spectrum_analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ namespace lsp
float *vOut; // Output buffer pointer
float *vRet; // Return buffer
float *vBuffer; // Temporary buffer
float *vSpc[2]; // Spectrum data
float *vMax[2]; // Maximum data

// Port references
plug::IPort *pIn; // Input samples
Expand Down Expand Up @@ -104,7 +106,7 @@ namespace lsp
sa_correlometer_t *vCorrelometers; // Available correlometers
float **vAnalyze; // Analysis buffers
float *vFrequences;
float *vMaxValues; // Maximum value tracking
float *vMaxValues[2]; // Maximum value tracking
float *vMFrequences;
uint32_t *vIndexes;
uint8_t *pData;
Expand All @@ -121,7 +123,6 @@ namespace lsp
mode_t enMode;
bool bLogScale;
bool bMSSwitch; // Mid/Side switch for stereo mode
bool bMaxTracking; // Enable tracking of maximum values

float fWndState; // Variable to save the state of WINDOW
float fEnvState; // Variable to save the state of ENVELOPE
Expand All @@ -143,7 +144,6 @@ namespace lsp
plug::IPort *pMSSwitch;

plug::IPort *pFreeze;
plug::IPort *pMaxTrack; // Enable maximum value tracking
plug::IPort *pMaxReset; // Reset maximum values
plug::IPort *pSpp;
sa_spectralizer_t vSpc[2];
Expand All @@ -165,6 +165,8 @@ namespace lsp
void measure_correlation(size_t count);
void prepare_buffers(size_t count);

void output_spectrum();

public:
explicit spectrum_analyzer(const meta::plugin_t *metadata);
virtual ~spectrum_analyzer() override;
Expand Down
4 changes: 2 additions & 2 deletions res/main/ui/analyzer/spectrum/x1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
</ui:with>

<!-- Meshes -->
<mesh xi="0" yi="1" id="spd" width="1" color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5" fill="true" visibility=":mtrack"/>
<mesh xi="0" yi="2" id="spd" width=":lthick+1" color="mono" visibility_id="on_0"/>
<mesh xi="0" yi="3" id="spd" width="1" color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5" fill="true" visibility=":mtrack"/>
<mesh xi="0" yi="1" id="spd" width=":lthick+1" color="mono" visibility_id="on_0"/>

<!-- Axis -->
<axis ui:id="main_graph_ox" angle="0.0" min="10" max="24000" log="true" visibility="false"/>
Expand Down
19 changes: 17 additions & 2 deletions res/main/ui/analyzer/spectrum/x12.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,23 @@
</ui:with>

<!-- Meshes -->
<mesh xi="0" yi="1" id="spd" width="1" color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5" fill="true" visibility=":mtrack"/>
<mesh xi="0" yi="25"
id="spd" width="1"
color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5"
fill="true" visibility=":mtrack" />
<ui:for id="i" first="0" count="12">
<mesh xi="0" yi="${:i + 2}" id="spd" width=":lthick+1" color="graph_mesh_cycle" color.a="0.2" color.hue="${i} / 12.0" visibility="(((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))"/>
<mesh xi="0" yi="${:i + 13}"
id="spd" width="1"
color="graph_mesh_cycle" color.hue="${i} / 12.0" color.a="0.5"
fill.color="graph_mesh_cycle" fill.color.hue="${i} / 12.0" fill.color.a="0.9"
fill="true"
visibility=":ctrack and (((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))" />
</ui:for>
<ui:for id="i" first="0" count="12">
<mesh xi="0" yi="${:i + 1}"
id="spd" width=":lthick+1"
color="graph_mesh_cycle" color.hue="${i} / 12.0" color.a="0.2"
visibility="(((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))" />
</ui:for>

<!-- Axis -->
Expand Down Expand Up @@ -286,6 +300,7 @@
<combo id="lthick" visibility=":mode ilt 4"/>
<hbox fill="false" spacing="4" pad.h="4">
<button ui:inject="Button_cyan" text="labels.history" id="mtrack" size="16" visibility=":mode ilt 4"/>
<button ui:inject="Button_cyan" text="labels.signal.max" id="ctrack" size="16" visibility=":mode ilt 4"/>
<button ui:inject="Button_cyan" text="labels.clear" id="mreset" size="16" visibility=":mode ilt 4"/>
</hbox>
<button ui:inject="Button_cyan" text="labels.metering.measure_line" id="mline" size="16" visibility=":mode ilt 4" pad.l="15"/>
Expand Down
19 changes: 17 additions & 2 deletions res/main/ui/analyzer/spectrum/x16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,23 @@
</ui:with>

<!-- Meshes -->
<mesh xi="0" yi="1" id="spd" width="1" color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5" fill="true" visibility=":mtrack"/>
<mesh xi="0" yi="33"
id="spd" width="1"
color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5"
fill="true" visibility=":mtrack" />
<ui:for id="i" first="0" count="16">
<mesh xi="0" yi="${:i + 2}" id="spd" width=":lthick+1" color="graph_mesh_cycle" color.a="0.2" color.hue="${i} / 16.0" visibility="(((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))"/>
<mesh xi="0" yi="${:i + 17}"
id="spd" width="1"
color="graph_mesh_cycle" color.hue="${i} / 16.0" color.a="0.5"
fill.color="graph_mesh_cycle" fill.color.hue="${i} / 16.0" fill.color.a="0.9"
fill="true"
visibility=":ctrack and (((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))" />
</ui:for>
<ui:for id="i" first="0" count="16">
<mesh xi="0" yi="${:i + 1}"
id="spd" width=":lthick+1"
color="graph_mesh_cycle" color.hue="${i} / 16.0" color.a="0.2"
visibility="(((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))" />
</ui:for>

<!-- Axis -->
Expand Down Expand Up @@ -286,6 +300,7 @@
<combo id="lthick" visibility=":mode ilt 4"/>
<hbox fill="false" spacing="4" pad.h="4">
<button ui:inject="Button_cyan" text="labels.history" id="mtrack" size="16" visibility=":mode ilt 4"/>
<button ui:inject="Button_cyan" text="labels.signal.max" id="ctrack" size="16" visibility=":mode ilt 4"/>
<button ui:inject="Button_cyan" text="labels.clear" id="mreset" size="16" visibility=":mode ilt 4"/>
</hbox>
<button ui:inject="Button_cyan" text="labels.metering.measure_line" id="mline" size="16" visibility=":mode ilt 4" pad.l="15"/>
Expand Down
28 changes: 25 additions & 3 deletions res/main/ui/analyzer/spectrum/x2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,30 @@
</ui:with>

<!-- Meshes -->
<mesh xi="0" yi="1" id="spd" width="1" color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5" fill="true" visibility=":mtrack"/>
<mesh xi="0" yi="2" id="spd" width=":lthick+1" color="left" color.a="0.2" visibility_id="on_0"/>
<mesh xi="0" yi="3" id="spd" width=":lthick+1" color="right" color.a="0.2" visibility_id="on_1"/>
<mesh xi="0" yi="5"
id="spd" width="1"
color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5"
fill="true" visibility=":mtrack" />
<mesh xi="0" yi="3"
id="spd" width="1"
color="left" color.a="0.5"
fill.color="left" fill.color.a="0.9"
fill="true"
visibility=":ctrack and :on_0" />
<mesh xi="0" yi="4"
id="spd" width="1"
color="right" color.a="0.5"
fill.color="right" fill.color.a="0.9"
fill="true"
visibility=":ctrack and :on_1" />
<mesh xi="0" yi="1"
id="spd" width=":lthick+1"
color="left" color.a="0.2"
visibility="on_0" />
<mesh xi="0" yi="2"
id="spd" width=":lthick+1"
color="right" color.a="0.2"
visibility="on_1" />

<!-- Axis -->
<axis ui:id="main_graph_ox" angle="0.0" min="10" max="24000" color="graph_prim" log="true" visibility="false"/>
Expand Down Expand Up @@ -264,6 +285,7 @@
<combo id="lthick" visibility=":mode ilt 2"/>
<hbox fill="false" spacing="4" pad.h="4" visibility=":mode ilt 2">
<button ui:inject="Button_cyan" text="labels.history" id="mtrack" size="16"/>
<button ui:inject="Button_cyan" text="labels.signal.max" id="ctrack" size="16" />
<button ui:inject="Button_cyan" text="labels.clear" id="mreset" size="16"/>
</hbox>

Expand Down
19 changes: 17 additions & 2 deletions res/main/ui/analyzer/spectrum/x4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,23 @@
</ui:with>

<!-- Meshes -->
<mesh xi="0" yi="1" id="spd" width="1" color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5" fill="true" visibility=":mtrack"/>
<mesh xi="0" yi="9"
id="spd" width="1"
color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5"
fill="true" visibility=":mtrack" />
<ui:for id="i" first="0" count="4">
<mesh xi="0" yi="${:i + 2}" id="spd" width=":lthick+1" color="graph_mesh_cycle" color.hue="${i} / 4.0" color.a="0.2" visibility="(((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))"/>
<mesh xi="0" yi="${:i + 5}"
id="spd" width="1"
color="graph_mesh_cycle" color.hue="${i} / 4.0" color.a="0.5"
fill.color="graph_mesh_cycle" fill.color.hue="${i} / 4.0" fill.color.a="0.9"
fill="true"
visibility=":ctrack and (((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))" />
</ui:for>
<ui:for id="i" first="0" count="4">
<mesh xi="0" yi="${:i + 1}"
id="spd" width=":lthick+1"
color="graph_mesh_cycle" color.hue="${i} / 4.0" color.a="0.2"
visibility="(((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))" />
</ui:for>

<!-- Axis -->
Expand Down Expand Up @@ -290,6 +304,7 @@
<combo id="lthick" visibility=":mode ilt 4"/>
<hbox fill="false" spacing="4" pad.h="4">
<button ui:inject="Button_cyan" text="labels.history" id="mtrack" size="16" visibility=":mode ilt 4"/>
<button ui:inject="Button_cyan" text="labels.signal.max" id="ctrack" size="16" visibility=":mode ilt 4"/>
<button ui:inject="Button_cyan" text="labels.clear" id="mreset" size="16" visibility=":mode ilt 4"/>
</hbox>
<button ui:inject="Button_cyan" text="labels.metering.measure_line" id="mline" size="16" visibility=":mode ilt 4" pad.l="15"/>
Expand Down
20 changes: 20 additions & 0 deletions res/main/ui/analyzer/spectrum/x8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@
</ui:with>

<!-- Meshes -->
<mesh xi="0" yi="17"
id="spd" width="1"
color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5"
fill="true" visibility=":mtrack" />
<ui:for id="i" first="0" count="8">
<mesh xi="0" yi="${:i + 9}"
id="spd" width="1"
color="graph_mesh_cycle" color.hue="${i} / 8.0" color.a="0.5"
fill.color="graph_mesh_cycle" fill.color.hue="${i} / 8.0" fill.color.a="0.9"
fill="true"
visibility=":ctrack and (((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))" />
</ui:for>
<ui:for id="i" first="0" count="8">
<mesh xi="0" yi="${:i + 1}"
id="spd" width=":lthick+1"
color="graph_mesh_cycle" color.hue="${i} / 8.0" color.a="0.2"
visibility="(((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))" />
</ui:for>

<mesh xi="0" yi="1" id="spd" width="1" color="cyan" fill.color="cyan" fill.color.a="0.9" color.a="0.5" fill="true" visibility=":mtrack"/>
<ui:for id="i" first="0" count="8">
<mesh xi="0" yi="${:i + 2}" id="spd" width=":lthick+1" color="graph_mesh_cycle" color.a="0.2" color.hue="${i} / 8.0" visibility="(((:mode ieq 0) or (:mode ieq 2)) and (:on_${i})) or ((:mode ieq 1) or (:mode ieq 3) and ((:spc0 ieq ${i}) or (:spc1 ieq ${i})))"/>
Expand Down Expand Up @@ -286,6 +305,7 @@
<combo id="lthick" visibility=":mode ilt 4"/>
<hbox fill="false" spacing="4" pad.h="4">
<button ui:inject="Button_cyan" text="labels.history" id="mtrack" size="16" visibility=":mode ilt 4"/>
<button ui:inject="Button_cyan" text="labels.signal.max" id="ctrack" size="16" visibility=":mode ilt 4"/>
<button ui:inject="Button_cyan" text="labels.clear" id="mreset" size="16" visibility=":mode ilt 4"/>
</hbox>
<button ui:inject="Button_cyan" text="labels.metering.measure_line" id="mline" size="16" visibility=":mode ilt 4" pad.l="15"/>
Expand Down
5 changes: 5 additions & 0 deletions src/doc/manuals/plugins/spectrum_analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
<li><b>Window</b> - the window applied to the audio data before processing.</li>
<li><b>Tolerance</b> - the number of points for the FFT (Fast Fourier Transform) analysis.</li>
<li><b>Envelope</b> - the envelope compensation of the signal.</li>
<li><b>History</b> - Show chart with maximum registered peak values among the full frequency range of all channels.</li>
<?php if ($nc > 1) {?>
<li><b>Max</b> - Show chart with maximum registered peak values among the full frequency range of selected channels.</li>
<?php } ?>
<li><b>Clear</b> - Clear charts with maximum retistered peak values among the full frequency range.</li>
<li><b>Zoom</b> - zoom fader, allows to adjust zoom on the frequency chart.</li>
</ul>

Expand Down
25 changes: 13 additions & 12 deletions src/main/meta/spectrum_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ namespace lsp
SWITCH("frz_" #x, "Freeze " #x, 0.0f), \
AMP_GAIN("sh_" #x, "Shift gain " #x, 1.0f, 1000.0f)

#define SA_MULTI_CHANNEL(...) __VA_ARGS__
#define SA_SINGLE_CHANNEL(...)

#define SA_COMMON(c, channel) \
BYPASS, \
COMBO("mode", "Analyzer mode", 0, spectrum_analyzer_x ## c ## _modes), \
Expand All @@ -166,7 +169,8 @@ namespace lsp
SWITCH("splog", "Spectralizer logarithmic scale", 1), \
SWITCH("freeze", "Analyzer freeze", 0), \
SWITCH("mline", "Horizontal measuring line", 0), \
SWITCH("mtrack", "Track maximum values", 1), \
SWITCH("mtrack", "Show maximum values for all channels", 1), \
channel(SWITCH("ctrack", "Track maximum values for individual channels", 0), ) \
TRIGGER("mreset", "Reset maximum values"), \
{ "tol", "FFT Tolerance", U_ENUM, R_CONTROL, 0, 0, 0, spectrum_analyzer::RANK_DFL - spectrum_analyzer::RANK_MIN, 0, fft_tolerance }, \
{ "wnd", "FFT Window", U_ENUM, R_CONTROL, 0, 0, 0, spectrum_analyzer::WND_DFL, 0, fft_windows }, \
Expand All @@ -175,13 +179,13 @@ namespace lsp
LOG_CONTROL("zoom", "Graph zoom", U_GAIN_AMP, spectrum_analyzer::ZOOM), \
{ "react", "Reactivity", U_SEC, R_CONTROL, F_UPPER | F_LOWER | F_STEP | F_LOG, \
spectrum_analyzer::REACT_TIME_MIN, spectrum_analyzer::REACT_TIME_MAX, spectrum_analyzer::REACT_TIME_DFL, spectrum_analyzer::REACT_TIME_STEP, NULL }, \
channel(c) \
channel({ "chn", "Channel", U_ENUM, R_CONTROL, 0, 0, 0, 0, 0, spectrum_analyzer_x ## c ## _channels }, ) \
LOG_CONTROL("sel", "Selector", U_HZ, spectrum_analyzer::SELECTOR), \
LOG_CONTROL("mlval", "Horizontal measuring line level value", U_DB, spectrum_analyzer::HLINE), \
{ "freq", "Frequency", U_HZ, R_METER, F_UPPER | F_LOWER, \
spectrum_analyzer::FREQ_MIN, spectrum_analyzer::FREQ_MAX, spectrum_analyzer::FREQ_DFL, 0, NULL }, \
{ "lvl", "Level", U_GAIN_AMP, R_METER, F_UPPER | F_LOWER, 0, 10000, 0, 0, NULL }, \
MESH("spd", "Spectrum Data", c + 2, spectrum_analyzer::MESH_POINTS + 4)
MESH("spd", "Spectrum Data", c*2 + 2, spectrum_analyzer::MESH_POINTS + 4)

#define SA_MGROUP(id) \
OPT_RETURN_MONO("ret_" #id, "rin_" #id, "Audio return group " #id)
Expand All @@ -191,14 +195,11 @@ namespace lsp
SWITCH("ms_" #id, "Mid/Side switch for channel pair " #id, 0), \
SA_CORRMETER("cm_" #id, "Correlometer for stereo channel pair " #id)

#define SA_CHANNEL(c) { "chn", "Channel", U_ENUM, R_CONTROL, 0, 0, 0, 0, 0, spectrum_analyzer_x ## c ## _channels },
#define SA_SKIP(c)

static const port_t spectrum_analyzer_x1_ports[] =
{
SA_INPUT(0, 1),
SA_MGROUP(0),
SA_COMMON(1, SA_SKIP),
SA_COMMON(1, SA_SINGLE_CHANNEL),
FBUFFER("fb", "Spectralizer buffer", spectrum_analyzer::FB_ROWS, spectrum_analyzer::MESH_POINTS),
PORTS_END
};
Expand All @@ -208,7 +209,7 @@ namespace lsp
SA_INPUT(0, 1),
SA_INPUT(1, 1),
SA_SGROUP(0),
SA_COMMON(2, SA_CHANNEL),
SA_COMMON(2, SA_MULTI_CHANNEL),
SWITCH("ms", "Stereo analysis Mid/Side mode", 0),
COMBO("spc", "Spectralizer channel", 0, spectrum_analyzer_x2_channels),
FBUFFER("fb0", "Spectralizer buffer 0", spectrum_analyzer::FB_ROWS, spectrum_analyzer::MESH_POINTS),
Expand All @@ -224,7 +225,7 @@ namespace lsp
SA_INPUT(3, 0),
SA_SGROUP(0),
SA_SGROUP(1),
SA_COMMON(4, SA_CHANNEL),
SA_COMMON(4, SA_MULTI_CHANNEL),
SA_CORRMETER("cccm", "Correlometer for selected channels"),
SWITCH("ms", "Stereo analysis Mid/Side mode", 0),
COMBO("spc0", "Spectralizer channel 0", 0, spectrum_analyzer_x4_channels),
Expand All @@ -248,7 +249,7 @@ namespace lsp
SA_SGROUP(1),
SA_SGROUP(2),
SA_SGROUP(3),
SA_COMMON(8, SA_CHANNEL),
SA_COMMON(8, SA_MULTI_CHANNEL),
SA_CORRMETER("cccm", "Correlometer for selected channels"),
SWITCH("ms", "Stereo analysis Mid/Side mode", 0),
COMBO("spc0", "Spectralizer channel 0", 0, spectrum_analyzer_x8_channels),
Expand Down Expand Up @@ -278,7 +279,7 @@ namespace lsp
SA_SGROUP(3),
SA_SGROUP(4),
SA_SGROUP(5),
SA_COMMON(12, SA_CHANNEL),
SA_COMMON(12, SA_MULTI_CHANNEL),
SA_CORRMETER("cccm", "Correlometer for selected channels"),
SWITCH("ms", "Stereo analysis Mid/Side mode", 0),
COMBO("spc0", "Spectralizer channel 0", 0, spectrum_analyzer_x12_channels),
Expand Down Expand Up @@ -314,7 +315,7 @@ namespace lsp
SA_SGROUP(5),
SA_SGROUP(6),
SA_SGROUP(7),
SA_COMMON(16, SA_CHANNEL),
SA_COMMON(16, SA_MULTI_CHANNEL),
SA_CORRMETER("cccm", "Correlometer for selected channels"),
SWITCH("ms", "Stereo analysis Mid/Side mode", 0),
COMBO("spc0", "Spectralizer channel 0", 0, spectrum_analyzer_x16_channels),
Expand Down
Loading

0 comments on commit 09c6cc8

Please sign in to comment.