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

Method copyFromRange

src/core/AudioChannel.cpp:41–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void 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
71void AudioChannel::sumFrom(const AudioChannel * sourceChannel)
72{

Callers 2

createBufferFromRangeMethod · 0.80
createByCloningMethod · 0.80

Calls 3

lengthMethod · 0.45
isSilentMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected