Skip to content

Commit

Permalink
Added shared memory links for signal analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
sadko4u committed Dec 2, 2024
1 parent 93e5cce commit a07c33b
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 69 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 shared memory links for signal analysis.
* Removed the unused 'Hue' parameter for channels.

=== 1.0.28 ===
Expand Down
2 changes: 2 additions & 0 deletions include/private/plugins/spectrum_analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ namespace lsp
float fGain; // Makeup gain
float *vIn; // Input buffer pointer
float *vOut; // Output buffer pointer
float *vRet; // Return buffer
float *vBuffer; // Temporary buffer

// Port references
plug::IPort *pIn; // Input samples
plug::IPort *pOut; // Output samples
plug::IPort *pRet; // Return
plug::IPort *pMSSwitch; // Mid/Side switch
plug::IPort *pOn; // FFT on
plug::IPort *pSolo; // Soloing flag
Expand Down
1 change: 1 addition & 0 deletions res/main/ui/analyzer/spectrum/x1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
</cell>

<vbox padding="6">
<shmlink id="ret_0" value.maxlen="6" text.clip="true" hfill="true" />
<button ui:inject="Button_cyan" id="frz_0" text="labels.chan.hold" size="16" width="60"/>
</vbox>

Expand Down
7 changes: 5 additions & 2 deletions res/main/ui/analyzer/spectrum/x12.xml
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,16 @@

<ui:if test=":i % 2 ieq 0">
<cell cols="3" pad.h="6" pad.v="4" bg.color="bg_schema">
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_${:i idiv 2}" height="19" hfill="true"/>
<vbox>
<shmlink id="ret_${:i idiv 2}" value.maxlen="6" text.clip="true" hfill="true" />
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_${:i idiv 2}" height="19" hfill="true"/>
</vbox>
</cell>
<cell cols="3" pad.h="6" pad.v="4" bg.color="bg_schema">
<hbox>
<label text="-1" font.size="8" hfill="true" text.halign="-1" pad.t="2" pad.r="1"/>
<ledchannel
id="cm_${:i / 2}"
id="cm_${:i idiv 2}"
width.min="13"
width.max="13"
min="-100"
Expand Down
5 changes: 4 additions & 1 deletion res/main/ui/analyzer/spectrum/x16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@

<ui:if test=":i % 2 ieq 0">
<cell cols="3" pad.h="6" pad.v="4" bg.color="bg_schema">
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_${:i idiv 2}" height="19" hfill="true"/>
<vbox>
<shmlink id="ret_${:i idiv 2}" value.maxlen="6" text.clip="true" hfill="true" />
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_${:i idiv 2}" height="19" hfill="true"/>
</vbox>
</cell>
<cell cols="3" pad.h="6" pad.v="4" bg.color="bg_schema">
<hbox>
Expand Down
5 changes: 4 additions & 1 deletion res/main/ui/analyzer/spectrum/x2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@
</grid>
</group>

<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_0" height="19" hfill="true" pad.v="4" pad.h="6"/>
<vbox>
<shmlink id="ret_0" value.maxlen="6" text.clip="true" hfill="true" />
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_0" height="19" hfill="true" pad.v="4" pad.h="6"/>
</vbox>

<vbox vfill="false" bg.color="bg_schema" pad.v="4" pad.h="6">
<label text="labels.chan.correlation" pad.v="0"/>
Expand Down
7 changes: 5 additions & 2 deletions res/main/ui/analyzer/spectrum/x4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,16 @@

<ui:if test=":i % 2 ieq 0">
<cell cols="3" pad.h="6" pad.v="4" bg.color="bg_schema">
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_${:i idiv 2}" height="19" hfill="true"/>
<vbox>
<shmlink id="ret_${:i idiv 2}" value.maxlen="6" text.clip="true" hfill="true" />
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_${:i idiv 2}" height="19" hfill="true"/>
</vbox>
</cell>
<cell cols="3" pad.h="6" pad.v="4" bg.color="bg_schema">
<hbox>
<label text="-1" font.size="8" hfill="true" text.halign="-1" pad.t="2" pad.r="1"/>
<ledchannel
id="cm_${:i / 2}"
id="cm_${:i idiv 2}"
width.min="13"
width.max="13"
min="-100"
Expand Down
7 changes: 5 additions & 2 deletions res/main/ui/analyzer/spectrum/x8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,16 @@

<ui:if test=":i % 2 ieq 0">
<cell cols="3" pad.h="6" pad.v="4" bg.color="bg_schema">
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_${:i idiv 2}" height="19" hfill="true"/>
<vbox>
<shmlink id="ret_${:i idiv 2}" value.maxlen="6" text.clip="true" hfill="true" />
<button bg.color="bg_schema" text="labels.chan.mid_side" id="ms_${:i idiv 2}" height="19" hfill="true"/>
</vbox>
</cell>
<cell cols="3" pad.h="6" pad.v="4" bg.color="bg_schema">
<hbox>
<label text="-1" font.size="8" hfill="true" text.halign="-1" pad.t="2" pad.r="1"/>
<ledchannel
id="cm_${:i / 2}"
id="cm_${:i idiv 2}"
width.min="13"
width.max="13"
min="-100"
Expand Down
1 change: 1 addition & 0 deletions src/doc/manuals/plugins/spectrum_analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<li><b>Hold</b> - forces the frequency graph of the channel to freeze.</li>
<li><b>Shift</b> - allows to adjust the gain of the channel.</li>
<li><b>Preamp</b> - allows to adjust the overall gain of the analysis.</li>
<li><b>Link</b> - stereo link, allows to add signal to the input channel <?php if ($nc > 1) { ?>pair<?php } ?> passed from the shared memory link.</li>
<?php if ($nc > 1) { ?>
<li><b>Channel</b> - allows to select the channel for level metering.</li>
<li><b>Mid/Side</b> - allows to switch the channel pair (which consists of two near subsequent channels) to the Mid/Side analysis mode.</li>
Expand Down
93 changes: 49 additions & 44 deletions src/main/meta/spectrum_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace lsp
#define SA_CORRMETER(id, label) \
METER(id, label, U_PERCENT, spectrum_analyzer::CORRELATION)

#define SA_INPUT(x, total, active) \
#define SA_INPUT(x, active) \
AUDIO_INPUT_N(x), \
AUDIO_OUTPUT_N(x), \
SWITCH("on_" #x, "Analyse " #x, active), \
Expand Down Expand Up @@ -183,7 +183,11 @@ namespace lsp
{ "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)

#define SA_MGROUP(id) \
OPT_RETURN_MONO("ret_" #id, "rin_" #id, "Audio return group " #id)

#define SA_SGROUP(id) \
OPT_RETURN_STEREO("ret_" #id, "rin_" #id, "Audio return group " #id), \
SWITCH("ms_" #id, "Mid/Side switch for channel pair " #id, 0), \
SA_CORRMETER("cm_" #id, "Correlometer for stereo channel pair " #id)

Expand All @@ -192,16 +196,17 @@ namespace lsp

static const port_t spectrum_analyzer_x1_ports[] =
{
SA_INPUT(0, 1, 1),
SA_INPUT(0, 1),
SA_MGROUP(0),
SA_COMMON(1, SA_SKIP),
FBUFFER("fb", "Spectralizer buffer", spectrum_analyzer::FB_ROWS, spectrum_analyzer::MESH_POINTS),
PORTS_END
};

static const port_t spectrum_analyzer_x2_ports[] =
{
SA_INPUT(0, 2, 1),
SA_INPUT(1, 2, 1),
SA_INPUT(0, 1),
SA_INPUT(1, 1),
SA_SGROUP(0),
SA_COMMON(2, SA_CHANNEL),
SWITCH("ms", "Stereo analysis Mid/Side mode", 0),
Expand All @@ -213,10 +218,10 @@ namespace lsp

static const port_t spectrum_analyzer_x4_ports[] =
{
SA_INPUT(0, 4, 1),
SA_INPUT(1, 4, 1),
SA_INPUT(2, 4, 0),
SA_INPUT(3, 4, 0),
SA_INPUT(0, 1),
SA_INPUT(1, 1),
SA_INPUT(2, 0),
SA_INPUT(3, 0),
SA_SGROUP(0),
SA_SGROUP(1),
SA_COMMON(4, SA_CHANNEL),
Expand All @@ -231,14 +236,14 @@ namespace lsp

static const port_t spectrum_analyzer_x8_ports[] =
{
SA_INPUT(0, 8, 1),
SA_INPUT(1, 8, 1),
SA_INPUT(2, 8, 0),
SA_INPUT(3, 8, 0),
SA_INPUT(4, 8, 0),
SA_INPUT(5, 8, 0),
SA_INPUT(6, 8, 0),
SA_INPUT(7, 8, 0),
SA_INPUT(0, 1),
SA_INPUT(1, 1),
SA_INPUT(2, 0),
SA_INPUT(3, 0),
SA_INPUT(4, 0),
SA_INPUT(5, 0),
SA_INPUT(6, 0),
SA_INPUT(7, 0),
SA_SGROUP(0),
SA_SGROUP(1),
SA_SGROUP(2),
Expand All @@ -255,18 +260,18 @@ namespace lsp

static const port_t spectrum_analyzer_x12_ports[] =
{
SA_INPUT(0, 12, 1),
SA_INPUT(1, 12, 1),
SA_INPUT(2, 12, 0),
SA_INPUT(3, 12, 0),
SA_INPUT(4, 12, 0),
SA_INPUT(5, 12, 0),
SA_INPUT(6, 12, 0),
SA_INPUT(7, 12, 0),
SA_INPUT(8, 12, 0),
SA_INPUT(9, 12, 0),
SA_INPUT(10, 12, 0),
SA_INPUT(11, 12, 0),
SA_INPUT(0, 1),
SA_INPUT(1, 1),
SA_INPUT(2, 0),
SA_INPUT(3, 0),
SA_INPUT(4, 0),
SA_INPUT(5, 0),
SA_INPUT(6, 0),
SA_INPUT(7, 0),
SA_INPUT(8, 0),
SA_INPUT(9, 0),
SA_INPUT(10, 0),
SA_INPUT(11, 0),
SA_SGROUP(0),
SA_SGROUP(1),
SA_SGROUP(2),
Expand All @@ -285,22 +290,22 @@ namespace lsp

static const port_t spectrum_analyzer_x16_ports[] =
{
SA_INPUT(0, 16, 1),
SA_INPUT(1, 16, 1),
SA_INPUT(2, 16, 0),
SA_INPUT(3, 16, 0),
SA_INPUT(4, 16, 0),
SA_INPUT(5, 16, 0),
SA_INPUT(6, 16, 0),
SA_INPUT(7, 16, 0),
SA_INPUT(8, 16, 0),
SA_INPUT(9, 16, 0),
SA_INPUT(10, 16, 0),
SA_INPUT(11, 16, 0),
SA_INPUT(12, 16, 0),
SA_INPUT(13, 16, 0),
SA_INPUT(14, 16, 0),
SA_INPUT(15, 16, 0),
SA_INPUT(0, 1),
SA_INPUT(1, 1),
SA_INPUT(2, 0),
SA_INPUT(3, 0),
SA_INPUT(4, 0),
SA_INPUT(5, 0),
SA_INPUT(6, 0),
SA_INPUT(7, 0),
SA_INPUT(8, 0),
SA_INPUT(9, 0),
SA_INPUT(10, 0),
SA_INPUT(11, 0),
SA_INPUT(12, 0),
SA_INPUT(13, 0),
SA_INPUT(14, 0),
SA_INPUT(15, 0),
SA_SGROUP(0),
SA_SGROUP(1),
SA_SGROUP(2),
Expand Down
Loading

0 comments on commit a07c33b

Please sign in to comment.