本文整理汇总了C++中AudioSampleBuffer::getRMSLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioSampleBuffer::getRMSLevel方法的具体用法?C++ AudioSampleBuffer::getRMSLevel怎么用?C++ AudioSampleBuffer::getRMSLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioSampleBuffer
的用法示例。
在下文中一共展示了AudioSampleBuffer::getRMSLevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processBlock
void OOTrack::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
updatePendingLooperState(OOServer::getInstance()->looperState.timeInSamples);
OOServer::getInstance()->updateGlobalTime(this,buffer.getNumSamples());
// RECORDING
if (*isRecording)
{
if(recordNeedle.get() + buffer.getNumSamples()> getSampleRate() * MAX_LOOP_LENGTH_S){
*shouldRecord = false;
*isRecording = false;
};
monoLoopSample.copyFrom(0, recordNeedle.get(), buffer, 0, 0, buffer.getNumSamples());
recordNeedle += buffer.getNumSamples();
rmsOut = (1-rmsAlpha)*rmsOut+ rmsAlpha*buffer.getRMSLevel(0, 0, buffer.getNumSamples());
}
else{
streamBipBuffer.writeBlock(buffer);
}
// PLAYING
// allow circular reading , although not sure that overflow need to be handled as its written with same block sizes than read
// we may need it if we start to use a different clock than looperState in OOServer that has a granularity of blockSize
// or if we dynamicly change blockSize
if (*isPlaying && recordNeedle.get()>0 && monoLoopSample.getNumSamples())
{
if ( (playNeedle + buffer.getNumSamples()) > recordNeedle.get())
{
//assert false for now see above
// jassert(false);
int firstSegmentLength = recordNeedle.get() - playNeedle;
int secondSegmentLength = buffer.getNumSamples() - firstSegmentLength;
buffer.copyFrom(0, 0, monoLoopSample, 0, playNeedle, firstSegmentLength);
buffer.copyFrom(0, 0, monoLoopSample, 0, 0, secondSegmentLength);
playNeedle = secondSegmentLength;
}else{
buffer.copyFrom(0, 0, monoLoopSample, 0, playNeedle, buffer.getNumSamples());
playNeedle += buffer.getNumSamples();
playNeedle %= recordNeedle.get();
}
buffer.applyGainRamp(0, 0, buffer.getNumSamples(), lastVolume,*volume);
lastVolume = *volume;
rmsOut = (1-rmsAlpha)*rmsOut+ rmsAlpha*buffer.getRMSLevel(0, 0, buffer.getNumSamples());
}
else{
// silence output buffer
buffer.applyGain(0, 0, buffer.getNumSamples(), 0);
}
}
示例2: processBlock
void PluginWrapper::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
//this processBlock merely processes a loaded VST.
if(!isBypassed)
{
vstInstance->processBlock(buffer,midiMessages);
}
if(isMuted)
buffer.clear();
rmsLeft = buffer.getRMSLevel(0, 0, buffer.getNumSamples());
rmsRight = buffer.getRMSLevel(1, 0, buffer.getNumSamples());
if(updateCounter==0)
sendActionMessage("rmsValues "+String(rmsLeft)+" "+String(rmsRight));
updateCounter++;
if(updateCounter>5)
updateCounter=0;
}
示例3: processBlock
void UGenPlugin::processBlock(AudioSampleBuffer& buffer,
MidiBuffer& /*midiMessages*/)
{
clearExtraChannels(buffer); // see below
int numSamples = buffer.getNumSamples();
if(inputBuffer.size() < numSamples)
inputBuffer = Buffer::newClear(numSamples, getNumInputChannels(), true);
for(int i = 0; i < getNumInputChannels(); i++)
{
float *inputData = inputBuffer.getData(i);
memcpy(inputData, buffer.getSampleData(i), numSamples * sizeof(float));
inputUGen.setInput(inputData, numSamples, i);
}
const int numOutputChannels = jmin(getNumOutputChannels(), outputUGen.getNumChannels());
for(int i = 0; i < numOutputChannels; i++)
{
outputUGen.setOutput(buffer.getSampleData(i), numSamples, i);
}
outputLock.enter();
outputUGen.prepareAndProcessBlock(numSamples, blockID, -1);
outputLock.exit();
// quick and dirty metering...
channelLevel0 += buffer.getRMSLevel(UGenAudio::Output0, 0, buffer.getNumSamples());
channelLevel1 += buffer.getRMSLevel(UGenAudio::Output1, 0, buffer.getNumSamples());
numMeasurements++;
if(numMeasurements >= 4)
{
setMeterLevel(UGenInterface::Meters::OutL, channelLevel0);
setMeterLevel(UGenInterface::Meters::OutR, channelLevel1);
channelLevel0 = channelLevel1 = 0.f;
numMeasurements = 0;
}
blockID += numSamples;
}