[SCM] calf/master: + Fluidsynth: new plugin (work in progress, just started)
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:18 UTC 2013
The following commit has been merged in the master branch:
commit 2a97ebed465a2f1757a784a7a133d7dbabb5fb5c
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Wed Feb 4 22:39:21 2009 +0000
+ Fluidsynth: new plugin (work in progress, just started)
diff --git a/configure.ac b/configure.ac
index a7ad7e3..ee3c171 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,7 @@ AC_CHECK_LIB(expat, XML_Parse, true, AC_MSG_ERROR([Expat XML library not found])
AC_CHECK_HEADERS([jack/jack.h], have_jack_header=yes, have_jack_header=no)
PKG_CHECK_MODULES(GLIB_DEPS, glib-2.0 >= 2.0.0, true, AC_MSG_ERROR([glib-2.0 library not found]))
+PKG_CHECK_MODULES(FLUIDSYNTH_DEPS, fluidsynth >= 1.0.7, true, AC_MSG_ERROR([fluidsynth library not found]))
if test "$have_jack_header" = "yes"; then
PKG_CHECK_MODULES(JACK_DEPS, jack >= 0.103.0,
@@ -55,6 +56,8 @@ AC_SUBST(GUI_DEPS_CFLAGS)
AC_SUBST(GUI_DEPS_LIBS)
AC_SUBST(JACK_DEPS_CFLAGS)
AC_SUBST(JACK_DEPS_LIBS)
+AC_SUBST(FLUIDSYNTH_DEPS_CFLAGS)
+AC_SUBST(FLUIDSYNTH_DEPS_LIBS)
PKG_CHECK_MODULES(LV2_DEPS, lv2core >= 1, LV2_ENABLED="yes", LV2_ENABLED="no")
PKG_CHECK_MODULES(LASH_DEPS, lash-1.0 >= 0.5.2, LASH_ENABLED="yes", LASH_ENABLED="no")
diff --git a/src/Makefile.am b/src/Makefile.am
index fa5dc2e..371476b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,7 +18,7 @@ if USE_LV2_GUI
noinst_LTLIBRARIES += calflv2gui.la
endif
-AM_CXXFLAGS = -ffast-math -finline-limit=80
+AM_CXXFLAGS = -ffast-math -finline-limit=80 $(FLUIDSYNTH_DEPS_CFLAGS)
if USE_GUI
AM_CXXFLAGS += $(GUI_DEPS_CFLAGS)
@@ -28,7 +28,7 @@ AM_CXXFLAGS += $(JACK_DEPS_CFLAGS)
noinst_LTLIBRARIES += libcalfgui.la
bin_PROGRAMS += calfjackhost
calfjackhost_SOURCES = jackhost.cpp
-calfjackhost_LDADD = libcalfgui.la libcalfstatic.la $(JACK_DEPS_LIBS) $(GUI_DEPS_LIBS)
+calfjackhost_LDADD = libcalfgui.la libcalfstatic.la $(JACK_DEPS_LIBS) $(GUI_DEPS_LIBS) $(FLUIDSYNTH_DEPS_LIBS)
if USE_LASH
AM_CXXFLAGS += $(LASH_DEPS_CFLAGS)
calfjackhost_LDADD += $(LASH_DEPS_LIBS)
@@ -50,11 +50,12 @@ calfbenchmark_CXXFLAGS = $(AM_CXXFLAGS) -DTEST_OSC
calfbenchmark_LDADD += libcalfgui.la
endif
-calf_la_SOURCES = modules.cpp modules_dsp.cpp modules_small.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp osctlnet.cpp plugin.cpp preset.cpp synth.cpp utils.cpp
+calf_la_SOURCES = modules.cpp modules_dsp.cpp modules_small.cpp fluidsynth.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp osctlnet.cpp plugin.cpp preset.cpp synth.cpp utils.cpp
+calf_la_LIBADD ?= $(FLUIDSYNTH_DEPS_LIBS)
if USE_DEBUG
-calf_la_LDFLAGS = -rpath $(ladspadir) -avoid-version -module -lexpat -disable-static
+calf_la_LDFLAGS = -rpath $(ladspadir) -avoid-version -module -lexpat -disable-static
else
-calf_la_LDFLAGS = -rpath $(ladspadir) -avoid-version -module -lexpat -disable-static -export-symbols-regex "(ladspa_|lv2_|dssi_)descriptor"
+calf_la_LDFLAGS = -rpath $(ladspadir) -avoid-version -module -lexpat -disable-static -export-symbols-regex "(ladspa_|lv2_|dssi_)descriptor" $(FLUIDSYNTH_DEPS_LIBS)
endif
if USE_LV2_GUI
@@ -66,8 +67,8 @@ calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat -export-
endif
endif
-libcalfstatic_la_SOURCES = modules.cpp modules_dsp.cpp modules_small.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp osctlnet.cpp preset.cpp synth.cpp utils.cpp
-libcalfstatic_la_LDFLAGS = -static -lexpat -disable-shared
+libcalfstatic_la_SOURCES = modules.cpp modules_dsp.cpp modules_small.cpp fluidsynth.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp osctlnet.cpp preset.cpp synth.cpp utils.cpp
+libcalfstatic_la_LDFLAGS = -static -lexpat -disable-shared $(FLUIDSYNTH_DEPS_LIBS)
if USE_GUI
libcalfgui_la_SOURCES = gui.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp preset_gui.cpp custom_ctl.cpp osctl.cpp osctlnet.cpp osctlserv.cpp main_win.cpp utils.cpp
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 81bb0e6..94c5919 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -201,6 +201,15 @@ struct organ_metadata: public organ_enums, public plugin_metadata<organ_metadata
const char **get_default_configure_vars();
};
+/// FluidSynth - metadata
+struct fluidsynth_metadata: public plugin_metadata<fluidsynth_metadata>
+{
+ enum { par_master, par_soundfont, param_count };
+ enum { in_count = 0, out_count = 2, support_midi = true, require_midi = true, rt_capable = false };
+ PLUGIN_NAME_ID_LABEL("fluidsynth", "fluidsynth", "Fluidsynth")
+ const char **get_default_configure_vars();
+};
+
};
#endif
diff --git a/src/calf/modulelist.h b/src/calf/modulelist.h
index ef3e3be..1ba573d 100644
--- a/src/calf/modulelist.h
+++ b/src/calf/modulelist.h
@@ -10,6 +10,9 @@
PER_MODULE_ITEM(phaser, false, "phaser")
PER_MODULE_ITEM(multichorus, false, "multichorus")
PER_MODULE_ITEM(compressor, false, "compressor")
+#ifdef ENABLE_EXPERIMENTAL
+ PER_MODULE_ITEM(fluidsynth, true, "fluidsynth")
+#endif
#undef PER_MODULE_ITEM
#endif
#ifdef PER_SMALL_MODULE_ITEM
diff --git a/src/calf/modules_dev.h b/src/calf/modules_dev.h
index 6ea8a1c..6a31dae 100644
--- a/src/calf/modules_dev.h
+++ b/src/calf/modules_dev.h
@@ -24,10 +24,67 @@
#include <calf/metadata.h>
#include <calf/modules.h>
+#if ENABLE_EXPERIMENTAL
+#include <fluidsynth.h>
+#endif
+
namespace calf_plugins {
#if ENABLE_EXPERIMENTAL
+
+/// Tiny wrapper for fluidsynth
+class fluidsynth_audio_module: public audio_module<fluidsynth_metadata>
+{
+public:
+ float *ins[in_count];
+ float *outs[out_count];
+ float *params[param_count];
+ uint32_t srate;
+ fluid_settings_t *settings;
+ fluid_synth_t *synth;
+ std::string soundfont;
+ int sfid;
+
+ /// Constructor to initialize handles to NULL
+ fluidsynth_audio_module();
+ /// Create a fluidsynth object and load the current soundfont
+ fluid_synth_t *create_synth(int &new_sfid);
+
+ void post_instantiate();
+ void set_sample_rate(uint32_t sr) {}
+ /// Handle MIDI Note On message (by sending it to fluidsynth)
+ void note_on(int note, int vel);
+ /// Handle MIDI Note Off message (by sending it to fluidsynth)
+ void note_off(int note, int vel);
+ /// Handle pitch bend message.
+ /*
+ inline void pitch_bend(int value)
+ {
+ pitchbend = pow(2.0, value / 8192.0);
+ }
+ */
+ /// Handle control change messages.
+ // void control_change(int controller, int value);
+ /// Update variables from control ports.
+ void params_changed() {
+ }
+ void activate();
+ void deactivate();
+ /// No CV inputs for now
+ bool is_cv(int param_no) { return false; }
+ /// Practically all the stuff here is noisy... for now
+ bool is_noisy(int param_no) { return true; }
+ /// Main processing function
+ uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask);
+ /// DSSI-style configure function for handling string port data
+ char *configure(const char *key, const char *value);
+ void send_configures(send_configure_iface *sci);
+ ~fluidsynth_audio_module();
+};
+
+
+
#endif
};
diff --git a/src/fluidsynth.cpp b/src/fluidsynth.cpp
new file mode 100644
index 0000000..f283d8e
--- /dev/null
+++ b/src/fluidsynth.cpp
@@ -0,0 +1,136 @@
+/* Calf DSP Library
+ * Example audio modules - monosynth
+ *
+ * Copyright (C) 2001-2007 Krzysztof Foltman
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <assert.h>
+#include <memory.h>
+#include <config.h>
+#include <complex>
+#if USE_JACK
+#include <jack/jack.h>
+#endif
+#include <calf/giface.h>
+#include <calf/modules_synths.h>
+#include <calf/modules_dev.h>
+
+#if ENABLE_EXPERIMENTAL
+
+using namespace dsp;
+using namespace calf_plugins;
+using namespace std;
+
+fluidsynth_audio_module::fluidsynth_audio_module()
+{
+ settings = NULL;
+ synth = NULL;
+}
+
+void fluidsynth_audio_module::post_instantiate()
+{
+ settings = new_fluid_settings();
+ synth = create_synth(sfid);
+}
+
+void fluidsynth_audio_module::activate()
+{
+}
+
+void fluidsynth_audio_module::deactivate()
+{
+}
+
+fluid_synth_t *fluidsynth_audio_module::create_synth(int &new_sfid)
+{
+ fluid_settings_t *new_settings = new_fluid_settings();
+ fluid_synth_t *s = new_fluid_synth(new_settings);
+ if (!soundfont.empty())
+ {
+ int sid = fluid_synth_sfload(s, soundfont.c_str(), 1);
+ if (sid == -1)
+ {
+ delete_fluid_synth(s);
+ return NULL;
+ }
+ assert(sid >= 0);
+ printf("sid=%d\n", sid);
+ fluid_synth_sfont_select(s, 0, sid);
+ fluid_synth_bank_select(s, 0, 0);
+ fluid_synth_program_change(s, 0, 0);
+ new_sfid = sid;
+ }
+ else
+ new_sfid = -1;
+ return s;
+}
+
+void fluidsynth_audio_module::note_on(int note, int vel)
+{
+ fluid_synth_noteon(synth, 0, note, vel);
+}
+
+void fluidsynth_audio_module::note_off(int note, int vel)
+{
+ fluid_synth_noteoff(synth, 0, note);
+}
+
+uint32_t fluidsynth_audio_module::process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask)
+{
+ fluid_synth_write_float(synth, nsamples, outs[0], offset, 1, outs[1], offset, 1);
+ return 3;
+}
+
+char *fluidsynth_audio_module::configure(const char *key, const char *value)
+{
+ if (!strcmp(key, "soundfont"))
+ {
+ printf("Loading %s\n", value);
+ soundfont = value;
+ int newsfid = -1;
+ fluid_synth_t *new_synth = create_synth(newsfid);
+
+ if (new_synth)
+ {
+ synth = new_synth;
+ sfid = newsfid;
+ }
+ else
+ return strdup("Cannot load a soundfont");
+ // XXXKF memory leak
+ }
+ return NULL;
+}
+
+void fluidsynth_audio_module::send_configures(send_configure_iface *sci)
+{
+ sci->send_configure("soundfont", soundfont.c_str());
+}
+
+fluidsynth_audio_module::~fluidsynth_audio_module()
+{
+ if (synth) {
+ delete_fluid_synth(synth);
+ synth = NULL;
+ }
+ if (settings) {
+ // delete_fluid_settings(settings);
+ settings = NULL;
+ }
+}
+
+#endif
diff --git a/src/modules.cpp b/src/modules.cpp
index 1bd0a99..9f8a5cc 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -484,6 +484,21 @@ CALF_PORT_PROPS(organ) = {
////////////////////////////////////////////////////////////////////////////
+const char *fluidsynth_init_soundfont = "/home/kfoltman/sf2/HS R8 Drums.sf2";
+
+CALF_PORT_NAMES(fluidsynth) = {
+ "Out L", "Out R",
+};
+
+CALF_PLUGIN_INFO(fluidsynth) = { 0x8700, "Fluidsynth", "Calf Fluidsynth", "FluidSynth Team / Krzysztof Foltman", calf_plugins::calf_copyright_info, "SynthesizerPlugin" };
+
+CALF_PORT_PROPS(fluidsynth) = {
+ { 0.5, 0, 1, 100, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_PROP_OUTPUT_GAIN, NULL, "master", "Volume" },
+ { 0, 0, 0, 0, PF_STRING | PF_PROP_MSGCONTEXT, &fluidsynth_init_soundfont, "soundfont", "Soundfont" },
+};
+
+////////////////////////////////////////////////////////////////////////////
+
void calf_plugins::get_all_plugins(std::vector<plugin_metadata_iface *> &plugins)
{
#define PER_MODULE_ITEM(name, isSynth, jackname) plugins.push_back(new name##_metadata);
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list