// From within my application program:
qSetMasterVolume( (DWORD)0xFFFFFFFFUL);
// Function in sound routine program:
void qSetMasterVolume(unsigned long newValue)
{
HMIXER HMixer;
MIXERCONTROLDETAILS mcd;
MIXERCONTROLDETAILS_UNSIGNED mcdMeter;
MIXERLINE ml;
MIXERCONTROL mc;
MIXERLINECONTROLS mlc;
ZeroMemory(&mc, sizeof(MIXERCONTROL));
ZeroMemory(&ml, sizeof(MIXERLINE));
ZeroMemory(&mlc, sizeof(MIXERLINECONTROLS));
ZeroMemory(&mcd, sizeof(mcd));
// Open mixer device and grab its handle
if (mixerOpen(&HMixer, 0, 0, 0, 0) == MMSYSERR_NOERROR)
{
// Initialize the MIXERCONTROL structure
mc.cbStruct = sizeof(MIXERCONTROL);
// Initialize the MIXERLINE structure
ml.cbStruct = sizeof(MIXERLINE);
ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
// Fill the mixerline info
if (mixerGetLineInfo(HMixer, &ml, MIXER_GETLINEINFOF_COMPONENTTYPE)
==
MMSYSERR_NOERROR)
{
// Find the source for the master volume component
int num_devices = ml.cConnections;
for (int index = 0; index < num_devices; index++)
{
ml.dwSource = index;
mixerGetLineInfo(HMixer, &ml, MIXER_GETLINEINFOF_SOURCE);
if (ml.dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_FIRST)
break;
}
// Initialize the MIXERLINECONTROL structure
mlc.cbStruct = sizeof(MIXERLINECONTROLS);
mlc.dwLineID = ml.dwLineID;
mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
mlc.cControls = 1;
mlc.cbmxctrl = sizeof(MIXERCONTROL);
mlc.pamxctrl = (LPMIXERCONTROL)&mc;
// Find the level display associated with this source
if (mixerGetLineControls(HMixer, &mlc,
MIXER_GETLINECONTROLSF_ONEBYTYPE)
== MMSYSERR_NOERROR)
{
// Initialize the MIXERCONTROLDETAILS structure
mcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
mcd.dwControlID = mc.dwControlID;
mcd.cChannels = 1;
mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mcd.paDetails = &mcdMeter;
// Set the new volume value
mcdMeter.dwValue = newValue;
mixerSetControlDetails(HMixer, &mcd,
MIXER_GETCONTROLDETAILSF_VALUE);
}
}
}
// Close mixer handle
mixerClose(HMixer);
}
>Any pointers would be greatly appreciated.
You probably don't want to hear this, but armed with this code you
should go back to the help file and figure out what's going on.
There's no substitute for a little understanding :-)
Sure, the help file documents contain everything you need to know.
Having been writing a sound program that uses the low level
waveIn/Out routines, I can tell you that the documentation from
Microsoft does not contain everything you need to know to write
a working program.
JAB.
--
Jonathan A. Buzzard Email: jonathan...@sund.ac.uk
University of Sunderland, U.K. Tel: +44(0)191-5153447
>> You probably don't want to hear this, but armed with this code you
>> should go back to the help file and figure out what's going on.
>> There's no substitute for a little understanding :-)
>
>Sure, the help file documents contain everything you need to know.
>Having been writing a sound program that uses the low level
>waveIn/Out routines, I can tell you that the documentation from
>Microsoft does not contain everything you need to know to write
>a working program.
I've learnt to use a variety of sections of the API, such as wave
in/out and the audio mixer, with nothing but the help file for
assistance. Certainly potted code can solve immediate problems more
quickly (if it's correct and applicable!) but if you really understand
how something works you can take it much further.