| 39 | } |
| 40 | |
| 41 | void AudioChannel::copyFromRange(const AudioChannel * sourceChannel, int startFrame, int endFrame) |
| 42 | { |
| 43 | // Check that range is safe for reading from sourceChannel. |
| 44 | bool isRangeSafe = sourceChannel && startFrame < endFrame && endFrame <= sourceChannel->length(); |
| 45 | ASSERT(isRangeSafe); |
| 46 | if (!isRangeSafe) return; |
| 47 | |
| 48 | if (sourceChannel->isSilent() && isSilent()) return; |
| 49 | |
| 50 | // Check that this channel has enough space. |
| 51 | size_t rangeLength = endFrame - startFrame; |
| 52 | bool isRangeLengthSafe = rangeLength <= length(); |
| 53 | ASSERT(isRangeLengthSafe); |
| 54 | |
| 55 | if (!isRangeLengthSafe) return; |
| 56 | |
| 57 | const float * source = sourceChannel->data(); |
| 58 | float * destination = mutableData(); |
| 59 | |
| 60 | if (sourceChannel->isSilent()) |
| 61 | { |
| 62 | if (rangeLength == length()) |
| 63 | zero(); |
| 64 | else |
| 65 | memset(destination, 0, sizeof(float) * rangeLength); |
| 66 | } |
| 67 | else |
| 68 | memcpy(destination, source + startFrame, sizeof(float) * rangeLength); |
| 69 | } |
| 70 | |
| 71 | void AudioChannel::sumFrom(const AudioChannel * sourceChannel) |
| 72 | { |
no test coverage detected