MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / play3dClocked

Method play3dClocked

extlibs/soloud/src/core/soloud_core_3d.cpp:436–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434 }
435
436 handle Soloud::play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX, float aVelY, float aVelZ, float aVolume, unsigned int aBus)
437 {
438 handle h = play(aSound, aVolume, 0, 1, aBus);
439 lockAudioMutex();
440 int v = getVoiceFromHandle(h);
441 if (v < 0)
442 {
443 unlockAudioMutex();
444 return h;
445 }
446 m3dData[v].mHandle = h;
447 mVoice[v]->mFlags |= AudioSourceInstance::PROCESS_3D;
448 set3dSourceParameters(h, aPosX, aPosY, aPosZ, aVelX, aVelY, aVelZ);
449 time lasttime = mLastClockedTime;
450 if (lasttime == 0)
451 mLastClockedTime = aSoundTime;
452 vec3 pos;
453 pos.mX = aPosX;
454 pos.mY = aPosY;
455 pos.mZ = aPosZ;
456 unlockAudioMutex();
457 int samples = 0;
458 if (lasttime != 0)
459 {
460 samples = (int)floor((aSoundTime - lasttime) * mSamplerate);
461 }
462 if (aSound.mFlags & AudioSource::DISTANCE_DELAY)
463 {
464 float dist = pos.mag();
465 samples += (int)floor((dist / m3dSoundSpeed) * mSamplerate);
466 }
467
468 update3dVoices((unsigned int *)&v, 1);
469 lockAudioMutex();
470 updateVoiceRelativePlaySpeed(v);
471 int j;
472 for (j = 0; j < MAX_CHANNELS; j++)
473 {
474 mVoice[v]->mChannelVolume[j] = m3dData[v].mChannelVolume[j];
475 }
476
477 updateVoiceVolume(v);
478
479 // Fix initial voice volume ramp up
480 int i;
481 for (i = 0; i < MAX_CHANNELS; i++)
482 {
483 mVoice[v]->mCurrentChannelVolume[i] = mVoice[v]->mChannelVolume[i] * mVoice[v]->mOverallVolume;
484 }
485
486 if (mVoice[v]->mOverallVolume < 0.01f)
487 {
488 // Inaudible.
489 mVoice[v]->mFlags |= AudioSourceInstance::INAUDIBLE;
490
491 if (mVoice[v]->mFlags & AudioSourceInstance::INAUDIBLE_KILL)
492 {
493 stopVoice(v);

Callers

nothing calls this directly

Calls 1

magMethod · 0.80

Tested by

no test coverage detected