IanM, sorry for not getting back sooner on this and mabie you already figured this out, but just in case...
Looking through the DBPro SDK code I have ( pre-reorganized music library era ), I saw in the SetSoundVolume and SoundMusicVolume functions where the algorithm used to set the volumes were not converted to a linear scale to make full use of a 0-100 sound range. Also note that the "->put_Volume" and "->SetVolume" uses a logarithmic scale. With this new algorithm, I can hear the full range now.
If you want to test this, here is the code I have...
In function SetMusicVolume found in CMusicC.cpp:
(Updated code in the "else block")
DARKSDK void SetMusicVolume ( int iID, int iVolume )
{
if ( iID < 1 || iID > MAXIMUMVALUE )
{
RunTimeError(RUNTIMEERROR_MUSICNUMBERILLEGAL);
return;
}
if ( !UpdatePtr ( iID ) )
{
RunTimeError(RUNTIMEERROR_MUSICNOTEXIST);
return;
}
// set volume value
m_ptr->iVolume = iVolume;
// if CD music, volume is through MCI
if ( m_ptr->eID == CD )
{
// cannot adjust CD volume directly, must change master volume via mixer
DWORD m_nNumMixers = ::mixerGetNumDevs();
HMIXER m_hMixer = NULL;
MIXERCAPS m_mxcaps;
::ZeroMemory(&m_mxcaps, sizeof(MIXERCAPS));
if (m_nNumMixers != 0)
{
if (::mixerOpen(&m_hMixer,
0,
reinterpret_cast<DWORD>(g_pGlob->hWnd),
NULL,
MIXER_OBJECTF_MIXER | CALLBACK_WINDOW)
!= MMSYSERR_NOERROR)
return;
if (::mixerGetDevCaps(reinterpret_cast<UINT>(m_hMixer),
&m_mxcaps, sizeof(MIXERCAPS))
!= MMSYSERR_NOERROR)
return;
}
// get dwLineID
DWORD m_dwVolumeControlID = 0;
MIXERLINE mxl;
mxl.cbStruct = sizeof(MIXERLINE);
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
if (::mixerGetLineInfo(reinterpret_cast<HMIXEROBJ>(m_hMixer),
&mxl,
MIXER_OBJECTF_HMIXER |
MIXER_GETLINEINFOF_COMPONENTTYPE)
!= MMSYSERR_NOERROR)
return;
// get dwControlID
MIXERCONTROL mxc;
MIXERLINECONTROLS mxlc;
mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
mxlc.dwLineID = mxl.dwLineID;
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
mxlc.cControls = 1;
mxlc.cbmxctrl = sizeof(MIXERCONTROL);
mxlc.pamxctrl = &mxc;
if (::mixerGetLineControls(reinterpret_cast<HMIXEROBJ>(m_hMixer),
&mxlc,
MIXER_OBJECTF_HMIXER |
MIXER_GETLINECONTROLSF_ONEBYTYPE)
!= MMSYSERR_NOERROR)
return;
// store dwControlID
DWORD m_dwMinimum = mxc.Bounds.dwMinimum;
DWORD m_dwMaximum = mxc.Bounds.dwMaximum;
m_dwVolumeControlID = mxc.dwControlID;
// set volume
DWORD dwVal = (DWORD)(((m_dwMaximum - m_dwMinimum)/100.0f) * iVolume);
MIXERCONTROLDETAILS_UNSIGNED mxcdVolume = { dwVal };
MIXERCONTROLDETAILS mxcd;
mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
mxcd.dwControlID = m_dwVolumeControlID;
mxcd.cChannels = 1;
mxcd.cMultipleItems = 0;
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mxcd.paDetails = &mxcdVolume;
if (::mixerSetControlDetails(reinterpret_cast<HMIXEROBJ>(m_hMixer),
&mxcd,
MIXER_OBJECTF_HMIXER |
MIXER_SETCONTROLDETAILSF_VALUE)
!= MMSYSERR_NOERROR)
return;
if (m_hMixer != NULL)
{
BOOL bSucc = (::mixerClose(m_hMixer) == MMSYSERR_NOERROR);
m_hMixer = NULL;
}
}
else
{
// basic audio interface required for music volume change
if ( !m_ptr->pBasicAudio )
{
Error ( "SetMusicVolume - invalid basic audio interface" );
return;
}
//long lVolume = -2500 - (iVolume * -25);
//if(iVolume>0)
// m_ptr->pBasicAudio->put_Volume ( lVolume );
//else
// m_ptr->pBasicAudio->put_Volume ( -10000 );
double decibels;
DWORD linearVolume;
if (iVolume == 0)
linearVolume = -10000;
else
{
decibels = 20.0 * log10((double)(iVolume*100) / 10000.0);
linearVolume = (DWORD)(decibels * 100.0);
}
m_ptr->pBasicAudio->put_Volume ( linearVolume );
}
}
In function SetSoundVolume found in CSoundC.cpp
DARKSDK void SetSoundVolume ( int iID, int iVolume )
{
// mike - 010904 - 5.7 - silent return if sound card does not exist
if ( !g_pSoundManager->GetExists ( ) )
return;
if ( iID < 1 || iID > MAXIMUMVALUE )
{
RunTimeError(RUNTIMEERROR_SOUNDNUMBERILLEGAL);
return;
}
if ( !UpdatePtr ( iID ) )
{
RunTimeError(RUNTIMEERROR_SOUNDNOTEXIST);
return;
}
if ( iVolume < 0 || iVolume > 100 )
{
RunTimeError(RUNTIMEERROR_SOUNDVOLUMEILLEGAL);
return;
}
// set the volume
// set the volume property
m_ptr->iVolume=iVolume;
//m_ptr->pSound->GetBuffer(0)->SetVolume ( (int)(-9600*((100-iVolume)/100.0)) );
double decibels;
DWORD linearVolume;
if (iVolume == 0)
linearVolume = -10000;
else
{
decibels = 20.0 * log10((double)(iVolume*100) / 10000.0);
linearVolume = (DWORD)(decibels * 100.0);
}
m_ptr->pSound->GetBuffer(0)->SetVolume ( linearVolume );
}
So, instead of only able to hear audio in the 35-40 to 100 range, I'm able to hear 1-100 range, 0 being quite, for sounds and midi music now.
Here's the dbpro code I used to test with...
For midi music:
Music1.mid
Dark Basic Professional Online\Help\examples\music\music
Midi Music Test Code: [ press a,d to change volume ]
load music "music1.mid",1
loop music 1
akey=0
dkey=0
volume=50
set music volume 1,volume
do
cls
if keystate(30)=1 and akey=0
akey=1
dec volume,1
if volume<0 then volume=0
set music volume 1,volume
endif
if keystate(30)=0 and akey=1
akey=0
endif
if keystate(32)=1 and dkey=0
dkey=1
inc volume,1
if volume>100 then volume=100
set music volume 1,volume
endif
if keystate(32)=0 and dkey=1
dkey=0
endif
print "music volume ",music volume(1)
loop
end
For .wav sound:
Razor Slate.wav
Found at:
Dark Basic Professional Online\Media\Sounds\Super Weapons
Sound test code: [ press a,d to change volume ]
load sound "Razor Slate.wav",1
loop sound 1
akey=0
dkey=0
volume=50
set sound volume 1,volume
do
cls
if keystate(30)=1 and akey=0
akey=1
dec volume,1
if volume<0 then volume=0
set sound volume 1,volume
play sound 1
endif
if keystate(30)=0 and akey=1
akey=0
endif
if keystate(32)=1 and dkey=0
dkey=1
inc volume,1
if volume>100 then volume=100
set sound volume 1,volume
play sound 1
endif
if keystate(32)=0 and dkey=1
dkey=0
endif
print "sound volume "+str$(sound volume(1))
loop
end
EDIT: Also tested CLS's goodbadugly.mid and the volume works for me with it. No clue what could be the problem on why they can't change the volume. Will test a mp3 here in a bit.
EDIT2: Tested some mp3 files and they work for me also. I have a SoundBlaster Audigy 4 soundcard. I wonder if it's a soundcard issue for them to not being able to change the volume?? Just a guess...