本文整理汇总了C++中AudioSampleBuffer::getArrayOfWritePointers方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioSampleBuffer::getArrayOfWritePointers方法的具体用法?C++ AudioSampleBuffer::getArrayOfWritePointers怎么用?C++ AudioSampleBuffer::getArrayOfWritePointers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioSampleBuffer
的用法示例。
在下文中一共展示了AudioSampleBuffer::getArrayOfWritePointers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processBlock
void JuceVibAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
if (bypassed) {
processBlockBypassed(buffer, midiMessages);
}
else {
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();
//Set parameters
lfoFreq = freqParam->get();
lfoAmp = depthParam->get();
Vib->setFreq(lfoFreq*maxFreq);
Vib->setDepth(lfoAmp);
// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear(i, 0, buffer.getNumSamples());
float** ppfWriteBuffer = buffer.getArrayOfWritePointers();
Vib->process(ppfWriteBuffer, ppfWriteBuffer, buffer.getNumSamples());
}
}
示例2: it
void Tunefish4AudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
MidiBuffer::Iterator it(midiMessages);
MidiMessage midiMessage;
eU32 messageOffset = 0;
eU32 requestedLen = buffer.getNumSamples();
eU32 sampleRate = (eU32)getSampleRate();
if (sampleRate > 0)
synth->sampleRate = sampleRate;
for (int i = 0; i < getNumOutputChannels(); ++i)
{
buffer.clear(i, 0, buffer.getNumSamples());
}
if (buffer.getNumChannels() == 2)
{
eU32 len = requestedLen;
eF32 **signal = buffer.getArrayOfWritePointers();
eF32 *destL = signal[0];
eF32 *destR = signal[1];
while(len)
{
if (!adapterDataAvailable)
{
csSynth.enter();
eMemSet(adapterBuffer[0], 0, TF_BUFFERSIZE * sizeof(eF32));
eMemSet(adapterBuffer[1], 0, TF_BUFFERSIZE * sizeof(eF32));
processEvents(midiMessages, messageOffset, TF_BUFFERSIZE);
eTfInstrumentProcess(*synth, *tf, adapterBuffer, TF_BUFFERSIZE);
messageOffset += TF_BUFFERSIZE;
adapterDataAvailable = TF_BUFFERSIZE;
csSynth.exit();
}
eF32 *srcL = &adapterBuffer[0][TF_BUFFERSIZE - adapterDataAvailable];
eF32 *srcR = &adapterBuffer[1][TF_BUFFERSIZE - adapterDataAvailable];
while (len && adapterDataAvailable)
{
*destL++ += *srcL++;
*destR++ += *srcR++;
len--;
adapterDataAvailable--;
}
}
}
processEvents(midiMessages, messageOffset, requestedLen);
}
示例3: readMaxLevels
void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples,
Range<float>* const results, const int channelsToRead)
{
jassert (channelsToRead > 0 && channelsToRead <= numChannels);
if (numSamples <= 0)
{
for (int i = 0; i < channelsToRead; ++i)
results[i] = Range<float>();
return;
}
const int bufferSize = (int) jmin (numSamples, (int64) 4096);
AudioSampleBuffer tempSampleBuffer ((int) channelsToRead, bufferSize);
float* const* const floatBuffer = tempSampleBuffer.getArrayOfWritePointers();
int* const* intBuffer = reinterpret_cast<int* const*> (floatBuffer);
bool isFirstBlock = true;
while (numSamples > 0)
{
const int 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
{
Range<int> 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;
}
}
示例4: processBuffers
void processBuffers()
{
if (recorder != nullptr)
recorder->readNextBlock (inputBuffer, *this);
{
const ScopedLock sl (callbackLock);
if (callback != nullptr)
callback->audioDeviceIOCallback (numInputChannels > 0 ? inputBuffer.getArrayOfReadPointers() : nullptr, numInputChannels,
numOutputChannels > 0 ? outputBuffer.getArrayOfWritePointers() : nullptr, numOutputChannels,
actualBufferSize);
else
outputBuffer.clear();
}
if (player != nullptr)
player->writeBuffer (outputBuffer, *this);
}
示例5: process
void AudioResamplingNode::process(AudioSampleBuffer& buffer,
MidiBuffer& midiMessages)
{
int nSamps = buffer.getNumSamples(); // WRONG!!!!
int valuesNeeded;
if (destBufferIsTempBuffer)
{
ratio = float(nSamps) / float(buffer.getNumSamples());
valuesNeeded = buffer.getNumSamples();
}
else
{
ratio = sourceBufferSampleRate / destBufferSampleRate;
valuesNeeded = (int) buffer.getNumSamples() / ratio;
//std::cout << std::endl;
//std::cout << "Ratio: " << ratio << std::endl;
//std::cout << "Values needed: " << valuesNeeded << std::endl;
}
if (lastRatio != ratio)
{
updateFilter();
lastRatio = ratio;
}
if (ratio > 1.0001)
{
// pre-apply filter before downsampling
filter->process(nSamps, buffer.getArrayOfWritePointers());
}
// initialize variables
tempBuffer->clear();
int sourceBufferPos = 0;
int sourceBufferSize = buffer.getNumSamples();
float subSampleOffset = 0.0;
int nextPos = (sourceBufferPos + 1) % sourceBufferSize;
int tempBufferPos;
//int totalSamples = 0;
// code modified from "juce_ResamplingAudioSource.cpp":
for (tempBufferPos = 0; tempBufferPos < valuesNeeded; tempBufferPos++)
{
float gain = 1.0;
float alpha = (float) subSampleOffset;
float invAlpha = 1.0f - alpha;
for (int channel = 0; channel < buffer.getNumChannels(); ++channel)
{
tempBuffer->addFrom(channel, // destChannel
tempBufferPos, // destSampleOffset
buffer, // source
channel, // sourceChannel
sourceBufferPos,// sourceSampleOffset
1, // number of samples
invAlpha*gain); // gain to apply to source
tempBuffer->addFrom(channel, // destChannel
tempBufferPos, // destSampleOffset
buffer, // source
channel, // sourceChannel
nextPos, // sourceSampleOffset
1, // number of samples
alpha*gain); // gain to apply to source
}
subSampleOffset += ratio;
while (subSampleOffset >= 1.0)
{
if (++sourceBufferPos >= sourceBufferSize)
sourceBufferPos = 0;
nextPos = (sourceBufferPos + 1) % sourceBufferSize;
subSampleOffset -= 1.0;
}
}
// std::cout << sourceBufferPos << " " << tempBufferPos << std::endl;
if (ratio < 0.9999)
{
filter->process(tempBufferPos, tempBuffer->getArrayOfWritePointers());
// apply the filter after upsampling
///////filter->process (totalSamples, buffer.getArrayOfChannels());
}
//.........这里部分代码省略.........
示例6: readMaxLevels
void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples,
float& lowestLeft, float& highestLeft,
float& lowestRight, float& highestRight)
{
if (numSamples <= 0)
{
lowestLeft = 0;
lowestRight = 0;
highestLeft = 0;
highestRight = 0;
return;
}
const int bufferSize = (int) jmin (numSamples, (int64) 4096);
AudioSampleBuffer tempSampleBuffer ((int) numChannels, bufferSize);
float* const* const floatBuffer = tempSampleBuffer.getArrayOfWritePointers();
int* const* intBuffer = reinterpret_cast<int* const*> (floatBuffer);
if (usesFloatingPointData)
{
float lmin = 1.0e6f;
float lmax = -lmin;
float rmin = lmin;
float rmax = lmax;
while (numSamples > 0)
{
const int numToDo = (int) jmin (numSamples, (int64) bufferSize);
if (! read (intBuffer, 2, startSampleInFile, numToDo, false))
break;
numSamples -= numToDo;
startSampleInFile += numToDo;
getStereoMinAndMax (floatBuffer, (int) numChannels, numToDo, lmin, lmax, rmin, rmax);
}
lowestLeft = lmin;
highestLeft = lmax;
lowestRight = rmin;
highestRight = rmax;
}
else
{
int lmax = std::numeric_limits<int>::min();
int lmin = std::numeric_limits<int>::max();
int rmax = std::numeric_limits<int>::min();
int rmin = std::numeric_limits<int>::max();
while (numSamples > 0)
{
const int numToDo = (int) jmin (numSamples, (int64) bufferSize);
if (! read (intBuffer, 2, startSampleInFile, numToDo, false))
break;
numSamples -= numToDo;
startSampleInFile += numToDo;
getStereoMinAndMax (intBuffer, (int) numChannels, numToDo, lmin, lmax, rmin, rmax);
}
lowestLeft = lmin / (float) std::numeric_limits<int>::max();
highestLeft = lmax / (float) std::numeric_limits<int>::max();
lowestRight = rmin / (float) std::numeric_limits<int>::max();
highestRight = rmax / (float) std::numeric_limits<int>::max();
}
}
示例7: processBlock
void InstanceProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
for(int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i)
{
buffer.clear(i, 0, buffer.getNumSamples());
}
bool infos = false;
AudioPlayHead* playhead = getPlayHead();
if(playhead && m_patch_tie)
{
infos = playhead->getCurrentPosition(m_playinfos);
}
lock();
{
m_midi.clear();
if(infos)
{
m_playing_list.setFloat(0, m_playinfos.isPlaying);
m_playing_list.setFloat(1, m_playinfos.timeInSeconds);
sendMessageAnything(m_patch_tie, s_playing, m_playing_list);
m_measure_list.setFloat(0, m_playinfos.bpm);
m_measure_list.setFloat(1, m_playinfos.timeSigNumerator);
m_measure_list.setFloat(2, m_playinfos.timeSigDenominator);
m_measure_list.setFloat(3, m_playinfos.ppqPosition);
m_measure_list.setFloat(4, m_playinfos.ppqPositionOfLastBarStart);
sendMessageAnything(m_patch_tie, s_measure, m_measure_list);
}
for(size_t i = 0; i < m_parameters.size() && m_parameters[i].isValid(); ++i)
{
sendMessageFloat(m_parameters[i].getTie(), m_parameters[i].getValueNonNormalized());
}
MidiMessage message;
MidiBuffer::Iterator it(midiMessages);
int position = midiMessages.getFirstEventTime();
while(it.getNextEvent(message, position))
{
if(message.isNoteOnOrOff())
{
sendMidiNote(message.getChannel(), message.getNoteNumber(), message.getVelocity());
}
else if(message.isController())
{
sendMidiControlChange(message.getChannel(), message.getControllerNumber(), message.getControllerValue());
}
else if(message.isPitchWheel())
{
sendMidiPitchBend(message.getChannel(), message.getPitchWheelValue());
}
else if(message.isChannelPressure())
{
sendMidiAfterTouch(message.getChannel(), message.getChannelPressureValue());
}
else if(message.isAftertouch())
{
sendMidiPolyAfterTouch(message.getChannel(), message.getNoteNumber(), message.getAfterTouchValue());
}
else if(message.isProgramChange())
{
sendMidiProgramChange(message.getChannel(), message.getProgramChangeNumber());
}
}
}
midiMessages.clear();
performDsp(buffer.getNumSamples(),
getTotalNumInputChannels(), buffer.getArrayOfReadPointers(),
getTotalNumOutputChannels(), buffer.getArrayOfWritePointers());
midiMessages.swapWith(m_midi);
unlock();
}