[SDL] SDL_Mixer : Mix_VolumeMusic() and windows native midi, a painful journey ; )
Benjamin Babut
marty at whyme.fr.fm
Sat Feb 4 03:07:46 PST 2006
I come finally to a solution quite satisfying, that is to say patching
SDL_mixer so that the midi volume function changes the volume of ALL
midiout devices that have the MIDICAPS_VOLUME set in their capabilities
(MIDIOUTCAPS.dwSupport).
Thus, if there's a "master" device for midi volume, which seems to happen
on my machine, it is also affected by a call to Mix_VolumeMusic and
everything is fine. Thus, my solution :
SDL_Mixer : native_midi_win32.c :
=================================
void native_midi_setvolume(int volume)
{
int calcVolume;
MIDIOUTCAPS capabilities;
int i = 0;
if (volume > 128)
volume = 128;
if (volume < 0)
volume = 0;
calcVolume = (65535 * volume / 128);
//Device loop
for(i=0;i<midiOutGetNumDevs();i++)
{
//Get device capabilities
midiOutGetDevCaps(i,&capabilities,sizeof(capabilities));
//Adjust volume on this candidate
if((capabilities.dwSupport&MIDICAPS_VOLUME))
midiOutSetVolume((HMIDIOUT)i, MAKELONG(calcVolume , calcVolume));
}
}
My remaining questions are : do you think is this method safe ? robust ?
resource consuming ? or simply OK ?
In any case, it solved my problems :)
Ben
On Wed, 01 Feb 2006 17:37:06 +0100, Benjamin Babut <marty at whyme.fr.fm>
wrote:
> On Tue, 31 Jan 2006, Sam Lantinga <slouken at devolution.com> wrote:
>
>> Can you test this with some other programs that use MIDI_MAPPER?
>> If you explicitly open the SB Live! MIDI device and change the
>> volume on that while it is the currently selected default device,
>> does that work?
>> What happens with the system midi volume slider when you have the
>> SB Live! device selected?
>
>
> After some tests : if if I open explicitly the SB Live! MIDI device,
> midiOutSetVolume has the same behaviour. It returns 1 and the Volume does
> not change in spite of the good value of the field capability structure
> (I've verified that field again and again and again).
>
>
> However, changing the volume with Windows volume controler "MIDI" slider,
> the volume is affected : so, the slider is able to command the volume of
> my SB, whereas the midiOutSetVolume function does not.
More information about the SDL
mailing list