BOOL CConfigSound::OnInitDialog()
{
	CPropertyPage::OnInitDialog();

	CComboBox *pSampleRate	= static_cast<CComboBox*>(GetDlgItem(IDC_SAMPLE_RATE));
	CComboBox *pSampleSize	= static_cast<CComboBox*>(GetDlgItem(IDC_SAMPLE_SIZE));
	CComboBox *pDevices		= static_cast<CComboBox*>(GetDlgItem(IDC_DEVICES));
	
	CSliderCtrl *pBufSlider			  = static_cast<CSliderCtrl*>(GetDlgItem(IDC_BUF_LENGTH));
	CSliderCtrl *pBassSlider		  = static_cast<CSliderCtrl*>(GetDlgItem(IDC_BASS_FREQ));
	CSliderCtrl *pTrebleSliderFreq	  = static_cast<CSliderCtrl*>(GetDlgItem(IDC_TREBLE_FREQ));
	CSliderCtrl *pTrebleSliderDamping = static_cast<CSliderCtrl*>(GetDlgItem(IDC_TREBLE_DAMP));
	CSliderCtrl *pVolumeSlider		  = static_cast<CSliderCtrl*>(GetDlgItem(IDC_VOLUME));

	// Set ranges
	pBufSlider->SetRange(1, MAX_BUFFER_LEN);
	pBassSlider->SetRange(16, 4000);
	pTrebleSliderFreq->SetRange(20, 20000);
	pTrebleSliderDamping->SetRange(0, 90);
	pVolumeSlider->SetRange(0, 100);

	CSettings *pSettings = theApp.GetSettings();

	// Read settings
	switch (pSettings->Sound.iSampleRate) {
		case 11025: pSampleRate->SelectString(0, _T("11 025 Hz")); break;
		case 22050: pSampleRate->SelectString(0, _T("22 050 Hz")); break;
		case 44100: pSampleRate->SelectString(0, _T("44 100 Hz")); break;
		case 48000: pSampleRate->SelectString(0, _T("48 000 Hz")); break;
		case 96000: pSampleRate->SelectString(0, _T("96 000 Hz")); break;
	}

	switch (pSettings->Sound.iSampleSize) {
		case 16: pSampleSize->SelectString(0, _T("16 bit")); break;
		case 8:	 pSampleSize->SelectString(0, _T("8 bit")); break;
	}

	pBufSlider->SetPos(pSettings->Sound.iBufferLength);
	pBassSlider->SetPos(pSettings->Sound.iBassFilter);
	pTrebleSliderFreq->SetPos(pSettings->Sound.iTrebleFilter);
	pTrebleSliderDamping->SetPos(pSettings->Sound.iTrebleDamping);
	pVolumeSlider->SetPos(pSettings->Sound.iMixVolume);

	UpdateTexts();

	CDSound *pDSound = theApp.GetSoundGenerator()->GetSoundInterface();
	const int iCount = pDSound->GetDeviceCount();

	for (int i = 0; i < iCount; ++i)
		pDevices->AddString(pDSound->GetDeviceName(i));

	pDevices->SetCurSel(pSettings->Sound.iDevice);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #2
0
BOOL CConfigSound::OnInitDialog()
{
	CPropertyPage::OnInitDialog();

	CString Text;

	CComboBox	*pSampleRate, *pSampleSize, *pDevices;
	CSliderCtrl	*pBufSlider, *pBassSlider, *pTrebleSliderFreq, *pTrebleSliderDamping, *pVolumeSlider;

	pSampleRate	= (CComboBox*)GetDlgItem(IDC_SAMPLE_RATE);
	pSampleSize	= (CComboBox*)GetDlgItem(IDC_SAMPLE_SIZE);
	pDevices	= (CComboBox*)GetDlgItem(IDC_DEVICES);
	pBufSlider	= (CSliderCtrl*)GetDlgItem(IDC_BUF_LENGTH);

	pBassSlider			 = (CSliderCtrl*)GetDlgItem(IDC_BASS_FREQ);
	pTrebleSliderFreq	 = (CSliderCtrl*)GetDlgItem(IDC_TREBLE_FREQ);
	pTrebleSliderDamping = (CSliderCtrl*)GetDlgItem(IDC_TREBLE_DAMP);
	pVolumeSlider		 = (CSliderCtrl*)GetDlgItem(IDC_VOLUME);


	pBufSlider->SetRange(1, MAX_BUFFER_LEN);

	switch (theApp.GetSettings()->Sound.iSampleRate) {
		case 11025: pSampleRate->SelectString(0, _T("11 025 Hz")); break;
		case 22050: pSampleRate->SelectString(0, _T("22 050 Hz")); break;
		case 44100: pSampleRate->SelectString(0, _T("44 100 Hz")); break;
		case 48000: pSampleRate->SelectString(0, _T("48 000 Hz")); break;
		case 96000: pSampleRate->SelectString(0, _T("96 000 Hz")); break;
	}

	switch (theApp.GetSettings()->Sound.iSampleSize) {
		case 16: pSampleSize->SelectString(0, _T("16 bit")); break;
		case 8:	 pSampleSize->SelectString(0, _T("8 bit")); break;
	}

	pBufSlider->SetPos(theApp.GetSettings()->Sound.iBufferLength);

	Text.Format(_T("%i ms"), theApp.GetSettings()->Sound.iBufferLength);
	SetDlgItemText(IDC_BUF_LEN, Text);

	pBassSlider->SetRange(16, 4000);
	pTrebleSliderFreq->SetRange(20, 20000);
	pTrebleSliderDamping->SetRange(0, 90);
	pVolumeSlider->SetRange(0, 100);

	pBassSlider->SetPos(theApp.GetSettings()->Sound.iBassFilter);
	pTrebleSliderFreq->SetPos(theApp.GetSettings()->Sound.iTrebleFilter);
	pTrebleSliderDamping->SetPos(theApp.GetSettings()->Sound.iTrebleDamping);
	pVolumeSlider->SetPos(theApp.GetSettings()->Sound.iMixVolume);

	Text.Format(_T("%i Hz"), pBassSlider->GetPos());
	SetDlgItemText(IDC_BASS_FREQ_T, Text);

	Text.Format(_T("%i Hz"), pTrebleSliderFreq->GetPos());
	SetDlgItemText(IDC_TREBLE_FREQ_T, Text);

	Text.Format(_T("-%i dB"), pTrebleSliderDamping->GetPos());
	SetDlgItemText(IDC_TREBLE_DAMP_T, Text);

	Text.Format(_T("%i %%"), pVolumeSlider->GetPos());
	SetDlgItemText(IDC_VOLUME_T, Text);

	CDSound *pDSound = theApp.GetSoundGenerator()->GetSoundInterface();
	int iCount = pDSound->GetDeviceCount();

	for (int i = 0; i < iCount; ++i)
		pDevices->AddString(pDSound->GetDeviceName(i));

	pDevices->SetCurSel(theApp.GetSettings()->Sound.iDevice);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}