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

Function InitVoice

Engine/lib/openal-soft/al/source.cpp:435–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433
434
435void InitVoice(Voice *voice, ALsource *source, ALbufferQueueItem *BufferList, ALCcontext *context,
436 ALCdevice *device)
437{
438 voice->mLoopBuffer.store(source->Looping ? &source->mQueue.front() : nullptr,
439 std::memory_order_relaxed);
440
441 ALbuffer *buffer{BufferList->mBuffer};
442 ALuint num_channels{buffer->channelsFromFmt()};
443 voice->mFrequency = buffer->mSampleRate;
444 voice->mFmtChannels = buffer->mChannels;
445 voice->mFmtType = buffer->mType;
446 voice->mSampleSize = buffer->bytesFromFmt();
447 voice->mAmbiLayout = buffer->mAmbiLayout;
448 voice->mAmbiScaling = buffer->mAmbiScaling;
449 voice->mAmbiOrder = buffer->mAmbiOrder;
450
451 if(buffer->mCallback) voice->mFlags |= VoiceIsCallback;
452 else if(source->SourceType == AL_STATIC) voice->mFlags |= VoiceIsStatic;
453 voice->mNumCallbackSamples = 0;
454
455 /* Clear the stepping value explicitly so the mixer knows not to mix this
456 * until the update gets applied.
457 */
458 voice->mStep = 0;
459
460 if(voice->mChans.capacity() > 2 && num_channels < voice->mChans.capacity())
461 al::vector<Voice::ChannelData>{}.swap(voice->mChans);
462 voice->mChans.reserve(maxu(2, num_channels));
463 voice->mChans.resize(num_channels);
464
465 /* Don't need to set the VOICE_IS_AMBISONIC flag if the device is not
466 * higher order than the voice. No HF scaling is necessary to mix it.
467 */
468 if(voice->mAmbiOrder && device->mAmbiOrder > voice->mAmbiOrder)
469 {
470 const uint8_t *OrderFromChan{(voice->mFmtChannels == FmtBFormat2D) ?
471 AmbiIndex::OrderFrom2DChannel().data() :
472 AmbiIndex::OrderFromChannel().data()};
473 const auto scales = BFormatDec::GetHFOrderScales(voice->mAmbiOrder, device->mAmbiOrder);
474
475 const BandSplitter splitter{device->mXOverFreq / static_cast<float>(device->Frequency)};
476
477 for(auto &chandata : voice->mChans)
478 {
479 chandata.mPrevSamples.fill(0.0f);
480 chandata.mAmbiScale = scales[*(OrderFromChan++)];
481 chandata.mAmbiSplitter = splitter;
482 chandata.mDryParams = DirectParams{};
483 std::fill_n(chandata.mWetParams.begin(), device->NumAuxSends, SendParams{});
484 }
485
486 voice->mFlags |= VoiceIsAmbisonic;
487 }
488 else
489 {
490 /* Clear previous samples. */
491 for(auto &chandata : voice->mChans)
492 {

Callers 1

source.cppFile · 0.85

Calls 13

maxuFunction · 0.85
UpdateSourcePropsFunction · 0.85
channelsFromFmtMethod · 0.80
bytesFromFmtMethod · 0.80
frontMethod · 0.45
capacityMethod · 0.45
swapMethod · 0.45
reserveMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
fillMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected