diff --git a/.cproject b/.cproject
index 9daa9d2..7c7fd4d 100644
--- a/.cproject
+++ b/.cproject
@@ -98,6 +98,7 @@
@@ -124,7 +125,7 @@
-
+
@@ -218,7 +219,7 @@
-
+
@@ -371,7 +372,7 @@
-
+
diff --git a/CHANGELOG b/CHANGELOG
index 9a0cd8c..ac47264 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,9 @@
* RECENT CHANGES
*******************************************************************************
+=== 1.0.24 ===
+* Updated build scripts and dependencies.
+
=== 1.0.23 ===
* Updated build scripts and dependencies.
diff --git a/dependencies.mk b/dependencies.mk
index 3ef6589..7942ad9 100644
--- a/dependencies.mk
+++ b/dependencies.mk
@@ -44,6 +44,7 @@ DEFAULT_FEATURES = clap doc ladspa lv2 vst2 vst3 xdg
LINUX_DEPENDENCIES = \
LIBPTHREAD \
LIBDL \
+ LIBRT \
LIBSNDFILE \
LIBCAIRO \
LIBFREETYPE \
@@ -66,6 +67,7 @@ endif
BSD_DEPENDENCIES = \
LIBPTHREAD \
LIBDL \
+ LIBRT \
LIBSNDFILE \
LIBICONV \
LIBCAIRO \
diff --git a/include/private/meta/spectrum_analyzer.h b/include/private/meta/spectrum_analyzer.h
index 2c66186..afc228f 100644
--- a/include/private/meta/spectrum_analyzer.h
+++ b/include/private/meta/spectrum_analyzer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Linux Studio Plugins Project
- * (C) 2021 Vladimir Sadovnikov
+ * Copyright (C) 2024 Linux Studio Plugins Project
+ * (C) 2024 Vladimir Sadovnikov
*
* This file is part of lsp-plugins-spectrum-analyzer
* Created on: 22 июн. 2021 г.
@@ -38,11 +38,12 @@ namespace lsp
static constexpr float FREQ_MIN = SPEC_FREQ_MIN;
static constexpr float FREQ_DFL = 1000.0f;
static constexpr float FREQ_MAX = SPEC_FREQ_MAX;
+ static constexpr float CORR_PERIOD = 100.0f;
static constexpr size_t PORTS_PER_INPUT = 6;
static constexpr size_t RANK_MIN = 10;
static constexpr size_t RANK_DFL = 12;
- static constexpr size_t RANK_MAX = 14;
+ static constexpr size_t RANK_MAX = 15;
static constexpr size_t MESH_POINTS = 640;
static constexpr float THRESH_HI_DB = 0.0f;
@@ -64,6 +65,11 @@ namespace lsp
static constexpr float SELECTOR_MAX = SPEC_FREQ_MAX;
static constexpr float SELECTOR_STEP = 0.005f;
+ static constexpr float CORRELATION_MIN = -100.0f;
+ static constexpr float CORRELATION_MAX = 100.0f;
+ static constexpr float CORRELATION_DFL = 0.0f;
+ static constexpr float CORRELATION_STEP = 0.1f;
+
static constexpr float HLINE_MIN = GAIN_AMP_M_72_DB;
static constexpr float HLINE_DFL = GAIN_AMP_0_DB;
static constexpr float HLINE_MAX = GAIN_AMP_P_24_DB;
diff --git a/include/private/plugins/spectrum_analyzer.h b/include/private/plugins/spectrum_analyzer.h
index 500d847..25deefe 100644
--- a/include/private/plugins/spectrum_analyzer.h
+++ b/include/private/plugins/spectrum_analyzer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2023 Linux Studio Plugins Project
- * (C) 2023 Vladimir Sadovnikov
+ * Copyright (C) 2024 Linux Studio Plugins Project
+ * (C) 2024 Vladimir Sadovnikov
*
* This file is part of lsp-plugins-spectrum-analyzer
* Created on: 22 июн. 2021 г.
@@ -23,6 +23,7 @@
#define PRIVATE_PLUGINS_SPECTRUM_ANALYZER_H_
#include
+#include
#include
#include
#include
@@ -62,13 +63,20 @@ namespace lsp
typedef struct sa_spectralizer_t
{
- ssize_t nPortId; // Last port identifier
- ssize_t nChannelId; // Channel identifier
+ int32_t nPortId; // Last port identifier
+ int32_t nChannelId; // Channel identifier
plug::IPort *pPortId; // Port identifier
plug::IPort *pFBuffer; // Frame buffer port
} sa_spectralizer_t;
+ typedef struct sa_correlometer_t
+ {
+ dspu::Correlometer sCorr; // Correlometer
+ float fCorrelation; // Measured correlation value
+ plug::IPort *pCorrelometer; // Correlometer output value
+ } sa_correlometer_t;
+
enum mode_t
{
SA_ANALYZER,
@@ -90,8 +98,10 @@ namespace lsp
protected:
dspu::Analyzer sAnalyzer;
dspu::Counter sCounter;
- size_t nChannels;
+ uint32_t nChannels;
+ uint32_t nCorrelometers;
sa_channel_t *vChannels;
+ sa_correlometer_t *vCorrelometers; // Available correlometers
float **vAnalyze; // Analysis buffers
float *vFrequences;
float *vMaxValues; // Maximum value tracking
@@ -152,6 +162,7 @@ namespace lsp
void process_multiple();
void process_spectralizer();
void get_spectrum(float *dst, size_t channel, size_t flags);
+ void measure_correlation(size_t count);
void prepare_buffers(size_t count);
public:
diff --git a/make/tools.mk b/make/tools.mk
index cedf900..08c295f 100644
--- a/make/tools.mk
+++ b/make/tools.mk
@@ -76,6 +76,8 @@ ifeq ($(PLATFORM),Solaris)
else ifeq ($(PLATFORM),Windows)
FLAG_RELRO =
FLAG_STDLIB =
+ CFLAGS_EXT += -DWINVER=0x600 -D_WIN32_WINNT=0x600
+ CXXFLAGS_EXT += -DWINVER=0x600 -D_WIN32_WINNT=0x600
EXE_FLAGS_EXT += -static-libgcc -static-libstdc++
SO_FLAGS_EXT += -static-libgcc -static-libstdc++
LDFLAGS_EXT += -T $(CURDIR)/make/ld-windows.script
diff --git a/modules.mk b/modules.mk
index a73d9ce..80c851a 100644
--- a/modules.mk
+++ b/modules.mk
@@ -19,93 +19,93 @@
#
# Variables that describe dependencies
-LSP_3RD_PARTY_VERSION := 1.0.15
+LSP_3RD_PARTY_VERSION := 1.0.16
LSP_3RD_PARTY_NAME := lsp-3rd-party
LSP_3RD_PARTY_TYPE := hdr
LSP_3RD_PARTY_INC_OPT := -idirafter
LSP_3RD_PARTY_URL_RO := https://github.com/lsp-plugins/$(LSP_3RD_PARTY_NAME).git
LSP_3RD_PARTY_URL_RW := git@github.com:lsp-plugins/$(LSP_3RD_PARTY_NAME).git
-LSP_COMMON_LIB_VERSION := 1.0.34
+LSP_COMMON_LIB_VERSION := 1.0.36
LSP_COMMON_LIB_NAME := lsp-common-lib
LSP_COMMON_LIB_TYPE := src
LSP_COMMON_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_COMMON_LIB_NAME).git
LSP_COMMON_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_COMMON_LIB_NAME).git
-LSP_DSP_LIB_VERSION := 1.0.21
+LSP_DSP_LIB_VERSION := 1.0.23
LSP_DSP_LIB_NAME := lsp-dsp-lib
LSP_DSP_LIB_TYPE := src
LSP_DSP_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_DSP_LIB_NAME).git
LSP_DSP_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_DSP_LIB_NAME).git
-LSP_DSP_UNITS_VERSION := 1.0.20
+LSP_DSP_UNITS_VERSION := 1.0.22
LSP_DSP_UNITS_NAME := lsp-dsp-units
LSP_DSP_UNITS_TYPE := src
LSP_DSP_UNITS_URL_RO := https://github.com/lsp-plugins/$(LSP_DSP_UNITS_NAME).git
LSP_DSP_UNITS_URL_RW := git@github.com:lsp-plugins/$(LSP_DSP_UNITS_NAME).git
-LSP_LLTL_LIB_VERSION := 1.0.17
+LSP_LLTL_LIB_VERSION := 1.0.19
LSP_LLTL_LIB_NAME := lsp-lltl-lib
LSP_LLTL_LIB_TYPE := src
LSP_LLTL_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_LLTL_LIB_NAME).git
LSP_LLTL_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_LLTL_LIB_NAME).git
-LSP_R3D_BASE_LIB_VERSION := 1.0.17
+LSP_R3D_BASE_LIB_VERSION := 1.0.18
LSP_R3D_BASE_LIB_NAME := lsp-r3d-base-lib
LSP_R3D_BASE_LIB_TYPE := src
LSP_R3D_BASE_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_R3D_BASE_LIB_NAME).git
LSP_R3D_BASE_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_R3D_BASE_LIB_NAME).git
-LSP_R3D_IFACE_VERSION := 1.0.17
+LSP_R3D_IFACE_VERSION := 1.0.18
LSP_R3D_IFACE_NAME := lsp-r3d-iface
LSP_R3D_IFACE_TYPE := src
LSP_R3D_IFACE_URL_RO := https://github.com/lsp-plugins/$(LSP_R3D_IFACE_NAME).git
LSP_R3D_IFACE_URL_RW := git@github.com:lsp-plugins/$(LSP_R3D_IFACE_NAME).git
-LSP_R3D_GLX_LIB_VERSION := 1.0.17
+LSP_R3D_GLX_LIB_VERSION := 1.0.18
LSP_R3D_GLX_LIB_NAME := lsp-r3d-glx-lib
LSP_R3D_GLX_LIB_TYPE := bin
LSP_R3D_GLX_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_R3D_GLX_LIB_NAME).git
LSP_R3D_GLX_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_R3D_GLX_LIB_NAME).git
-LSP_R3D_WGL_LIB_VERSION := 1.0.12
+LSP_R3D_WGL_LIB_VERSION := 1.0.13
LSP_R3D_WGL_LIB_NAME := lsp-r3d-wgl-lib
LSP_R3D_WGL_LIB_TYPE := bin
LSP_R3D_WGL_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_R3D_WGL_LIB_NAME).git
LSP_R3D_WGL_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_R3D_WGL_LIB_NAME).git
-LSP_RUNTIME_LIB_VERSION := 1.0.20
+LSP_RUNTIME_LIB_VERSION := 1.0.22
LSP_RUNTIME_LIB_NAME := lsp-runtime-lib
LSP_RUNTIME_LIB_TYPE := src
LSP_RUNTIME_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_RUNTIME_LIB_NAME).git
LSP_RUNTIME_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_RUNTIME_LIB_NAME).git
-LSP_TEST_FW_VERSION := 1.0.24
+LSP_TEST_FW_VERSION := 1.0.25
LSP_TEST_FW_NAME := lsp-test-fw
LSP_TEST_FW_TYPE := src
LSP_TEST_FW_URL_RO := https://github.com/lsp-plugins/$(LSP_TEST_FW_NAME).git
LSP_TEST_FW_URL_RW := git@github.com:lsp-plugins/$(LSP_TEST_FW_NAME).git
-LSP_TK_LIB_VERSION := 1.0.20
+LSP_TK_LIB_VERSION := 1.0.21
LSP_TK_LIB_NAME := lsp-tk-lib
LSP_TK_LIB_TYPE := src
LSP_TK_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_TK_LIB_NAME).git
LSP_TK_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_TK_LIB_NAME).git
-LSP_WS_LIB_VERSION := 1.0.20
+LSP_WS_LIB_VERSION := 1.0.21
LSP_WS_LIB_NAME := lsp-ws-lib
LSP_WS_LIB_TYPE := src
LSP_WS_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_WS_LIB_NAME).git
LSP_WS_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_WS_LIB_NAME).git
# Plugin-related module dependencies
-LSP_PLUGIN_FW_VERSION := 1.0.22
+LSP_PLUGIN_FW_VERSION := 1.0.23
LSP_PLUGIN_FW_NAME := lsp-plugin-fw
LSP_PLUGIN_FW_TYPE := src
LSP_PLUGIN_FW_URL_RO := https://github.com/lsp-plugins/$(LSP_PLUGIN_FW_NAME).git
LSP_PLUGIN_FW_URL_RW := git@github.com:lsp-plugins/$(LSP_PLUGIN_FW_NAME).git
-LSP_PLUGINS_SHARED_VERSION := 1.0.21
+LSP_PLUGINS_SHARED_VERSION := 1.0.22
LSP_PLUGINS_SHARED_NAME := lsp-plugins-shared
LSP_PLUGINS_SHARED_TYPE := src
LSP_PLUGINS_SHARED_URL_RO := https://github.com/lsp-plugins/$(LSP_PLUGINS_SHARED_NAME).git
@@ -154,15 +154,15 @@ LIBICONV_NAME := libiconv
LIBICONV_TYPE := opt
LIBICONV_LDFLAGS := -liconv
+LIBJACK_VERSION := system
+LIBJACK_NAME := jack
+LIBJACK_TYPE := pkg
+
LIBMPR_VERSION := system
LIBMPR_NAME := libmpr
LIBMPR_TYPE := opt
LIBMPR_LDFLAGS := -lmpr
-LIBJACK_VERSION := system
-LIBJACK_NAME := jack
-LIBJACK_TYPE := pkg
-
LIBMSACM_VERSION := system
LIBMSACM_NAME := libmsacm
LIBMSACM_TYPE := opt
@@ -183,6 +183,11 @@ LIBPTHREAD_NAME := libpthread
LIBPTHREAD_TYPE := opt
LIBPTHREAD_LDFLAGS := -lpthread
+LIBRT_VERSION := system
+LIBRT_NAME := librt
+LIBRT_TYPE := opt
+LIBRT_LDFLAGS := -lrt
+
LIBSNDFILE_VERSION := system
LIBSNDFILE_NAME := sndfile
LIBSNDFILE_TYPE := pkg
diff --git a/project.mk b/project.mk
index 18901ff..c473300 100644
--- a/project.mk
+++ b/project.mk
@@ -25,7 +25,7 @@ ARTIFACT_TYPE = plug
ARTIFACT_DESC = LSP Spectrum Analyzer Plugin Series
ARTIFACT_HEADERS = lsp-plug.in
ARTIFACT_EXPORT_HEADERS = 0
-ARTIFACT_VERSION = 1.0.23
+ARTIFACT_VERSION = 1.0.24
diff --git a/res/doc/configs/spectrum_analyzer_x4.cfg b/res/doc/configs/spectrum_analyzer_x4.cfg
index 593a266..bc29117 100644
--- a/res/doc/configs/spectrum_analyzer_x4.cfg
+++ b/res/doc/configs/spectrum_analyzer_x4.cfg
@@ -3,10 +3,11 @@
# Package: test (Test Case)
# Package version: 0.0.0-devel
# Plugin name: Spektrumanalysator x4 (Spectrum Analyzer x4)
-# Plugin version: 1.0.22
+# Plugin version: 1.0.24
# UID: spectrum_analyzer_x4
# LV2 URI: http://lsp-plug.in/plugins/lv2/spectrum_analyzer_x4
-# VST identifier: xzgo
+# VST 2.x identifier: xzgo
+# VST 3.x identifier: 647370207361342020202020787A676F
# LADSPA identifier: 5002070
# LADSPA label: http://lsp-plug.in/plugins/ladspa/spectrum_analyzer_x4
#
@@ -124,13 +125,14 @@ mtrack = true
# Reset maximum values [boolean]: true/false
mreset = false
-# FFT Tolerance: 0..4
+# FFT Tolerance: 0..5
# 0: 1024
# 1: 2048
# 2: 4096
# 3: 8192
# 4: 16384
-tol = 2
+# 5: 32768
+tol = 5
# FFT Window: 0..20
# 0: Hann
diff --git a/res/doc/screenshots/spectrum_analyzer_x1.png b/res/doc/screenshots/spectrum_analyzer_x1.png
index 60e73b5..ed5e0fe 100644
Binary files a/res/doc/screenshots/spectrum_analyzer_x1.png and b/res/doc/screenshots/spectrum_analyzer_x1.png differ
diff --git a/res/doc/screenshots/spectrum_analyzer_x12.png b/res/doc/screenshots/spectrum_analyzer_x12.png
index eb2892b..0c16004 100644
Binary files a/res/doc/screenshots/spectrum_analyzer_x12.png and b/res/doc/screenshots/spectrum_analyzer_x12.png differ
diff --git a/res/doc/screenshots/spectrum_analyzer_x16.png b/res/doc/screenshots/spectrum_analyzer_x16.png
index 59c8f69..30176cc 100644
Binary files a/res/doc/screenshots/spectrum_analyzer_x16.png and b/res/doc/screenshots/spectrum_analyzer_x16.png differ
diff --git a/res/doc/screenshots/spectrum_analyzer_x2.png b/res/doc/screenshots/spectrum_analyzer_x2.png
index dae64d1..5c4cb3b 100644
Binary files a/res/doc/screenshots/spectrum_analyzer_x2.png and b/res/doc/screenshots/spectrum_analyzer_x2.png differ
diff --git a/res/doc/screenshots/spectrum_analyzer_x4.png b/res/doc/screenshots/spectrum_analyzer_x4.png
index b5aacca..20413a4 100644
Binary files a/res/doc/screenshots/spectrum_analyzer_x4.png and b/res/doc/screenshots/spectrum_analyzer_x4.png differ
diff --git a/res/doc/screenshots/spectrum_analyzer_x8.png b/res/doc/screenshots/spectrum_analyzer_x8.png
index ead2031..67ff6f0 100644
Binary files a/res/doc/screenshots/spectrum_analyzer_x8.png and b/res/doc/screenshots/spectrum_analyzer_x8.png differ
diff --git a/res/main/ui/analyzer/spectrum/x12.xml b/res/main/ui/analyzer/spectrum/x12.xml
index ba86d85..05136ff 100644
--- a/res/main/ui/analyzer/spectrum/x12.xml
+++ b/res/main/ui/analyzer/spectrum/x12.xml
@@ -379,11 +379,11 @@
-
+
-
-
- |
+
+
+
@@ -392,7 +392,7 @@
-
+
|
@@ -400,6 +400,28 @@
|
+
+
+
+
+
+
+ |
|
@@ -483,8 +505,13 @@
-
-
+
+
+
+
+
+
+
diff --git a/res/main/ui/analyzer/spectrum/x16.xml b/res/main/ui/analyzer/spectrum/x16.xml
index 5606ff5..bdf258e 100644
--- a/res/main/ui/analyzer/spectrum/x16.xml
+++ b/res/main/ui/analyzer/spectrum/x16.xml
@@ -378,11 +378,11 @@
-
+
-
-
- |
+
+
+
@@ -391,7 +391,7 @@
-
+
|
@@ -399,6 +399,28 @@
|
+
+
+
+
+
+
+ |
|
@@ -482,8 +504,13 @@
-
-
+
+
+
+
+
+
+
diff --git a/res/main/ui/analyzer/spectrum/x2.xml b/res/main/ui/analyzer/spectrum/x2.xml
index 9e3d748..bf269ce 100644
--- a/res/main/ui/analyzer/spectrum/x2.xml
+++ b/res/main/ui/analyzer/spectrum/x2.xml
@@ -357,6 +357,30 @@
+
+
+
+
+
+
+
+
+
@@ -440,6 +464,29 @@
+
+
+
+
+
+
+
+
diff --git a/res/main/ui/analyzer/spectrum/x4.xml b/res/main/ui/analyzer/spectrum/x4.xml
index aea2a82..a0f6986 100644
--- a/res/main/ui/analyzer/spectrum/x4.xml
+++ b/res/main/ui/analyzer/spectrum/x4.xml
@@ -312,11 +312,11 @@
-
+
-
-
- |
+
+
+
@@ -332,7 +332,7 @@
|
-
+
|
@@ -340,6 +340,28 @@
|
+
+
+
+
+
+
+ |
|
@@ -373,80 +395,90 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
- |
-
-
-
-
-
- |
-
-
- |
-
-
-
- |
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
- |
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
|
@@ -456,9 +488,16 @@
+
+
+
-
-
|
-
+
|
@@ -336,6 +336,28 @@
|
+
+
+
+
+
+
+ |
|
@@ -369,80 +391,90 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
- |
-
-
-
-
-
- |
-
-
- |
-
-
-
- |
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
- |
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
@@ -499,8 +531,13 @@
-
-
+
+
+
+
+
+
+
diff --git a/src/main/meta/spectrum_analyzer.cpp b/src/main/meta/spectrum_analyzer.cpp
index e4c4cc5..f382465 100644
--- a/src/main/meta/spectrum_analyzer.cpp
+++ b/src/main/meta/spectrum_analyzer.cpp
@@ -25,7 +25,7 @@
#define LSP_PLUGINS_SPECTRUM_ANALYZER_VERSION_MAJOR 1
#define LSP_PLUGINS_SPECTRUM_ANALYZER_VERSION_MINOR 0
-#define LSP_PLUGINS_SPECTRUM_ANALYZER_VERSION_MICRO 23
+#define LSP_PLUGINS_SPECTRUM_ANALYZER_VERSION_MICRO 24
#define LSP_PLUGINS_SPECTRUM_ANALYZER_VERSION \
LSP_MODULE_VERSION( \
@@ -52,6 +52,7 @@ namespace lsp
{ "4096", NULL },
{ "8192", NULL },
{ "16384", NULL },
+ { "32768", NULL },
{ NULL, NULL }
};
@@ -146,6 +147,9 @@ namespace lsp
static const port_item_t *spectrum_analyzer_x16_modes = spectrum_analyzer_x4_modes;
+ #define SA_CORRMETER(id, label) \
+ METER(id, label, U_PERCENT, spectrum_analyzer::CORRELATION)
+
#define SA_INPUT(x, total, active) \
AUDIO_INPUT_N(x), \
AUDIO_OUTPUT_N(x), \
@@ -181,7 +185,8 @@ namespace lsp
MESH("spd", "Spectrum Data", c + 2, spectrum_analyzer::MESH_POINTS + 4)
#define SA_SGROUP(id) \
- SWITCH("ms_" #id, "Mid/Side switch for channel pair " #id, 0)
+ 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)
@@ -216,6 +221,7 @@ namespace lsp
SA_SGROUP(0),
SA_SGROUP(1),
SA_COMMON(4, SA_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),
FBUFFER("fb0", "Spectralizer buffer 0", spectrum_analyzer::FB_ROWS, spectrum_analyzer::MESH_POINTS),
@@ -239,6 +245,7 @@ namespace lsp
SA_SGROUP(2),
SA_SGROUP(3),
SA_COMMON(8, SA_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),
FBUFFER("fb0", "Spectralizer buffer 0", spectrum_analyzer::FB_ROWS, spectrum_analyzer::MESH_POINTS),
@@ -268,6 +275,7 @@ namespace lsp
SA_SGROUP(4),
SA_SGROUP(5),
SA_COMMON(12, SA_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),
FBUFFER("fb0", "Spectralizer buffer 0", spectrum_analyzer::FB_ROWS, spectrum_analyzer::MESH_POINTS),
@@ -303,6 +311,7 @@ namespace lsp
SA_SGROUP(6),
SA_SGROUP(7),
SA_COMMON(16, SA_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),
FBUFFER("fb0", "Spectralizer buffer 0", spectrum_analyzer::FB_ROWS, spectrum_analyzer::MESH_POINTS),
diff --git a/src/main/plug/spectrum_analyzer.cpp b/src/main/plug/spectrum_analyzer.cpp
index 16d88c9..392d1b4 100644
--- a/src/main/plug/spectrum_analyzer.cpp
+++ b/src/main/plug/spectrum_analyzer.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2023 Linux Studio Plugins Project
- * (C) 2023 Vladimir Sadovnikov
+ * Copyright (C) 2024 Linux Studio Plugins Project
+ * (C) 2024 Vladimir Sadovnikov
*
* This file is part of lsp-plugins-spectrum-analyzer
* Created on: 22 июн. 2021 г.
@@ -61,7 +61,9 @@ namespace lsp
spectrum_analyzer::spectrum_analyzer(const meta::plugin_t *metadata): plug::Module(metadata)
{
nChannels = 0;
+ nCorrelometers = 0;
vChannels = NULL;
+ vCorrelometers = NULL;
vAnalyze = NULL;
pData = NULL;
vFrequences = NULL;
@@ -128,19 +130,29 @@ namespace lsp
lsp_trace("this=%p, channels = %d", this, int(channels));
// Calculate header size
+ size_t n_correlometers = (channels >= 4) ? (channels / 2) + 1 : (channels >= 2) ? 1 : 0;
size_t hdr_size = align_size(sizeof(sa_channel_t) * channels, 64);
size_t freq_buf_size = align_size(sizeof(float) * meta::spectrum_analyzer::MESH_POINTS, 64);
size_t mfreq_buf_size = align_size(sizeof(float) * meta::spectrum_analyzer::MESH_POINTS, 64);
size_t ind_buf_size = align_size(sizeof(uint32_t) * meta::spectrum_analyzer::MESH_POINTS, 64);
size_t analyze_size = align_size(sizeof(float *) * channels, 16);
size_t buffers = BUFFER_SIZE * sizeof(float) * channels;
- size_t alloc = hdr_size + freq_buf_size + freq_buf_size + mfreq_buf_size + ind_buf_size + analyze_size + buffers;
+ size_t szof_corrs = align_size(sizeof(sa_correlometer_t) * n_correlometers, 64);
+ size_t alloc = hdr_size +
+ freq_buf_size +
+ freq_buf_size +
+ mfreq_buf_size +
+ ind_buf_size +
+ analyze_size +
+ buffers +
+ szof_corrs;
lsp_trace("header_size = %d", int(hdr_size));
lsp_trace("freq_buf_size = %d", int(freq_buf_size));
lsp_trace("mfreq_buf_size = %d", int(mfreq_buf_size));
lsp_trace("ind_buf_size = %d", int(ind_buf_size));
lsp_trace("buffers = %d", int(buffers));
+ lsp_trace("corrs = %d", int(szof_corrs));
lsp_trace("alloc = %d", int(alloc));
// Allocate data
@@ -151,6 +163,7 @@ namespace lsp
// Initialize core
nChannels = channels;
+ nCorrelometers = n_correlometers;
nChannel = 0;
fSelector = meta::spectrum_analyzer::SELECTOR_DFL;
fMinFreq = meta::spectrum_analyzer::FREQ_MIN;
@@ -161,6 +174,7 @@ namespace lsp
// Initialize pointers and cleanup buffers
vChannels = advance_ptr_bytes(ptr, hdr_size);
+ vCorrelometers = (n_correlometers > 0) ? advance_ptr_bytes(ptr, szof_corrs) : NULL;
vFrequences = advance_ptr_bytes(ptr, freq_buf_size);
vMaxValues = advance_ptr_bytes(ptr, freq_buf_size);
vMFrequences = advance_ptr_bytes(ptr, mfreq_buf_size);
@@ -202,6 +216,15 @@ namespace lsp
dsp::fill_zero(c->vBuffer, BUFFER_SIZE);
}
+ // Initialize correlometers
+ for (size_t i=0; isCorr.construct();
+ cm->fCorrelation = 0.0f;
+ cm->pCorrelometer = NULL;
+ }
+
lsp_assert(ptr <= &guard[alloc]);
return true;
@@ -252,13 +275,13 @@ namespace lsp
break;
sa_channel_t *c = &vChannels[i];
- c->pIn = trace_port(ports[port_id++]);
- c->pOut = trace_port(ports[port_id++]);
- c->pOn = trace_port(ports[port_id++]);
- c->pSolo = trace_port(ports[port_id++]);
- c->pFreeze = trace_port(ports[port_id++]);
- c->pHue = trace_port(ports[port_id++]);
- c->pShift = trace_port(ports[port_id++]);
+ BIND_PORT(c->pIn);
+ BIND_PORT(c->pOut);
+ BIND_PORT(c->pOn);
+ BIND_PORT(c->pSolo);
+ BIND_PORT(c->pFreeze);
+ BIND_PORT(c->pHue);
+ BIND_PORT(c->pShift);
// Sync metadata
const meta::port_t *meta = c->pSolo->metadata();
@@ -276,52 +299,61 @@ namespace lsp
{
for (size_t i=0; i> 1];
- l->pMSSwitch = trace_port(ports[port_id++]);
+ BIND_PORT(l->pMSSwitch);
r->pMSSwitch = l->pMSSwitch;
+
+ BIND_PORT(cm->pCorrelometer);
}
}
// Initialize basic ports
- pBypass = trace_port(ports[port_id++]);
- pMode = trace_port(ports[port_id++]);
- trace_port(ports[port_id++]); // Skip mesh thickness
- trace_port(ports[port_id++]); // Skip spectralizer mode
- pLogScale = trace_port(ports[port_id++]);
- pFreeze = trace_port(ports[port_id++]);
- trace_port(ports[port_id++]); // Skip horizontal line switch button
- pMaxTrack = trace_port(ports[port_id++]);
- pMaxReset = trace_port(ports[port_id++]);
- pTolerance = trace_port(ports[port_id++]);
- pWindow = trace_port(ports[port_id++]);
- pEnvelope = trace_port(ports[port_id++]);
- pPreamp = trace_port(ports[port_id++]);
- pZoom = trace_port(ports[port_id++]);
- pReactivity = trace_port(ports[port_id++]);
+ BIND_PORT(pBypass);
+ BIND_PORT(pMode);
+ SKIP_PORT("Mesh thickness");
+ SKIP_PORT("Spectralizer mode");
+ BIND_PORT(pLogScale);
+ BIND_PORT(pFreeze);
+ SKIP_PORT("Horizontal line switch button");
+ BIND_PORT(pMaxTrack);
+ BIND_PORT(pMaxReset);
+ BIND_PORT(pTolerance);
+ BIND_PORT(pWindow);
+ BIND_PORT(pEnvelope);
+ BIND_PORT(pPreamp);
+ BIND_PORT(pZoom);
+ BIND_PORT(pReactivity);
if (nChannels > 1)
- pChannel = trace_port(ports[port_id++]);
- pSelector = trace_port(ports[port_id++]);
- trace_port(ports[port_id++]); // Skip horizontal line value
- pFrequency = trace_port(ports[port_id++]);
- pLevel = trace_port(ports[port_id++]);
- pFftData = trace_port(ports[port_id++]);
+ BIND_PORT(pChannel);
+ BIND_PORT(pSelector);
+ SKIP_PORT("Horizontal line value");
+ BIND_PORT(pFrequency);
+ BIND_PORT(pLevel);
+ BIND_PORT(pFftData);
+
+ // Bind global correlometer ports
+ if (nChannels >= 4)
+ {
+ BIND_PORT(vCorrelometers[nCorrelometers-1].pCorrelometer);
+ }
// Bind spectralizer ports
if (nChannels >= 2)
{
- pMSSwitch = trace_port(ports[port_id++]);
- vSpc[0].pPortId = trace_port(ports[port_id++]);
+ BIND_PORT(pMSSwitch);
+ BIND_PORT(vSpc[0].pPortId);
}
- vSpc[0].pFBuffer = trace_port(ports[port_id++]);
+ BIND_PORT(vSpc[0].pFBuffer);
vSpc[0].nChannelId = -1;
if (nChannels >= 2)
{
if (nChannels > 2)
- vSpc[1].pPortId = trace_port(ports[port_id++]);
- vSpc[1].pFBuffer = trace_port(ports[port_id++]);
+ BIND_PORT(vSpc[1].pPortId);
+ BIND_PORT(vSpc[1].pFBuffer);
vSpc[1].nChannelId = -1;
}
@@ -340,6 +372,16 @@ namespace lsp
void spectrum_analyzer::do_destroy()
{
+ if (vCorrelometers != NULL)
+ {
+ for (size_t i=0; isCorr.destroy();
+ }
+ vCorrelometers = NULL;
+ }
+
sAnalyzer.destroy();
if (pData != NULL)
@@ -625,6 +667,16 @@ namespace lsp
void spectrum_analyzer::update_sample_rate(long sr)
{
lsp_trace("this=%p, sample_rate = %d", this, int(sr));
+ const size_t corr_period = dspu::millis_to_samples(sr, meta::spectrum_analyzer::CORR_PERIOD);
+
+ for (size_t i=0; isCorr.init(corr_period);
+ cm->sCorr.set_period(corr_period);
+ cm->sCorr.clear();
+ }
+
sAnalyzer.set_sample_rate(sr);
if (sAnalyzer.needs_reconfiguration())
sAnalyzer.reconfigure();
@@ -699,6 +751,47 @@ namespace lsp
}
}
+ void spectrum_analyzer::measure_correlation(size_t count)
+ {
+ // Do the correlation measurements
+ if (nCorrelometers > 0)
+ {
+ for (size_t i=0; i> 1];
+
+ float min = 0.0f;
+ float max = 0.0f;
+ cm->sCorr.process(l->vBuffer, l->vIn, r->vIn, count);
+ dsp::minmax(l->vBuffer, count, &min, &max);
+ max = (fabs(min) > fabs(max)) ? min : max;
+
+ if (fabs(cm->fCorrelation) < fabs(max))
+ cm->fCorrelation = max;
+ }
+
+ if (nChannels >= 4)
+ {
+ sa_correlometer_t *cm = &vCorrelometers[nCorrelometers-1];
+ sa_channel_t *a = (vSpc[0].nPortId >= 0) ? &vChannels[vSpc[0].nPortId] : NULL;
+ sa_channel_t *b = (vSpc[1].nPortId >= 0) ? &vChannels[vSpc[1].nPortId] : NULL;
+
+ float min = 0.0f;
+ float max = 0.0f;
+ if ((a != NULL) && (b != NULL))
+ {
+ cm->sCorr.process(a->vBuffer, a->vIn, b->vIn, count);
+ dsp::minmax(a->vBuffer, count, &min, &max);
+ }
+
+ if (fabs(cm->fCorrelation) < fabs(max))
+ cm->fCorrelation = max;
+ }
+ }
+ }
+
void spectrum_analyzer::prepare_buffers(size_t count)
{
if (nChannels > 1)
@@ -773,6 +866,10 @@ namespace lsp
c->vOut = c->pOut->buffer();
}
+ // Cleanup correlometers
+ for (size_t i=0; ibuffer();
bool mesh_request = (mesh != NULL) && (mesh->isEmpty());
@@ -800,6 +897,9 @@ namespace lsp
for (size_t i=0; idata(nChannels + 2, meta::spectrum_analyzer::MESH_POINTS + 4);
+
+ // Report correlometers
+ for (size_t i=0; ipCorrelometer->set_value(cm->fCorrelation * 100.0f);
+ }
}
bool spectrum_analyzer::inline_display(plug::ICanvas *cv, size_t width, size_t height)
@@ -1027,6 +1134,7 @@ namespace lsp
v->write_object("sCounter", &sCounter);
v->write("nChannels", nChannels);
+ v->write("nCorrelometers", nCorrelometers);
v->begin_array("vChannels", vChannels, nChannels);
{
for (size_t i=0; iend_array();
+ v->begin_array("vCorrelometers", vCorrelometers, nCorrelometers);
+ {
+ for (size_t i=0; ibegin_object(cm, sizeof(sa_correlometer_t));
+ {
+ v->write_object("sCorr", &cm->sCorr);
+ v->write("fCorrelation", cm->fCorrelation);
+ v->write("pCorrelometer", cm->pCorrelometer);
+ }
+ v->end_object();
+ }
+ }
+ v->end_array();
+
v->write("vAnalyze", vAnalyze);
v->write("vFrequences", vFrequences);
v->write("vMFrequences", vMFrequences);
|