本文整理汇总了C++中AudioBuffer::getArrayOfWritePointers方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioBuffer::getArrayOfWritePointers方法的具体用法?C++ AudioBuffer::getArrayOfWritePointers怎么用?C++ AudioBuffer::getArrayOfWritePointers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioBuffer
的用法示例。
在下文中一共展示了AudioBuffer::getArrayOfWritePointers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: 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;
}
示例3: 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);
}
示例4: readMaxLevels
void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples,
Range<float>* const results, const int channelsToRead)
{
jassert (channelsToRead > 0 && channelsToRead <= (int) numChannels);
if (numSamples <= 0)
{
for (int i = 0; i < channelsToRead; ++i)
results[i] = Range<float>();
return;
}
auto bufferSize = (int) jmin (numSamples, (int64) 4096);
AudioBuffer<float> tempSampleBuffer ((int) channelsToRead, bufferSize);
auto floatBuffer = tempSampleBuffer.getArrayOfWritePointers();
auto intBuffer = reinterpret_cast<int* const*> (floatBuffer);
bool isFirstBlock = true;
while (numSamples > 0)
{
auto numToDo = (int) jmin (numSamples, (int64) bufferSize);
if (! read (intBuffer, channelsToRead, startSampleInFile, numToDo, false))
break;
for (int i = 0; i < channelsToRead; ++i)
{
Range<float> r;
if (usesFloatingPointData)
{
r = FloatVectorOperations::findMinAndMax (floatBuffer[i], numToDo);
}
else
{
auto intRange = Range<int>::findMinAndMax (intBuffer[i], numToDo);
r = Range<float> (intRange.getStart() / (float) std::numeric_limits<int>::max(),
intRange.getEnd() / (float) std::numeric_limits<int>::max());
}
results[i] = isFirstBlock ? r : results[i].getUnionWith (r);
}
isFirstBlock = false;
numSamples -= numToDo;
startSampleInFile += numToDo;
}
}