Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support stereo fx send to LADSPA #1170

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Support stereo fx send to LADSPA #1170

wants to merge 1 commit into from

Conversation

derselbst
Copy link
Member

For details, see #1161

Open questions:

  • Should this become fluidsynth's default way of handling fx?
  • Or should we make this feature configurable?
    • at runtime via a setting?
    • or at compile-time via a #define / CMake option?

@derselbst derselbst added this to the 2.4 milestone Oct 8, 2022
@sonarcloud
Copy link

sonarcloud bot commented Oct 8, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

61.9% 61.9% Coverage
0.0% 0.0% Duplication

@derselbst
Copy link
Member Author

@mawe42 In case you have some time these days, could you perhaps have a look at these changes and the related discussion? I'm struggling a bit whether this is useful in general as this is open for over a year now and no comments or feedback have arrived.

@mawe42
Copy link
Member

mawe42 commented Dec 29, 2023

Sure! No time at the moment , but I will look at it early January.

@mawe42
Copy link
Member

mawe42 commented Jan 4, 2024

So far I've only looked at the motivation behind this change and the diff, so I haven't tried it out yet. But from what I can see, this looks like a valuable change. And I'm leaning towards having the stereo fx send always enabled, without config option or compile-time switch.

But that would either require three fx sends (mono, left, right), or we would need to change the multi-channel audio drivers as well. For example, the jack driver only supports one reverb and chorus channel at the moment. If we would take the change as-is and always define #STEREO_FX, then the jack sends would not be mono anymore but only send the left channel.

Not sure what it would mean in terms of performance, but it might be easiest to go for three sends (mono, left + right). Expose all via the LADSPA interface (which would also remove any backwards incompatibilities) and later extend the multichannel audio drivers to also expose the left + right sends.

@derselbst
Copy link
Member Author

Thanks Marcus! I think the jack driver is the only one to handle effects channels, i.e. dsound, wasapi and waveout only handle dry channels currently.

So changing jack driver to expose the left and right fx channels should be straight forward.

The only benefit for an additional mono channel I see would be to retain backward compatibility in LADSPA, for e.g. Reverb:Send, correct?

@mawe42
Copy link
Member

mawe42 commented Jan 5, 2024

I think the mono channels would also be required for the internal effects. Currently the sends for the internal reverb and chorus effects only consider voice->reverb_send for the amp calculation. With this change, the first effect buffer (which is used by the internal effects) becomes the left effect send and also considers voice->pan and voice->balance. Voices that pan hard right would not send anything to the internal effects anymore.

Instead of a mono send, we could also sum the left and right sends together before handing them to the internal effects. But do we might run into phase problems here. Hm... more thinking required :-)

@mawe42
Copy link
Member

mawe42 commented Mar 31, 2024

Coming back to this... maybe a way forward would be to upgrade the internal effects to stereo? It would change the "sound" of FluidSynth, but probably for the better. And I wouldn't be too concerned about performance, as computing power even on embedded devices has increased quite a lot since FluidSynth was first written. If we are concerned about performance, we could leave the complile-time switch in but make it default to stereo fx. What do you think?

@derselbst
Copy link
Member Author

Those who are really concerned about performance would disable reverb and chorus anyway. I'm all in favor to upgrade internal fx to stereo. If you've got some time to spare, that would be great :)

@mawe42
Copy link
Member

mawe42 commented Apr 1, 2024

Ok, I'll try to tackle this over the next few weeks.

@mawe42
Copy link
Member

mawe42 commented Apr 1, 2024

But maybe some input from @mrbumpy409 and @jjceresa would be good before I start moving the internal effects to stereo. From what I've read so far, using a stereo reverb instead of mono would quite drastically alter the sound of FluidSynth. Stereo reverbs seem to give more of a "physical room" effect while mono reverbs contribute more of a "sound depth" instead. Having mono reverb (and chrous?) might actually be much better for the default effects of FluidSynth.

Maybe the better way forward would be to expose stereo fx sends via LADSPA and jack, but sum the stereo sends before feeding them into our internal effects?

@mawe42
Copy link
Member

mawe42 commented Apr 1, 2024

After more reading on stereo vs. mono reverbs, it seems to me that summing the two fx sends would be the better solution here. Otherwise we might have to implement a completely new reverb effect that takes the stereo fields into account. And that would definitely be much more work than I can handle at the moment. But I'll wait for other opinions before going any further.

@mawe42
Copy link
Member

mawe42 commented Apr 1, 2024

#1157 seems to be closely related to this PR.

@derselbst
Copy link
Member Author

After more reading on stereo vs. mono reverbs, it seems to me that summing the two fx sends would be the better solution here.

The Lexicon like reverb that I was also planning to implement as part of the linked ticket is just a mono reverb as well (but it reads from stereo input). So the summing option you've suggested sounds fine to me.

@jjceresa
Copy link
Collaborator

jjceresa commented Apr 6, 2024

Marcus, After more reading on stereo vs. mono reverbs, it seems to me that summing the two fx sends would be the better solution here....

Yes, as actually, internal effects (reverb and chorus) are able to produce true stereo output from mono input . This is due to multiple delays lines presence in those effects from which it is quite easy to pick internal multiple signal to produce multiple output (i.e stereo) out of phase. So, I think it is sufficient to keep mono input for this kind of internal effects.

For LADSPA unit input, it is better to expose stereo input. Indeed, as we cannot predict the internal capabilities of the LADSPA loaded effect, it is good for this effect not to be constrained only by mono input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants