aboutsummaryrefslogtreecommitdiff
path: root/core/qmpmidioutfluid.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2021-01-23 18:32:13 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2021-01-23 18:32:13 +0800
commitf4f0d6195457c3c8c55a41a4dd4869d6653957c3 (patch)
treeb4fd028cd53ad680db3e3bc308d560244603fb5a /core/qmpmidioutfluid.cpp
parentfd7240ae1439b607c267d155e0fcfd2800d87f33 (diff)
downloadQMidiPlayer-f4f0d6195457c3c8c55a41a4dd4869d6653957c3.tar.xz
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...)
Diffstat (limited to 'core/qmpmidioutfluid.cpp')
-rw-r--r--core/qmpmidioutfluid.cpp11
1 files changed, 9 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<qmpMidiOutFluid*>(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()