Subject: [bug#48632] [PATCH v2] gnu: Add eq10q.

From: Thorsten Wilms <[email-masked]>
Date: Tue, 26 Oct 2021 10:01:28 +0200

* gnu/packages/audio.scm (eq10q): New variable.
* gnu/packages/patches/eq10q-lv2-descriptor.patch.
* gnu/packages/patches/eq10q-exp10.patch.
* /gnu/local.mk: Add patches.
---
 gnu/local.mk                                  |  3 +
 gnu/packages/audio.scm                        | 40 +++++++++-
 gnu/packages/patches/eq10q-exp10.patch        | 73 +++++++++++++++++++
 .../patches/eq10q-lv2-descriptor.patch        | 50 +++++++++++++
 4 files changed, 165 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/eq10q-exp10.patch
 create mode 100644 gnu/packages/patches/eq10q-lv2-descriptor.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 28e8c1966a..0a5b93c937 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -45,6 +45,7 @@
 # Copyright © 2021 Sharlatan Hellseher <[email-masked]>
 # Copyright © 2021 Dmitry Polyakov <[email-masked]>
 # Copyright © 2021 Andrew Tropin <[email-masked]>
+# Copyright © 2021 Thorsten Wilms <[email-masked]>
 #
 # This file is part of GNU Guix.
 #
@@ -1036,6 +1037,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-wordnut-require-adaptive-wrap.patch	\
   %D%/packages/patches/enjarify-setup-py.patch			\
   %D%/packages/patches/enlightenment-fix-setuid-path.patch	\
+  %D%/packages/patches/eq10q-exp10.patch			\
+  %D%/packages/patches/eq10q-lv2-descriptor.patch		\
   %D%/packages/patches/erlang-man-path.patch			\
   %D%/packages/patches/esmtp-add-lesmtp.patch		\
   %D%/packages/patches/eudev-rules-directory.patch		\
diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index faf106fc68..157b75600e 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -15,7 +15,7 @@
 ;;; Copyright © 2018 Clément Lassieur <[email-masked]>
 ;;; Copyright © 2018 Brett Gilio <[email-masked]>
 ;;; Copyright © 2018, 2019 Marius Bakke <[email-masked]>
-;;; Copyright © 2018 Thorsten Wilms <[email-masked]>
+;;; Copyright © 2018, 2021 Thorsten Wilms <[email-masked]>
 ;;; Copyright © 2018 Eric Bavier <[email-masked]>
 ;;; Copyright © 2018 Brendan Tildesley <[email-masked]>
 ;;; Copyright © 2019, 2021 Pierre Langlois <[email-masked]>
@@ -5566,3 +5566,41 @@ (define-public mda-lv2
      "MDA-LV2 is an LV2 port of the MDA plugins.  It includes effects and a few
 instrument plugins.")
     (license license:gpl3+)))
+
+(define-public eq10q
+  (package
+    (name "eq10q")
+    (version "2.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://sourceforge/eq10q/eq10q-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "16mhcav8gwkp29k9ki4dlkajlcgh1i2wvldabxb046d37dq4qzrk"))
+	      (patches
+	       (search-patches "eq10q-lv2-descriptor.patch"
+			       "eq10q-exp10.patch"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:tests? #f ; No target
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'override-target-directory
+           (lambda* (#:key outputs #:allow-other-keys)
+             (substitute* (find-files "CMakeLists.txt")
+               (("/usr/local")(assoc-ref outputs "out")))
+             #t)))))
+    (inputs
+     `(("gtkmm" ,gtkmm-2)
+       ("lv2" ,lv2)
+       ("fftw" ,fftw)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (home-page "http://eq10q.sourceforge.net")
+    (synopsis "Audio plug-in pack for LV2")
+    (description
+     "EQ10Q is an audio plug-in pack for LV2. It contains equalizers with 1, 4, 
+6 or 10 bands, all in mono and stereo variants. Plus a noise-gate, compressor, 
+bass-booster and stereo-mode converters.")
+    (license (list license:gpl3+ license:gpl3+))))
diff --git a/gnu/packages/patches/eq10q-exp10.patch b/gnu/packages/patches/eq10q-exp10.patch
new file mode 100644
index 0000000000..678009a700
--- /dev/null
+++ b/gnu/packages/patches/eq10q-exp10.patch
@@ -0,0 +1,73 @@
+Fix "‘pow10’ was not declared in this scope" error.
+Taken from https://build.opensuse.org/package/view_file/home:geekositalia:daw/lv2-EQ10Q-plugins/lv2-EQ10Q-plugins-exp10.patch?expand=1
+
+diff -rupN eq10q-2.2.org/gui/widgets/bandctl.cpp eq10q-2.2/gui/widgets/bandctl.cpp
+--- eq10q-2.2.org/gui/widgets/bandctl.cpp	2016-12-11 07:07:50.000000000 -0500
++++ eq10q-2.2/gui/widgets/bandctl.cpp	2018-03-10 16:29:14.026996405 -0500
+@@ -949,7 +949,7 @@ bool BandCtl::parseBtnString(BandCtl::Bu
+   if(str_k.length() > 0)
+   {
+     val_k = atof(str_k.c_str()) * 1e3;
+-    val *= pow10(3.0 - str.length());
++    val *= exp10(3.0 - str.length());
+     if(str.length() > 3)
+     {
+       //throw an error, imposible to match str > 3 with k
+@@ -960,7 +960,7 @@ bool BandCtl::parseBtnString(BandCtl::Bu
+   }
+   if(str_d.length() > 0)
+   {
+-    val_d = atof(str_d.c_str())/ pow10((double)str_d.length());
++    val_d = atof(str_d.c_str())/ exp10((double)str_d.length());
+   }
+    
+   btn->value = val + val_k + val_d;
+diff -rupN eq10q-2.2.org/gui/widgets/bodeplot.cpp eq10q-2.2/gui/widgets/bodeplot.cpp
+--- eq10q-2.2.org/gui/widgets/bodeplot.cpp	2016-12-11 07:07:50.000000000 -0500
++++ eq10q-2.2/gui/widgets/bodeplot.cpp	2018-03-10 16:27:06.222494049 -0500
+@@ -194,14 +194,14 @@ void PlotEQCurve::resetCenterSpan()
+ {
+   //Compute center and span for the full range spectrum
+   double sp = log10(MAX_FREQ/MIN_FREQ);
+-  double cn = MIN_FREQ * sqrt(pow10(sp));
++  double cn = MIN_FREQ * sqrt(exp10(sp));
+   setCenterSpan(cn, sp);
+ }
+ 
+ void PlotEQCurve::setCenterSpan(double center, double span)
+ { 
+-  m_minFreq = center / sqrt(pow10(span));
+-  m_maxFreq = center * sqrt(pow10(span));
++  m_minFreq = center / sqrt(exp10(span));
++  m_maxFreq = center * sqrt(exp10(span));
+     
+   //Initalize the grid
+   const double f_grid[GRID_VERTICAL_LINES] = {20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0,
+@@ -246,8 +246,8 @@ void PlotEQCurve::setCenter(double cente
+ {
+   //Limit center to the possible range according the current span
+   double sp = log10(m_maxFreq/m_minFreq);
+-  double cmin = MIN_FREQ * sqrt(pow10(sp));
+-  double cmax = MAX_FREQ / sqrt(pow10(sp));
++  double cmin = MIN_FREQ * sqrt(exp10(sp));
++  double cmax = MAX_FREQ / sqrt(exp10(sp));
+   
+   double cn = center;
+   cn = cn > cmax ? cmax : cn;
+@@ -259,7 +259,7 @@ void PlotEQCurve::setSpan(double span)
+ {
+   //Limit center to the possible range according the current span
+   double sp_act = log10(m_maxFreq/m_minFreq);
+-  double cn = m_minFreq * sqrt(pow10(sp_act));
++  double cn = m_minFreq * sqrt(exp10(sp_act));
+   double smax1 = 2.0*log10(cn/MIN_FREQ);
+   double smax2= 2.0*log10(MAX_FREQ/cn);
+   double smax = smax1 < smax2 ? smax1 : smax2;
+@@ -306,7 +306,7 @@ void PlotEQCurve::recomputeCenterFreq(do
+   double fmax = MIN_FREQ*pow((MAX_FREQ/MIN_FREQ),((local_x2 + 3.5)/((double)m_zoom_surface_ptr->get_width())));
+   
+   double sp_act = log10(fmax/fmin);
+-  double cn = fmin * sqrt(pow10(sp_act));
++  double cn = fmin * sqrt(exp10(sp_act));
+   setCenter(cn);
+ }
diff --git a/gnu/packages/patches/eq10q-lv2-descriptor.patch b/gnu/packages/patches/eq10q-lv2-descriptor.patch
new file mode 100644
index 0000000000..aabd078356
--- /dev/null
+++ b/gnu/packages/patches/eq10q-lv2-descriptor.patch
@@ -0,0 +1,50 @@
+Replace _LV2UI_Descriptor with LV2UI_Descriptor
+
+diff -rupN eq10q-2.2_original/gui/bassup_ui.cpp eq10q-2.2_patched/gui/bassup_ui.cpp
+--- eq10q-2.2_original/gui/bassup_ui.cpp	2016-12-11 13:07:52.000000000 +0100
++++ eq10q-2.2_patched/gui/bassup_ui.cpp	2021-05-24 19:24:34.363536592 +0200
+@@ -38,7 +38,7 @@ using namespace std;
+ #define BASSUP_GUI_URI "http://eq10q.sourceforge.net/bassup/gui"
+ 
+ 
+-static LV2UI_Handle instantiateBassUp_gui(const _LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
++static LV2UI_Handle instantiateBassUp_gui(const LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
+ {
+   #ifdef TESTING_EQ10Q
+   cout<<"instantiateEq10q_gui Entring... ";
+diff -rupN eq10q-2.2_original/gui/dyn_ui.cpp eq10q-2.2_patched/gui/dyn_ui.cpp
+--- eq10q-2.2_original/gui/dyn_ui.cpp	2016-12-11 13:07:50.000000000 +0100
++++ eq10q-2.2_patched/gui/dyn_ui.cpp	2021-05-24 19:24:34.363536592 +0200
+@@ -37,7 +37,7 @@ This plugin is inside the Sapista Plugin
+ using namespace std;
+ #endif
+ 
+-static LV2UI_Handle instantiateDyn_gui(const _LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
++static LV2UI_Handle instantiateDyn_gui(const LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
+ {
+   #ifdef TESTING_EQ10Q
+   cout<<"instantiateDyn_gui Entring... ";
+diff -rupN eq10q-2.2_original/gui/eq10q_ui.cpp eq10q-2.2_patched/gui/eq10q_ui.cpp
+--- eq10q-2.2_original/gui/eq10q_ui.cpp	2016-12-11 13:07:50.000000000 +0100
++++ eq10q-2.2_patched/gui/eq10q_ui.cpp	2021-05-24 19:24:34.363536592 +0200
+@@ -38,7 +38,7 @@ using namespace std;
+ #endif
+ 
+ 
+-static LV2UI_Handle instantiateEq10q_gui(const _LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
++static LV2UI_Handle instantiateEq10q_gui(const LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
+ {
+   #ifdef TESTING_EQ10Q
+   cout<<"instantiateEq10q_gui Entring... ";
+diff -rupN eq10q-2.2_original/gui/midside_ui.cpp eq10q-2.2_patched/gui/midside_ui.cpp
+--- eq10q-2.2_original/gui/midside_ui.cpp	2016-12-11 13:07:53.000000000 +0100
++++ eq10q-2.2_patched/gui/midside_ui.cpp	2021-05-24 19:24:34.367536562 +0200
+@@ -37,7 +37,7 @@ This plugin is inside the Sapista Plugin
+ using namespace std;
+ #endif
+ 
+-static LV2UI_Handle instantiateMidSide_gui(const _LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
++static LV2UI_Handle instantiateMidSide_gui(const LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
+ {
+   #ifdef TESTING_EQ10Q
+   cout<<"instantiateEq10q_gui Entring... ";
-- 
2.33.1