コード例 #1
0
ファイル: DirectSound.cpp プロジェクト: doveiya/isilme
//-----------------------------------------------------------------------------
//	Получение всех параметров слушателя
// на входе    :  listener - указатель на интерфейс слушателя
//  			  data     - указатель на структуру в которую нужно поместить
//  						 параметры слушателя
// на выходе   :	успешность получения параметров слушателя
//-----------------------------------------------------------------------------
int ds_GetAllListenerParameters(LPDIRECTSOUND3DLISTENER listener,
	LPDS3DLISTENER data)
{
	// проверка наличия слушателя
	if (!listener)
		return false;

	// пропишем размер структуры
	data->dwSize = sizeof(DS3DLISTENER);

	// получение параметров слушателя
	if (listener->GetAllParameters(data) == DS_OK)
		return true;

	return false;
}
コード例 #2
0
ファイル: play3dsound.cpp プロジェクト: grakidov/Render3D
//-----------------------------------------------------------------------------
// Name: OnInitDialog()
// Desc: Initializes the dialogs (sets up UI controls, etc.)
//-----------------------------------------------------------------------------
VOID OnInitDialog( HWND hDlg )
{
    HRESULT hr;

    // Load the icon
#ifdef _WIN64
    HINSTANCE hInst = (HINSTANCE) GetWindowLongPtr( hDlg, GWLP_HINSTANCE );
#else
    HINSTANCE hInst = (HINSTANCE) GetWindowLong( hDlg, GWL_HINSTANCE );
#endif
    HICON hIcon = LoadIcon( hInst, MAKEINTRESOURCE( IDR_MAINFRAME ) );

    // Create a static IDirectSound in the CSound class.  
    // Set coop level to DSSCL_PRIORITY, and set primary buffer 
    // format to stereo, 22kHz and 16-bit output.
    g_pSoundManager = new CSoundManager();

    hr = g_pSoundManager->Initialize( hDlg, DSSCL_PRIORITY, 2, 22050, 16 );

    // Get the 3D listener, so we can control its params
    hr |= g_pSoundManager->Get3DListenerInterface( &g_pDSListener );

    if( FAILED(hr) )
    {
        DXTRACE_ERR( TEXT("Get3DListenerInterface"), hr );
        MessageBox( hDlg, "Error initializing DirectSound.  Sample will now exit.", 
                            "DirectSound Sample", MB_OK | MB_ICONERROR );
        EndDialog( hDlg, IDABORT );
        return;
    }

    // Get listener parameters
    g_dsListenerParams.dwSize = sizeof(DS3DLISTENER);
    g_pDSListener->GetAllParameters( &g_dsListenerParams );

    // Set the icon for this dialog.
    PostMessage( hDlg, WM_SETICON, ICON_BIG,   (LPARAM) hIcon );  // Set big icon
    PostMessage( hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon );  // Set small icon

    // Create a timer to periodically move the 3D object around
    SetTimer( hDlg, IDT_MOVEMENT_TIMER, 0, NULL );

    // Set the UI controls
    SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
    SetDlgItemText( hDlg, IDC_STATUS, TEXT("No file loaded.") );

    // Get handles to dialog items
    HWND hDopplerSlider  = GetDlgItem( hDlg, IDC_DOPPLER_SLIDER );
    HWND hRolloffSlider  = GetDlgItem( hDlg, IDC_ROLLOFF_SLIDER );
    HWND hMinDistSlider  = GetDlgItem( hDlg, IDC_MINDISTANCE_SLIDER );
    HWND hMaxDistSlider  = GetDlgItem( hDlg, IDC_MAXDISTANCE_SLIDER );
    HWND hVertSlider     = GetDlgItem( hDlg, IDC_VERTICAL_SLIDER );
    HWND hHorzSlider     = GetDlgItem( hDlg, IDC_HORIZONTAL_SLIDER );

    // Set the range and position of the sliders
    PostMessage( hDopplerSlider, TBM_SETRANGEMAX, TRUE, 40L );
    PostMessage( hDopplerSlider, TBM_SETRANGEMIN, TRUE, 0L );

    PostMessage( hRolloffSlider, TBM_SETRANGEMAX, TRUE, 40L );
    PostMessage( hRolloffSlider, TBM_SETRANGEMIN, TRUE, 0L );

    PostMessage( hMinDistSlider, TBM_SETRANGEMAX, TRUE, 40L );
    PostMessage( hMinDistSlider, TBM_SETRANGEMIN, TRUE, 1L );

    PostMessage( hMaxDistSlider, TBM_SETRANGEMAX, TRUE, 40L );
    PostMessage( hMaxDistSlider, TBM_SETRANGEMIN, TRUE, 1L );

    PostMessage( hVertSlider,    TBM_SETRANGEMAX, TRUE, 100L );
    PostMessage( hVertSlider,    TBM_SETRANGEMIN, TRUE, -100L );
    PostMessage( hVertSlider,    TBM_SETPOS,      TRUE, 100L );

    PostMessage( hHorzSlider,    TBM_SETRANGEMAX, TRUE, 100L );
    PostMessage( hHorzSlider,    TBM_SETRANGEMIN, TRUE, -100L );
    PostMessage( hHorzSlider,    TBM_SETPOS,      TRUE, 100L );

    // Set the position of the sliders
    SetSlidersPos( hDlg, 0.0f, 0.0f, ORBIT_MAX_RADIUS, ORBIT_MAX_RADIUS*2.0f );
}