MCPcopy Create free account
hub / github.com/LabSound/LabSound / copyWithSampleAccurateGainValuesFrom

Method copyWithSampleAccurateGainValuesFrom

src/core/AudioBus.cpp:644–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642}
643
644void AudioBus::copyWithSampleAccurateGainValuesFrom(const AudioBus & sourceBus, float * gainValues, int numberOfGainValues)
645{
646 // Make sure we're processing from the same type of bus.
647 // We *are* able to process from mono -> stereo
648 if (sourceBus.numberOfChannels() != Channels::Mono && !topologyMatches(sourceBus))
649 {
650 ASSERT_NOT_REACHED();
651 return;
652 }
653
654 if (!gainValues || numberOfGainValues > sourceBus.length())
655 {
656 ASSERT_NOT_REACHED();
657 return;
658 }
659
660 if (sourceBus.length() == numberOfGainValues && sourceBus.length() == length() && sourceBus.isSilent())
661 {
662 zero();
663 return;
664 }
665
666 // We handle both the 1 -> N and N -> N case here.
667 const float * source = sourceBus.channel(0)->data();
668 for (int channelIndex = 0; channelIndex < numberOfChannels(); ++channelIndex)
669 {
670 if (sourceBus.numberOfChannels() == numberOfChannels())
671 {
672 source = sourceBus.channel(channelIndex)->data();
673 }
674 vmul(source, 1, gainValues, 1, channel(channelIndex)->mutableData(), 1, numberOfGainValues);
675 }
676}
677
678std::unique_ptr<AudioBus> AudioBus::createBySampleRateConverting(const AudioBus * sourceBus, bool mixToMono, float newSampleRate)
679{

Callers 2

processMethod · 0.80
processMethod · 0.80

Calls 7

vmulFunction · 0.85
channelMethod · 0.80
mutableDataMethod · 0.80
numberOfChannelsMethod · 0.45
lengthMethod · 0.45
isSilentMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected