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

Method _allocVoice

Engine/source/sfx/sfxSound.cpp:204–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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