MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _allocVoice

Method _allocVoice

Engine/source/sfx/sfxSound.cpp:205–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203//-----------------------------------------------------------------------------
204
205bool SFXSound::_allocVoice( SFXDevice* device )
206{
207 // We shouldn't have any existing voice!
208 AssertFatal( !mVoice, "SFXSound::_allocVoice() - Already had a voice!" );
209
210 // Must not assign voice to source that isn't playing.
211 AssertFatal( getLastStatus() == SFXStatusPlaying,
212 "SFXSound::_allocVoice() - Source is not playing!" );
213
214 // The buffer can be lost when the device is reset
215 // or changed, so initialize it if we have to. If
216 // that fails then we cannot create the voice.
217
218 if( mBuffer.isNull() )
219 {
220 SFXProfile* profile = getProfile();
221 if( profile != NULL )
222 {
223 SFXBuffer* buffer = profile->getBuffer();
224 if( buffer )
225 _setBuffer( buffer );
226 }
227
228 if( mBuffer.isNull() )
229 return false;
230 }
231
232 // Ask the device for a voice based on this buffer.
233 mVoice = device->createVoice( is3d(), mBuffer );
234 if( !mVoice )
235 return false;
236
237 // Set initial properties.
238
239 mVoice->setVolume( mPreAttenuatedVolume );
240 mVoice->setPitch( mEffectivePitch );
241 mVoice->setPriority( mEffectivePriority );
242 if( mDescription->mRolloffFactor != -1.f )
243 mVoice->setRolloffFactor( mDescription->mRolloffFactor );
244
245 // Set 3D parameters.
246
247 if( is3d() )
248 {
249 // Scatter the position, if requested. Do this only once so
250 // we don't change position when resuming from virtualized
251 // playback.
252
253 if( !mTransformScattered )
254 _scatterTransform();
255
256 // Set the 3D attributes.
257
258 setTransform( mTransform );
259 setVelocity( mVelocity );
260 _setMinMaxDistance( mMinDistance, mMaxDistance );
261 _setCone( mConeInsideAngle, mConeOutsideAngle, mConeOutsideVolume );
262 }

Callers 2

_assignVoicesMethod · 0.80
_assignVoiceMethod · 0.80

Calls 14

isNullMethod · 0.45
getBufferMethod · 0.45
createVoiceMethod · 0.45
setVolumeMethod · 0.45
setPitchMethod · 0.45
setPriorityMethod · 0.45
setRolloffFactorMethod · 0.45
setReverbMethod · 0.45
getDurationMethod · 0.45
getPositionMethod · 0.45
getSampleCountMethod · 0.45
getFormatMethod · 0.45

Tested by

no test coverage detected