When you create an audio application, the steps are the same as for other applications, except for additional steps that add audio features.
CreateFormRadio creates a form by loading it from the resource file and getting all the interfaces for the controls contained in the form. As you create a form, get the interface pointers to access the controls. Each Auto PC application must have at least one form.
Integer spin box controls are used with each menu item to provide a method for changing settings.
The audio manager gives you access and control over audio sources. For example, if you want to use the CD player and the radio is running, you need software that stops the radio before starting the CD player.
This procedure uses code examples from a sample audio application, Tuneit.cpp, included in the SDK. Tuneit.cpp highlights the use of tuner and audio manager APIs.
In the Tuneit.cpp file, the WinMain function shows how to program a message loop, and the GetFormsManager function shows how the Forms Manager is created. The TuneSink.cpp and TuneSink.h files show how to create an event sink.
Tuneit.cpp has only one form: form radio. The CreateFormRadio function creates a form by loading it from the resource file and getting all the interfaces for the controls contained in the form.
The following code example shows how to set up and initialize an audio manager. It shows only bass and treble; you need to cover all other application settings.
HRESULT
CTuneitApp::InitAudioManager()
{
long lRet;
long bMute = FALSE;
DWORD dwEQCaps = NULL;
// Verify support for bass and treble
if(AAM_GetEQCaps(&dwEQCaps))
{
return E_FAIL;
}
// Set local audio manager storage variables using
// local flags understood by your resource script
// menu-loading function.
if(dwEQCaps & AAM_FLAG_BASS) m_dwfAudioCaps |= FLAG_BASS;
if(dwEQCaps & AAM_FLAG_TREBLE) m_dwfAudioCaps |= FLAG_TREBLE;
// Get minimum, maximum, and current bass values.
if(!AAM_EQPreset(AAM_FLAG_BASS | AAM_FLAG_GET, &lRet))
{
m_lSetting[BASS] = lRet;
AAM_EQPreset(AAM_FLAG_BASS | AAM_FLAG_GET | AAM_FLAG_RANGE, &lRet);
m_lSettingMin[BASS] = -LOWORD(lRet);
m_lSettingMax[BASS] = LOWORD(lRet);
}
// Get minimum, maximum, and current treble values.
if(!AAM_EQPreset(AAM_FLAG_TREBLE | AAM_FLAG_GET, &lRet))
{
m_lSetting[TREBLE] = lRet;
AAM_EQPreset(AAM_FLAG_TREBLE | AAM_FLAG_GET | AAM_FLAG_RANGE, &lRet);
m_lSettingMin[TREBLE] = -LOWORD(lRet);
m_lSettingMax[TREBLE] = LOWORD(lRet);
}
// Turn off mute.
AAM_VolumeControl(AAM_FLAG_MUTE | AAM_FLAG_SET, &bMute);
// Set the source to radio.
AAM_SelectSource(AAM_SRC_TUNER);
return NOERROR;
}