| 642 | } |
| 643 | |
| 644 | void 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 | |
| 678 | std::unique_ptr<AudioBus> AudioBus::createBySampleRateConverting(const AudioBus * sourceBus, bool mixToMono, float newSampleRate) |
| 679 | { |
no test coverage detected