3 * Copyright (c) 2007-2010 SlimDX Group
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
6 * of this software and associated documentation files (the "Software"), to deal
\r
7 * in the Software without restriction, including without limitation the rights
\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
9 * copies of the Software, and to permit persons to whom the Software is
\r
10 * furnished to do so, subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in
\r
13 * all copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
23 #include <windows.h>
\r
26 #include "../ComObject.h"
\r
27 #include "../math/Vector3.h"
\r
29 #include "DirectSoundException.h"
\r
31 #include "DirectSound.h"
\r
32 #include "SoundBuffer3D.h"
\r
34 using namespace System;
\r
38 namespace DirectSound
\r
40 SoundBuffer3D::SoundBuffer3D( SoundBuffer^ soundBuffer )
\r
42 IDirectSound3DBuffer8* buffer;
\r
44 HRESULT hr = soundBuffer->InternalPointer->QueryInterface( IID_IDirectSound3DBuffer8, reinterpret_cast<void**>( &buffer ) );
\r
45 if( RECORD_DSOUND( hr ).IsFailure )
\r
46 throw gcnew DirectSoundException( Result::Last );
\r
48 Construct( buffer );
\r
51 Buffer3DSettings SoundBuffer3D::AllParameters::get()
\r
54 result.dwSize = sizeof( DS3DBUFFER );
\r
55 HRESULT hr = InternalPointer->GetAllParameters( &result );
\r
56 RECORD_DSOUND( hr );
\r
58 return Buffer3DSettings( result );
\r
61 void SoundBuffer3D::AllParameters::set( Buffer3DSettings value )
\r
63 DS3DBUFFER result = value.ToUnmanaged();
\r
64 HRESULT hr = InternalPointer->SetAllParameters( &result, Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
65 RECORD_DSOUND( hr );
\r
68 int SoundBuffer3D::InsideConeAngle::get()
\r
71 HRESULT hr = InternalPointer->GetConeAngles( &inside, NULL );
\r
72 RECORD_DSOUND( hr );
\r
77 void SoundBuffer3D::InsideConeAngle::set( int value )
\r
79 HRESULT hr = InternalPointer->SetConeAngles( value, NULL, Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
80 RECORD_DSOUND( hr );
\r
83 int SoundBuffer3D::OutsideConeAngle::get()
\r
86 HRESULT hr = InternalPointer->GetConeAngles( NULL, &outside );
\r
87 RECORD_DSOUND( hr );
\r
92 void SoundBuffer3D::OutsideConeAngle::set( int value )
\r
94 HRESULT hr = InternalPointer->SetConeAngles( NULL, value, Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
95 RECORD_DSOUND( hr );
\r
98 Vector3 SoundBuffer3D::ConeOrientation::get()
\r
100 D3DVECTOR orientation = D3DVECTOR();
\r
101 HRESULT hr = InternalPointer->GetConeOrientation( &orientation );
\r
102 RECORD_DSOUND( hr );
\r
104 return Vector3( orientation.x, orientation.y, orientation.z );
\r
107 void SoundBuffer3D::ConeOrientation::set( Vector3 value )
\r
109 HRESULT hr = InternalPointer->SetConeOrientation( value.X, value.Y, value.Z, Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
110 RECORD_DSOUND( hr );
\r
113 int SoundBuffer3D::ConeOutsideVolume::get()
\r
116 HRESULT hr = InternalPointer->GetConeOutsideVolume( &volume );
\r
117 RECORD_DSOUND( hr );
\r
119 return static_cast<int>( volume );
\r
122 void SoundBuffer3D::ConeOutsideVolume::set( int value )
\r
124 HRESULT hr = InternalPointer->SetConeOutsideVolume( static_cast<LONG>( value ), Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
125 RECORD_DSOUND( hr );
\r
128 float SoundBuffer3D::MaxDistance::get()
\r
130 float maxDistance = 0.0f;
\r
131 HRESULT hr = InternalPointer->GetMaxDistance( &maxDistance );
\r
132 RECORD_DSOUND( hr );
\r
134 return maxDistance;
\r
137 void SoundBuffer3D::MaxDistance::set( float value )
\r
139 HRESULT hr = InternalPointer->SetMaxDistance( value, Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
140 RECORD_DSOUND( hr );
\r
143 float SoundBuffer3D::MinDistance::get()
\r
145 float minDistance = 0.0f;
\r
146 HRESULT hr = InternalPointer->GetMinDistance( &minDistance );
\r
147 RECORD_DSOUND( hr );
\r
149 return minDistance;
\r
152 void SoundBuffer3D::MinDistance::set( float value )
\r
154 HRESULT hr = InternalPointer->SetMinDistance( value, Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
155 RECORD_DSOUND( hr );
\r
158 Mode3D SoundBuffer3D::Mode::get()
\r
161 HRESULT hr = InternalPointer->GetMode( &mode );
\r
162 RECORD_DSOUND( hr );
\r
164 return static_cast<Mode3D>( mode );
\r
167 void SoundBuffer3D::Mode::set( Mode3D value )
\r
169 HRESULT hr = InternalPointer->SetMode( static_cast<DWORD>( value ), Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
170 RECORD_DSOUND( hr );
\r
173 Vector3 SoundBuffer3D::Position::get()
\r
175 D3DVECTOR position = D3DVECTOR();
\r
176 HRESULT hr = InternalPointer->GetPosition( &position );
\r
177 RECORD_DSOUND( hr );
\r
179 return Vector3( position.x, position.y, position.z );
\r
182 void SoundBuffer3D::Position::set( Vector3 value )
\r
184 HRESULT hr = InternalPointer->SetPosition( value.X, value.Y, value.Z, Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
185 RECORD_DSOUND( hr );
\r
188 Vector3 SoundBuffer3D::Velocity::get()
\r
190 D3DVECTOR velocity = D3DVECTOR();
\r
191 HRESULT hr = InternalPointer->GetVelocity( &velocity );
\r
192 RECORD_DSOUND( hr );
\r
194 return Vector3( velocity.x, velocity.y, velocity.z );
\r
197 void SoundBuffer3D::Velocity::set( Vector3 value )
\r
199 HRESULT hr = InternalPointer->SetVelocity( value.X, value.Y, value.Z, Deferred ? DS3D_DEFERRED : DS3D_IMMEDIATE );
\r
200 RECORD_DSOUND( hr );
\r