本文整理汇总了C++中AudioSampleBuffer::applyGainRamp方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioSampleBuffer::applyGainRamp方法的具体用法?C++ AudioSampleBuffer::applyGainRamp怎么用?C++ AudioSampleBuffer::applyGainRamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioSampleBuffer
的用法示例。
在下文中一共展示了AudioSampleBuffer::applyGainRamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processBlock
void IAAEffectProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer&)
{
const float gain = *parameters.getRawParameterValue ("gain");
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();
const int numSamples = buffer.getNumSamples();
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
// Apply the gain to the samples using a ramp to avoid discontinuities in
// the audio between processed buffers.
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
buffer.applyGainRamp (channel, 0, numSamples, previousGain, gain);
meterListeners.call (&IAAEffectProcessor::MeterListener::handleNewMeterValue,
channel,
buffer.getMagnitude (channel, 0, numSamples));
}
previousGain = gain;
// Now ask the host for the current time so we can store it to be displayed later.
updateCurrentTimeInfoFromHost (lastPosInfo);
}
示例2: 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);
}
}
示例3: audioDeviceIOCallback
void AudioSourcePlayer::audioDeviceIOCallback (const float** inputChannelData,
int totalNumInputChannels,
float** outputChannelData,
int totalNumOutputChannels,
int numSamples)
{
// these should have been prepared by audioDeviceAboutToStart()...
jassert (sampleRate > 0 && bufferSize > 0);
const ScopedLock sl (readLock);
if (source != nullptr)
{
int numActiveChans = 0, numInputs = 0, numOutputs = 0;
// messy stuff needed to compact the channels down into an array
// of non-zero pointers..
for (int i = 0; i < totalNumInputChannels; ++i)
{
if (inputChannelData[i] != nullptr)
{
inputChans [numInputs++] = inputChannelData[i];
if (numInputs >= numElementsInArray (inputChans))
break;
}
}
for (int i = 0; i < totalNumOutputChannels; ++i)
{
if (outputChannelData[i] != nullptr)
{
outputChans [numOutputs++] = outputChannelData[i];
if (numOutputs >= numElementsInArray (outputChans))
break;
}
}
if (numInputs > numOutputs)
{
// if there aren't enough output channels for the number of
// inputs, we need to create some temporary extra ones (can't
// use the input data in case it gets written to)
tempBuffer.setSize (numInputs - numOutputs, numSamples,
false, false, true);
for (int i = 0; i < numOutputs; ++i)
{
channels[numActiveChans] = outputChans[i];
memcpy (channels[numActiveChans], inputChans[i], sizeof (float) * (size_t) numSamples);
++numActiveChans;
}
for (int i = numOutputs; i < numInputs; ++i)
{
channels[numActiveChans] = tempBuffer.getSampleData (i - numOutputs, 0);
memcpy (channels[numActiveChans], inputChans[i], sizeof (float) * (size_t) numSamples);
++numActiveChans;
}
}
else
{
for (int i = 0; i < numInputs; ++i)
{
channels[numActiveChans] = outputChans[i];
memcpy (channels[numActiveChans], inputChans[i], sizeof (float) * (size_t) numSamples);
++numActiveChans;
}
for (int i = numInputs; i < numOutputs; ++i)
{
channels[numActiveChans] = outputChans[i];
zeromem (channels[numActiveChans], sizeof (float) * (size_t) numSamples);
++numActiveChans;
}
}
AudioSampleBuffer buffer (channels, numActiveChans, numSamples);
AudioSourceChannelInfo info (&buffer, 0, numSamples);
source->getNextAudioBlock (info);
for (int i = info.buffer->getNumChannels(); --i >= 0;)
buffer.applyGainRamp (i, info.startSample, info.numSamples, lastGain, gain);
lastGain = gain;
}
else
{
for (int i = 0; i < totalNumOutputChannels; ++i)
if (outputChannelData[i] != nullptr)
zeromem (outputChannelData[i], sizeof (float) * (size_t) numSamples);
}
}