mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added AudioSampleBuffer::reverse() method.
This commit is contained in:
parent
463325c0c6
commit
3ef1ab02c6
2 changed files with 29 additions and 25 deletions
|
|
@ -285,9 +285,7 @@ void AudioSampleBuffer::applyGainRamp (const int channel,
|
|||
}
|
||||
}
|
||||
|
||||
void AudioSampleBuffer::applyGain (const int startSample,
|
||||
const int numSamples,
|
||||
const float gain) noexcept
|
||||
void AudioSampleBuffer::applyGain (int startSample, int numSamples, float gain) noexcept
|
||||
{
|
||||
for (int i = 0; i < numChannels; ++i)
|
||||
applyGain (i, startSample, numSamples, gain);
|
||||
|
|
@ -298,10 +296,8 @@ void AudioSampleBuffer::applyGain (const float gain) noexcept
|
|||
applyGain (0, size, gain);
|
||||
}
|
||||
|
||||
void AudioSampleBuffer::applyGainRamp (const int startSample,
|
||||
const int numSamples,
|
||||
const float startGain,
|
||||
const float endGain) noexcept
|
||||
void AudioSampleBuffer::applyGainRamp (int startSample, int numSamples,
|
||||
float startGain, float endGain) noexcept
|
||||
{
|
||||
for (int i = 0; i < numChannels; ++i)
|
||||
applyGainRamp (i, startSample, numSamples, startGain, endGain);
|
||||
|
|
@ -399,11 +395,9 @@ void AudioSampleBuffer::copyFrom (const int destChannel,
|
|||
jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size);
|
||||
|
||||
if (numSamples > 0)
|
||||
{
|
||||
FloatVectorOperations::copy (channels [destChannel] + destStartSample,
|
||||
source.channels [sourceChannel] + sourceStartSample,
|
||||
numSamples);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSampleBuffer::copyFrom (const int destChannel,
|
||||
|
|
@ -416,11 +410,7 @@ void AudioSampleBuffer::copyFrom (const int destChannel,
|
|||
jassert (source != nullptr);
|
||||
|
||||
if (numSamples > 0)
|
||||
{
|
||||
FloatVectorOperations::copy (channels [destChannel] + destStartSample,
|
||||
source,
|
||||
numSamples);
|
||||
}
|
||||
FloatVectorOperations::copy (channels [destChannel] + destStartSample, source, numSamples);
|
||||
}
|
||||
|
||||
void AudioSampleBuffer::copyFrom (const int destChannel,
|
||||
|
|
@ -482,6 +472,21 @@ void AudioSampleBuffer::copyFromWithRamp (const int destChannel,
|
|||
}
|
||||
}
|
||||
|
||||
void AudioSampleBuffer::reverse (int channel, int startSample, int numSamples) const noexcept
|
||||
{
|
||||
jassert (isPositiveAndBelow (channel, numChannels));
|
||||
jassert (startSample >= 0 && startSample + numSamples <= size);
|
||||
|
||||
std::reverse (channels[channel] + startSample,
|
||||
channels[channel] + startSample + numSamples);
|
||||
}
|
||||
|
||||
void AudioSampleBuffer::reverse (int startSample, int numSamples) const noexcept
|
||||
{
|
||||
for (int i = 0; i < numChannels; ++i)
|
||||
reverse (i, startSample, numSamples);
|
||||
}
|
||||
|
||||
void AudioSampleBuffer::findMinMax (const int channel,
|
||||
const int startSample,
|
||||
int numSamples,
|
||||
|
|
@ -508,8 +513,7 @@ float AudioSampleBuffer::getMagnitude (const int channel,
|
|||
return jmax (mn, -mn, mx, -mx);
|
||||
}
|
||||
|
||||
float AudioSampleBuffer::getMagnitude (const int startSample,
|
||||
const int numSamples) const noexcept
|
||||
float AudioSampleBuffer::getMagnitude (int startSample, int numSamples) const noexcept
|
||||
{
|
||||
float mag = 0.0f;
|
||||
|
||||
|
|
|
|||
|
|
@ -107,19 +107,16 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Returns the number of channels of audio data that this buffer contains.
|
||||
|
||||
@see getSampleData
|
||||
*/
|
||||
int getNumChannels() const noexcept { return numChannels; }
|
||||
|
||||
/** Returns the number of samples allocated in each of the buffer's channels.
|
||||
|
||||
@see getSampleData
|
||||
*/
|
||||
int getNumSamples() const noexcept { return size; }
|
||||
|
||||
/** Returns a pointer one of the buffer's channels.
|
||||
|
||||
For speed, this doesn't check whether the channel number is out of range,
|
||||
so be careful when using it!
|
||||
*/
|
||||
|
|
@ -409,23 +406,26 @@ public:
|
|||
float& minVal,
|
||||
float& maxVal) const noexcept;
|
||||
|
||||
/** Finds the highest absolute sample value within a region of a channel.
|
||||
*/
|
||||
/** Finds the highest absolute sample value within a region of a channel. */
|
||||
float getMagnitude (int channel,
|
||||
int startSample,
|
||||
int numSamples) const noexcept;
|
||||
|
||||
/** Finds the highest absolute sample value within a region on all channels.
|
||||
*/
|
||||
/** Finds the highest absolute sample value within a region on all channels. */
|
||||
float getMagnitude (int startSample,
|
||||
int numSamples) const noexcept;
|
||||
|
||||
/** Returns the root mean squared level for a region of a channel.
|
||||
*/
|
||||
/** Returns the root mean squared level for a region of a channel. */
|
||||
float getRMSLevel (int channel,
|
||||
int startSample,
|
||||
int numSamples) const noexcept;
|
||||
|
||||
/** Reverses a part of a channel. */
|
||||
void reverse (int channel, int startSample, int numSamples) const noexcept;
|
||||
|
||||
/** Reverses a part of the buffer. */
|
||||
void reverse (int startSample, int numSamples) const noexcept;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
int numChannels, size;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue