libsdl-org / SDL_mixer

An audio mixer that supports various file formats for Simple Directmedia Layer.
zlib License
433 stars 146 forks source link

Native MIDI music volume manipulating changes application global sound volume (MS GS only) #213

Open SDLBugzilla opened 3 years ago

SDLBugzilla commented 3 years ago

This bug report was migrated from our old Bugzilla tracker.

Reported in version: unspecified Reported for operating system, platform: Windows (All), x86

Comments on the original bug report:

On 2016-11-18 15:01:05 +0000, Vitaly Novichkov wrote:

Using midiOutSetVolume causes global uncontrollable application volume changing which we can see in the volumes panel. This happens with only MS GS MIDI Device, with other MIDI devices this doesn't happen.

A video demo which showing differences in MIDI engines work:

  • My custom libADLMIDI MIDI Engine
  • Native MIDI with standard Microsoft GS engine

https://www.youtube.com/watch?v=ObF9XBOa4Tk

Note: I used my own fork of the latest SDL Mixer which uses same code base with a few core changes and adding extra codecs (libADLMIDI, libGME): https://github.com/WohlSoft/PGE-Project/tree/master/_Libs/SDL2_mixer_modified

On 2016-11-19 21:48:11 +0000, Ozkan Sezer wrote:

I remember having a similar issue: https://sf.net/p/uhexen2/code/3815/ Quoting my commit message:

http://msdn.microsoft.com/en-us/library/dd798480(VS.85).aspx# 1 "This [midiOutSetVolume] function does not set the MIDI device volume when using a software synthesizer under Windows Vista or Windows 7, but instead alters the application-specific volume level in the system mixer. This means that if your application also outputs digital audio, the volume level of that audio will be reduced or increased by the same amount."

AFAICS, the user addition in that msdn page no longer exists, but the issue is there.

On 2016-11-19 21:55:08 +0000, Vitaly Novichkov wrote:

(In reply to Ozkan Sezer from comment # 1)

I remember having a similar issue: https://sf.net/p/uhexen2/code/3815/ Quoting my commit message:

http://msdn.microsoft.com/en-us/library/dd798480(VS.85).aspx# 1 "This [midiOutSetVolume] function does not set the MIDI device volume when using a software synthesizer under Windows Vista or Windows 7, but instead alters the application-specific volume level in the system mixer. This means that if your application also outputs digital audio, the volume level of that audio will be reduced or increased by the same amount."

AFAICS, the user addition in that msdn page no longer exists, but the issue is there.

Yea, therefore I implemented libADLMIDI as default MIDI engine which is:

  • required NO external bank files to be able to play MIDI
  • generates sound from scratch by formulas (like real Yamaha OPL3 FM Synthesis chip did)
  • works almost everywhere, tested Linux, Windows, OS X, Android.

However, this is suggested to people who want remember old DOS games or just liking the unique sound generated by that chip and have to use it for extra advantages in the music making, etc.

On 2017-06-01 19:26:03 +0000, Vitaly Novichkov wrote:

Okay, I have the solution idea: instead of passing entire MIDI file into Operating System, I have to implement the MIDI player that I'll iterate with dependence on sample rate and SDL Audio's timer and will play MIDI in real time. So, I getting the advantage: instead of changing application master volume, I have to apply volume multiply factor to every MIDI channel's volume value and this stupid bug will leave us. I already have iterative MIDI player at libADLMIDI, and I have to split it away as independent library that plays MIDI in real time with ability to attach any MIDI library or output to it

On 2019-06-19 09:43:09 +0000, Castro B wrote:

Does the issue already fixed? any current update? Thanks!

Castro B, https://tab.do/zh-tw/

On 2019-06-19 10:24:57 +0000, Vitaly Novichkov wrote:

(In reply to Castro B from comment # 4)

Does the issue already fixed? any current update? Thanks!

Castro B, https://tab.do/zh-tw/

No, it isn't. I still keep in my mind this to implement at any moment. Thanks for reminding, I'll try to do this soon.

slouken commented 2 years ago

Related to #128

AlexMax commented 1 year ago

It's worth mentioning that @ceski-1 has managed to create a workaround for this issue in the Doom source port Woof! which can be studied here. The idea is that volume events are injected into or mutated in the MIDI stream before it gets passed off to Windows.