From 430ca9ea2710158a67fc4a89be2fafae04406ec8 Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Mon, 8 Aug 2022 11:15:29 +0200
Subject: [PATCH] fluid~: Get rid of unimportant log messages, only post errors
 from fluidsynth to the console.

---
 externals/fluid~/fluid~.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/externals/fluid~/fluid~.c b/externals/fluid~/fluid~.c
index c47d3d990..c10a126fc 100644
--- a/externals/fluid~/fluid~.c
+++ b/externals/fluid~/fluid~.c
@@ -368,7 +368,12 @@ static void *fluid_tilde_new(t_symbol *s, int argc, t_atom *argv)
     fluid_init(x, gensym("init"), argc, argv);
     return (void *)x;
 }
- 
+
+static void fluid_log_cb(int level, const char *message, void *data)
+{
+  post("fluid~ [%d]: %s", level, message);
+}
+
 void fluid_tilde_setup(void)
 {
     fluid_tilde_class = class_new(gensym("fluid~"),
@@ -441,4 +446,12 @@ void fluid_tilde_setup(void)
 
     class_addmethod(fluid_tilde_class,
         (t_method)fluid_tilde_dsp, gensym("dsp"), A_CANT, 0);
+
+    // Set up logging. We don't want to have too much noise here, and we also
+    // want to see the important stuff in the Pd console rather than the
+    // terminal.
+    fluid_set_log_function(FLUID_PANIC, fluid_log_cb, NULL);
+    fluid_set_log_function(FLUID_ERR, fluid_log_cb, NULL);
+    fluid_set_log_function(FLUID_WARN, NULL, NULL);
+    fluid_set_log_function(FLUID_DBG, NULL, NULL);
 }
-- 
GitLab