Closed c0d3h4x0r closed 2 years ago
This is a good idea and shouldn't be difficult to implement as I already have per-SoundFont stuff in place for other FluidSynth parameters. Will work on this for the next release.
Please test this build: https://github.com/dwhinham/mt32-pi/actions/runs/1929248605
It should now be possible to set gain
in each FluidSynth profile section, and the main section contains the default as per the other effects settings.
It also contains an attempt at a fix for #247, so please check the behaviour when switching SoundFonts whilst music is playing.
Awesome! I'll give it a try tonight.
Sent via Outlook for iOShttps://aka.ms/o0ukef
From: Dale Whinham @.> Sent: Thursday, March 3, 2022 8:54:05 AM To: dwhinham/mt32-pi @.> Cc: Keith F. Kelly @.>; Author @.> Subject: Re: [dwhinham/mt32-pi] 💡 [FEATURE] Provide a per-SoundFont master gain override (Issue #248)
Please test this build: https://github.com/dwhinham/mt32-pi/actions/runs/1929248605https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdwhinham%2Fmt32-pi%2Factions%2Fruns%2F1929248605&data=04%7C01%7C%7C6a53d15a5d5742ff6fd208d9fd366e34%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637819232573505735%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ROSw987r0J3WjCjDQ%2Fd3R0oB3mVtCfJ5j9An%2BCYl7T0%3D&reserved=0
It should now be possible to set gain in each FluidSynth profile section, and the main section contains the default as per the other effects settings.
It also contains an attempt at a fix for #247https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdwhinham%2Fmt32-pi%2Fissues%2F247&data=04%7C01%7C%7C6a53d15a5d5742ff6fd208d9fd366e34%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637819232573505735%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ZSb8BiDz6jd5g7lbKh49ZiKzY6h0CYhBQJ6uw%2FSAURE%3D&reserved=0, so please check the behaviour when switching SoundFonts whilst music is playing.
— Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdwhinham%2Fmt32-pi%2Fissues%2F248%23issuecomment-1058256806&data=04%7C01%7C%7C6a53d15a5d5742ff6fd208d9fd366e34%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637819232573505735%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=smXiZ3hcl3kOWFWhf0y2hgzqjJuo5hd5AZC%2BjpXlsEg%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAF2EYJGB6MRFXT56Z7J2QSDU6DVC3ANCNFSM5PYNUEGQ&data=04%7C01%7C%7C6a53d15a5d5742ff6fd208d9fd366e34%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637819232573661953%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=LS11MMsgASVsmUmRDlnS562tbfSILTPy1hka1if7ycU%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C6a53d15a5d5742ff6fd208d9fd366e34%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637819232573661953%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2F3fhCc7YJ96dcFsSAnvhxaXDs2I4xJ996h5z%2FKBq1z0%3D&reserved=0 or Androidhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7C6a53d15a5d5742ff6fd208d9fd366e34%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637819232573661953%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Fa9iI39ihNa7KzLQ01i3tUQkGAExaTCVWb6YI6KIyn4%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>
Per-soundfont gain appears to work great for values greater than and less than 1.0.
Hrmm... actually, the per-soundfont gain override doesn't appear to stick. It applies for a while, but then suddenly it switches back to the general gain level.
Can you elaborate?
I switch to a SoundFont that I've set to use gain = 0.5. It loads. I start playing Tyrian. I notice the volume is greatly reduced. Good.
A few minutes into playing the game, mid-song, the gain suddenly jumps back to full, without me doing anything.
Reduced?
The initial gain is 0.2, which is the FluidSynth default. Setting it to 0.5 is an increase in volume.
It would be helpful if you could test this game with FluidSynth on a PC to understand the behaviour properly and ensure it's an mt32-pi thing. Games are able to control the volume of individual MIDI channels, as well as note velocity and MIDI master volume, and the gain setting is applied after all of those other volumes.
I'll try to find time to dig into this over the weekend...
Ah crud, good point! I forgot the global default isn't 1.0. So now I've got quite the mystery on my hands, because that font definitely now sounds quieter when first selected.
I'll go back and retry with 0.075 or something instead.
No problem.
Be sure that you are starting the soundtrack right from the beginning after switching SoundFonts. Mid-song is not a valid test, as any MIDI song is able to affect the volume in many ways independently of the gain and before gain is applied.
Example:
Additionally, games often have a settings menu for MIDI volume.
A fair test would be to switch SoundFont and then completely reboot the game from scratch.
Are you saying the per-soundfont gain overridable by MIDI rather than a true master mixing gain?
No, not at all. It is a multiplier applied after MIDI channel volume and MIDI master volume.
I said above:
Games are able to control the volume of individual MIDI channels, as well as note velocity and MIDI master volume, and the gain setting is applied after all of those other volumes.
Got it. Did more self-testing, and it looks good. Thanks!
Is your feature request related to a problem? Please describe.
Some SoundFonts are overall louder than others, such that it's impossible to set the master gain low enough to avoid clipping a loud font without other SoundFonts then being too quiet.
Describe the solution you'd like
Add a master gain override setting to each per-SoundFont configuration section, so the user can easily make quiet fonts louder or loud fonts quieter.
Describe alternatives you've considered
While it's possible to hand-edit SoundFont files (using various apps) to reduce the volume for every patch within a font, that's a lot of extra work just to get all the SoundFonts to be roughly the same volume.
Ideally, the user would never need to set the master gain level (for either Munt or FluidSynth) within the mt32-pi config. Both sound engines ought to be smart enough to do the math to automatically set the gain to the loudest possible value that won't clip, based on information contained within each SoundFont combined with other settings (such as max polyphony, chorus settings, and reverb settings). Clipping due to overgain should simply be made mathematically impossible. However, I'm sure that's a lot more work, and probably requires changes to each of this respective sound engines, rather than to code maintained by this repo.
Additional context
n/a