Just copies the samples from the source bus to this one. This is just a simple copy if the number of channels match, otherwise a mixup or mixdown is done. For now, we just support mixup from mono -> stereo and mixdown from stereo -> mono.
| 243 | // This is just a simple copy if the number of channels match, otherwise a mixup or mixdown is done. |
| 244 | // For now, we just support mixup from mono -> stereo and mixdown from stereo -> mono. |
| 245 | void AudioBus::copyFrom(const AudioBus & sourceBus, ChannelInterpretation channelInterpretation) |
| 246 | { |
| 247 | if (&sourceBus == this) return; |
| 248 | |
| 249 | int numberOfSourceChannels = sourceBus.numberOfChannels(); |
| 250 | int numberOfDestinationChannels = numberOfChannels(); |
| 251 | |
| 252 | if (numberOfDestinationChannels == numberOfSourceChannels) |
| 253 | { |
| 254 | for (int i = 0; i < numberOfSourceChannels; ++i) |
| 255 | { |
| 256 | channel(i)->copyFrom(sourceBus.channel(i)); |
| 257 | } |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | switch (channelInterpretation) |
| 262 | { |
| 263 | case ChannelInterpretation::Speakers: speakersCopyFrom(sourceBus); break; |
| 264 | case ChannelInterpretation::Discrete: discreteCopyFrom(sourceBus); break; |
| 265 | default: |
| 266 | ASSERT_NOT_REACHED(); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | void AudioBus::sumFrom(const AudioBus & sourceBus, ChannelInterpretation channelInterpretation) |
| 272 | { |