amsynth: fix DSSI-plugin's host control
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
This commit is contained in:
@@ -10,7 +10,12 @@ DEPENDS += " \
|
||||
intltool-native \
|
||||
"
|
||||
|
||||
SRC_URI = "https://github.com/${BPN}/${BPN}/releases/download/release-${PV}/${BPN}-${PV}.tar.bz2"
|
||||
SRC_URI = " \
|
||||
https://github.com/${BPN}/${BPN}/releases/download/release-${PV}/${BPN}-${PV}.tar.bz2 \
|
||||
file://0001-Preset-return-reference-to-mName.patch \
|
||||
file://0002-dssi-report-presets-correctly.patch \
|
||||
file://0003-dssi-fix-preset-selection.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "4856f582caed59fca79dfe3ca4597938"
|
||||
SRC_URI[sha256sum] = "08ec3fdc56b5eec89abed67d356458652ac5ebac2971aff4a147b9f8bcaa6169"
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
From 2bb9e40bde1ab9e03bf276bbaa1a8047f6b1265d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
|
||||
Date: Thu, 5 Jan 2017 02:02:49 +0100
|
||||
Subject: [PATCH 1/3] Preset: return reference to mName
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Otherwise we get temporary objects with non deterministic lifetime. Errors
|
||||
caused are e.g mangled names in dssi get_program. Not easy to debug believe
|
||||
me!
|
||||
|
||||
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
|
||||
---
|
||||
src/Preset.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/Preset.h b/src/Preset.h
|
||||
index ad98b07..7b7f631 100644
|
||||
--- a/src/Preset.h
|
||||
+++ b/src/Preset.h
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
bool isEqual (const Preset &);
|
||||
|
||||
- const std::string getName () const { return mName; }
|
||||
+ const std::string& getName () const { return mName; }
|
||||
void setName (const std::string name) { mName = name; }
|
||||
|
||||
Parameter& getParameter (const std::string name);
|
||||
--
|
||||
2.5.5
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
From 19094e40a72e88fdef5d68f8354c9bea51145b75 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
|
||||
Date: Thu, 5 Jan 2017 02:24:51 +0100
|
||||
Subject: [PATCH 2/3] dssi: report presets correctly
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
|
||||
---
|
||||
src/dssi.cpp | 29 ++++++++++++++++++++++-------
|
||||
1 file changed, 22 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/dssi.cpp b/src/dssi.cpp
|
||||
index 4647ba0..0d5528c 100644
|
||||
--- a/src/dssi.cpp
|
||||
+++ b/src/dssi.cpp
|
||||
@@ -21,9 +21,11 @@
|
||||
|
||||
#include "midi.h"
|
||||
#include "Preset.h"
|
||||
+#include "PresetController.h"
|
||||
#include "Synthesizer.h"
|
||||
|
||||
#include <assert.h>
|
||||
+#include <climits>
|
||||
#include <dssi.h>
|
||||
#include <ladspa.h>
|
||||
#include <math.h>
|
||||
@@ -42,6 +44,8 @@
|
||||
|
||||
static LADSPA_Descriptor * s_ladspaDescriptor = NULL;
|
||||
static DSSI_Descriptor * s_dssiDescriptor = NULL;
|
||||
+static PresetController * s_presetController = NULL;
|
||||
+static unsigned long s_lastBankGet = ULONG_MAX;
|
||||
|
||||
#define MIDI_BUFFER_SIZE 4096
|
||||
|
||||
@@ -106,19 +110,24 @@ static void cleanup (LADSPA_Handle instance)
|
||||
|
||||
static const DSSI_Program_Descriptor *get_program(LADSPA_Handle Instance, unsigned long Index)
|
||||
{
|
||||
- amsynth_wrapper * a = (amsynth_wrapper *) Instance;
|
||||
-
|
||||
static DSSI_Program_Descriptor descriptor;
|
||||
memset(&descriptor, 0, sizeof(descriptor));
|
||||
|
||||
- if (Index < 128) {
|
||||
- descriptor.Bank = 0;
|
||||
- descriptor.Program = Index;
|
||||
- descriptor.Name = a->synth->getPresetName(Index);
|
||||
+ descriptor.Program = Index % PresetController::kNumPresets;
|
||||
+ descriptor.Bank = Index / PresetController::kNumPresets;
|
||||
+
|
||||
+ const std::vector<BankInfo> banks = PresetController::getPresetBanks();
|
||||
+ if (descriptor.Bank < banks.size())
|
||||
+ {
|
||||
+ if (descriptor.Bank != s_lastBankGet) {
|
||||
+ s_presetController->loadPresets(banks[descriptor.Bank].file_path.c_str());
|
||||
+ s_lastBankGet = descriptor.Bank;
|
||||
+ }
|
||||
+ descriptor.Name = s_presetController->getPreset(descriptor.Program).getName().c_str();
|
||||
TRACE_ARGS("%d %d %s", descriptor.Bank, descriptor.Program, descriptor.Name);
|
||||
return &descriptor;
|
||||
}
|
||||
-
|
||||
+
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -227,6 +236,7 @@ static void run (LADSPA_Handle instance, unsigned long sample_count)
|
||||
|
||||
void __attribute__ ((constructor)) my_init ()
|
||||
{
|
||||
+ s_presetController = new PresetController;
|
||||
const char **port_names;
|
||||
LADSPA_PortDescriptor *port_descriptors;
|
||||
LADSPA_PortRangeHint *port_range_hints;
|
||||
@@ -340,4 +350,9 @@ void __attribute__ ((destructor)) my_fini ()
|
||||
{
|
||||
free (s_dssiDescriptor);
|
||||
}
|
||||
+ if (s_presetController)
|
||||
+ {
|
||||
+ delete s_presetController;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
--
|
||||
2.5.5
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
From 7c4d3532bd5540d403f4d477beb473f0948c9e32 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
|
||||
Date: Thu, 5 Jan 2017 11:45:38 +0100
|
||||
Subject: [PATCH 3/3] dssi: fix preset selection
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
|
||||
---
|
||||
src/dssi.cpp | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/dssi.cpp b/src/dssi.cpp
|
||||
index 0d5528c..f063a64 100644
|
||||
--- a/src/dssi.cpp
|
||||
+++ b/src/dssi.cpp
|
||||
@@ -137,7 +137,10 @@ static void select_program(LADSPA_Handle Instance, unsigned long Bank, unsigned
|
||||
|
||||
TRACE_ARGS("Bank = %d Index = %d", Bank, Index);
|
||||
|
||||
- if (Bank == 0 && Index < 128) {
|
||||
+ const std::vector<BankInfo> banks = PresetController::getPresetBanks();
|
||||
+
|
||||
+ if (Bank < banks.size() && Index < PresetController::kNumPresets) {
|
||||
+ s_presetController->loadPresets(banks[Bank].file_path.c_str());
|
||||
a->synth->setPresetNumber(Index);
|
||||
// now update DSSI host's view of the parameters
|
||||
for (unsigned i = 0; i < kAmsynthParameterCount; i++) {
|
||||
--
|
||||
2.5.5
|
||||
|
||||
Reference in New Issue
Block a user