From f4f0d6195457c3c8c55a41a4dd4869d6653957c3 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 23 Jan 2021 18:32:13 +0800 Subject: Pass 4 effect buffers (as it should be) to fluid_synth_process. Also retrieve active voices from the audio processing callback. (the values are still messed up sometimes...) --- core/qmpmidioutfluid.cpp | 11 +++++++++-- core/qmpmidioutfluid.hpp | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/qmpmidioutfluid.cpp b/core/qmpmidioutfluid.cpp index d2c0dcf..56e71a0 100644 --- a/core/qmpmidioutfluid.cpp +++ b/core/qmpmidioutfluid.cpp @@ -71,7 +71,8 @@ void qmpMidiOutFluid::deviceInit() [](void *t, int l, int nfx, float *fx[], int nout, float *out[])->int { qmpMidiOutFluid *self = static_cast(t); - fluid_synth_process(self->synth, l, nfx, fx, nout, out); + float *fxb[4] = {out[0], out[1], out[0], out[1]}; + int ret = fluid_synth_process(self->synth, l, nout * 2, fxb, nout, out); double s = 0; for (int i = 0; i < nout; ++i) { @@ -81,13 +82,15 @@ void qmpMidiOutFluid::deviceInit() } } self->output_level = 20 * log10(sqrt(s)); - return FLUID_OK; + self->voice_count = fluid_synth_get_active_voice_count(self->synth); + return ret; } , this); if (!adriver) { adriver = new_fluid_audio_driver(settings, synth); output_level = 1e9 + 7; + voice_count = -1; } if (!adriver) { @@ -317,6 +320,10 @@ void qmpMidiOutFluid::update_preset_list() } int qmpMidiOutFluid::getPolyphone() { + if (~voice_count) + { + return voice_count; + } return synth ? fluid_synth_get_active_voice_count(synth) : 0; } int qmpMidiOutFluid::getMaxPolyphone() diff --git a/core/qmpmidioutfluid.hpp b/core/qmpmidioutfluid.hpp index 4fdceff..f194c17 100644 --- a/core/qmpmidioutfluid.hpp +++ b/core/qmpmidioutfluid.hpp @@ -30,6 +30,7 @@ private: int default_driver = -1; void update_preset_list(); double output_level; + int voice_count; public: qmpMidiOutFluid(); ~qmpMidiOutFluid(); -- cgit v1.2.3