本文整理汇总了C++中AudioBuffer::getNumChannels方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioBuffer::getNumChannels方法的具体用法?C++ AudioBuffer::getNumChannels怎么用?C++ AudioBuffer::getNumChannels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioBuffer
的用法示例。
在下文中一共展示了AudioBuffer::getNumChannels方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyDelay
void JuceDemoPluginAudioProcessor::applyDelay (AudioBuffer<FloatType>& buffer, AudioBuffer<FloatType>& delayBuffer)
{
const int numSamples = buffer.getNumSamples();
const float delayLevel = *delayParam;
int delayPos = 0;
for (int channel = 0; channel < getNumInputChannels(); ++channel)
{
FloatType* const channelData = buffer.getWritePointer (channel);
FloatType* const delayData = delayBuffer.getWritePointer (jmin (channel, delayBuffer.getNumChannels() - 1));
delayPos = delayPosition;
for (int i = 0; i < numSamples; ++i)
{
const FloatType in = channelData[i];
channelData[i] += delayData[delayPos];
delayData[delayPos] = (delayData[delayPos] + in) * delayLevel;
if (++delayPos >= delayBuffer.getNumSamples())
delayPos = 0;
}
}
delayPosition = delayPos;
}
示例2: processNextBlock
void Synthesiser::processNextBlock (AudioBuffer<floatType>& outputAudio,
const MidiBuffer& midiData,
int startSample,
int numSamples)
{
// must set the sample rate before using this!
jassert (sampleRate != 0);
const int targetChannels = outputAudio.getNumChannels();
MidiBuffer::Iterator midiIterator (midiData);
midiIterator.setNextSamplePosition (startSample);
bool firstEvent = true;
int midiEventPos;
MidiMessage m;
const ScopedLock sl (lock);
while (numSamples > 0)
{
if (! midiIterator.getNextEvent (m, midiEventPos))
{
if (targetChannels > 0)
renderVoices (outputAudio, startSample, numSamples);
return;
}
const int samplesToNextMidiMessage = midiEventPos - startSample;
if (samplesToNextMidiMessage >= numSamples)
{
if (targetChannels > 0)
renderVoices (outputAudio, startSample, numSamples);
handleMidiEvent (m);
break;
}
if (samplesToNextMidiMessage < ((firstEvent && ! subBlockSubdivisionIsStrict) ? 1 : minimumSubBlockSize))
{
handleMidiEvent (m);
continue;
}
firstEvent = false;
if (targetChannels > 0)
renderVoices (outputAudio, startSample, samplesToNextMidiMessage);
handleMidiEvent (m);
startSample += samplesToNextMidiMessage;
numSamples -= samplesToNextMidiMessage;
}
while (midiIterator.getNextEvent (m, midiEventPos))
handleMidiEvent (m);
}
示例3: processBlock
void processBlock (AudioBuffer<FloatType>& outputBuffer, int startSample, int numSamples)
{
if (angleDelta != 0.0)
{
if (tailOff > 0)
{
while (--numSamples >= 0)
{
const FloatType currentSample =
static_cast<FloatType> (std::sin (currentAngle) * level * tailOff);
for (int i = outputBuffer.getNumChannels(); --i >= 0;)
outputBuffer.addSample (i, startSample, currentSample);
currentAngle += angleDelta;
++startSample;
tailOff *= 0.99;
if (tailOff <= 0.005)
{
clearCurrentNote();
angleDelta = 0.0;
break;
}
}
}
else
{
while (--numSamples >= 0)
{
const FloatType currentSample = static_cast<FloatType> (std::sin (currentAngle) * level);
for (int i = outputBuffer.getNumChannels(); --i >= 0;)
outputBuffer.addSample (i, startSample, currentSample);
currentAngle += angleDelta;
++startSample;
}
}
}
}
示例4: isLooping
MemoryAudioSource::MemoryAudioSource (AudioBuffer<float>& bufferToUse, bool copyMemory, bool shouldLoop)
: isLooping (shouldLoop)
{
if (copyMemory)
buffer.makeCopyOf (bufferToUse);
else
buffer.setDataToReferTo (bufferToUse.getArrayOfWritePointers(),
bufferToUse.getNumChannels(),
bufferToUse.getNumSamples());
}
示例5: copyBufferToTemporaryLocation
//==============================================================================
void copyBufferToTemporaryLocation (const AudioBuffer<float>& buffer)
{
const SpinLock::ScopedLockType sl (processLock);
auto numChannels = buffer.getNumChannels() > 1 ? 2 : 1;
temporaryBuffer.setSize (numChannels, buffer.getNumSamples(), false, false, true);
for (auto channel = 0; channel < numChannels; ++channel)
temporaryBuffer.copyFrom (channel, 0, buffer, channel, 0, buffer.getNumSamples());
}
示例6: perform
void perform (AudioBuffer<FloatType>& buffer, MidiBuffer& midiMessages, AudioPlayHead* audioPlayHead)
{
auto numSamples = buffer.getNumSamples();
auto maxSamples = renderingBuffer.getNumSamples();
if (numSamples > maxSamples)
{
// being asked to render more samples than our buffers have, so slice things up...
tempMIDI.clear();
tempMIDI.addEvents (midiMessages, maxSamples, numSamples, -maxSamples);
{
AudioBuffer<FloatType> startAudio (buffer.getArrayOfWritePointers(), buffer.getNumChannels(), maxSamples);
midiMessages.clear (maxSamples, numSamples);
perform (startAudio, midiMessages, audioPlayHead);
}
AudioBuffer<FloatType> endAudio (buffer.getArrayOfWritePointers(), buffer.getNumChannels(), maxSamples, numSamples - maxSamples);
perform (endAudio, tempMIDI, audioPlayHead);
return;
}
currentAudioInputBuffer = &buffer;
currentAudioOutputBuffer.setSize (jmax (1, buffer.getNumChannels()), numSamples);
currentAudioOutputBuffer.clear();
currentMidiInputBuffer = &midiMessages;
currentMidiOutputBuffer.clear();
{
const Context context { renderingBuffer.getArrayOfWritePointers(), midiBuffers.begin(), audioPlayHead, numSamples };
for (auto* op : renderOps)
op->perform (context);
}
for (int i = 0; i < buffer.getNumChannels(); ++i)
buffer.copyFrom (i, 0, currentAudioOutputBuffer, i, 0, numSamples);
midiMessages.clear();
midiMessages.addEvents (currentMidiOutputBuffer, 0, buffer.getNumSamples(), 0);
currentAudioInputBuffer = nullptr;
}
示例7: renderNextBlock
void SynthesiserVoice::renderNextBlock (AudioBuffer<double>& outputBuffer,
int startSample, int numSamples)
{
AudioBuffer<double> subBuffer (outputBuffer.getArrayOfWritePointers(),
outputBuffer.getNumChannels(),
startSample, numSamples);
tempBuffer.makeCopyOf (subBuffer, true);
renderNextBlock (tempBuffer, 0, numSamples);
subBuffer.makeCopyOf (tempBuffer, true);
}
示例8: writeFromAudioSampleBuffer
bool AudioFormatWriter::writeFromAudioSampleBuffer (const AudioBuffer<float>& source, int startSample, int numSamples)
{
auto numSourceChannels = source.getNumChannels();
jassert (startSample >= 0 && startSample + numSamples <= source.getNumSamples() && numSourceChannels > 0);
if (startSample == 0)
return writeFromFloatArrays (source.getArrayOfReadPointers(), numSourceChannels, numSamples);
const float* chans[256];
jassert ((int) numChannels < numElementsInArray (chans));
for (int i = 0; i < numSourceChannels; ++i)
chans[i] = source.getReadPointer (i, startSample);
chans[numSourceChannels] = nullptr;
return writeFromFloatArrays (chans, numSourceChannels, numSamples);
}
示例9: copyTo
// copy data from internal audio buffer to external audio buffer
void AverageLevelFiltered::copyTo(
AudioBuffer<float> &destination,
const int numberOfSamples)
{
jassert(fftSampleBuffer_.getNumChannels() ==
destination.getNumChannels());
jassert(fftSampleBuffer_.getNumSamples() >=
numberOfSamples);
jassert(destination.getNumSamples() >=
numberOfSamples);
int numberOfChannels = fftSampleBuffer_.getNumChannels();
// copy data to external buffer
for (int channel = 0; channel < numberOfChannels; ++channel)
{
destination.copyFrom(channel, 0,
fftSampleBuffer_,
channel, 0,
numberOfSamples);
}
}
示例10: copyFrom
// copy data from external audio buffer to internal audio buffer
void AverageLevelFiltered::copyFrom(
const AudioBuffer<float> &source,
const int numberOfSamples)
{
jassert(fftSampleBuffer_.getNumChannels() ==
source.getNumChannels());
jassert(fftSampleBuffer_.getNumSamples() ==
numberOfSamples);
int numberOfChannels = fftSampleBuffer_.getNumChannels();
// copy data to internal buffer
for (int channel = 0; channel < numberOfChannels; ++channel)
{
fftSampleBuffer_.copyFrom(channel, 0,
source,
channel, 0,
numberOfSamples);
}
// calculate loudness for all channels
calculateLoudness();
}