本文整理汇总了C++中AudioBuffer::applyGain方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioBuffer::applyGain方法的具体用法?C++ AudioBuffer::applyGain怎么用?C++ AudioBuffer::applyGain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioBuffer
的用法示例。
在下文中一共展示了AudioBuffer::applyGain方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyGain
void JuceDemoPluginAudioProcessor::applyGain (AudioBuffer<FloatType>& buffer, AudioBuffer<FloatType>& delayBuffer)
{
ignoreUnused (delayBuffer);
const float gainLevel = *gainParam;
for (int channel = 0; channel < getNumInputChannels(); ++channel)
buffer.applyGain (channel, 0, buffer.getNumSamples(), gainLevel);
}
示例2: fillWithUrgent
void JackLayer::fillWithUrgent(AudioBuffer &buffer, size_t samplesToGet)
{
// Urgent data (dtmf, incoming call signal) come first.
samplesToGet = std::min(samplesToGet, hardwareBufferSize_);
buffer.resize(samplesToGet);
urgentRingBuffer_.get(buffer, RingBufferPool::DEFAULT_ID);
buffer.applyGain(isPlaybackMuted_ ? 0.0 : playbackGain_);
// Consume the regular one as well (same amount of samples)
Manager::instance().getRingBufferPool().discard(samplesToGet, RingBufferPool::DEFAULT_ID);
}
示例3: audioPlaybackFillWithVoice
size_t OpenSLLayer::audioPlaybackFillWithVoice(AudioBuffer &buffer)
{
RingBufferPool &mainBuffer = Manager::instance().getRingBufferPool();
size_t got = mainBuffer.getAvailableData(buffer, RingBufferPool::DEFAULT_ID);
buffer.resize(got);
buffer.applyGain(isPlaybackMuted_ ? 0.0 : playbackGain_);
if (audioFormat_.sample_rate != mainBuffer.getInternalSamplingRate()) {
DEBUG("OpenSLLayer::audioPlaybackFillWithVoice sample_rate != mainBuffer.getInternalSamplingRate() \n");
AudioBuffer out(buffer, false);
out.setSampleRate(audioFormat_.sample_rate);
resampler_->resample(buffer, out);
buffer = out;
}
return buffer.size();
}
示例4: fillWithVoice
void JackLayer::fillWithVoice(AudioBuffer &buffer, size_t samplesAvail)
{
RingBufferPool &mainBuffer = Manager::instance().getRingBufferPool();
buffer.resize(samplesAvail);
mainBuffer.getData(buffer, RingBufferPool::DEFAULT_ID);
buffer.applyGain(isPlaybackMuted_ ? 0.0 : playbackGain_);
if (audioFormat_.sample_rate != (unsigned) mainBuffer.getInternalSamplingRate()) {
RING_DBG("fillWithVoice sample_rate != mainBuffer.getInternalSamplingRate() \n");
AudioBuffer out(buffer, false);
out.setSampleRate(audioFormat_.sample_rate);
resampler_->resample(buffer, out);
buffer = out;
}
}
示例5: audioCaptureFillBuffer
void OpenSLLayer::audioCaptureFillBuffer(AudioBuffer &buffer)
{
RingBufferPool &mbuffer = Manager::instance().getRingBufferPool();
const AudioFormat mainBufferFormat = mbuffer.getInternalAudioFormat();
const bool resample = mainBufferFormat.sample_rate != audioFormat_.sample_rate;
buffer.applyGain(isCaptureMuted_ ? 0.0 : captureGain_);
if (resample) {
int outSamples = buffer.frames() * (static_cast<double>(audioFormat_.sample_rate) / mainBufferFormat.sample_rate);
AudioBuffer out(outSamples, mainBufferFormat);
resampler_->resample(buffer, out);
dcblocker_.process(out);
mainRingBuffer_->put(out);
} else {
dcblocker_.process(buffer);
mainRingBuffer_->put(buffer);
}
}
示例6: processBlock
void PolyWavegeneratorProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiBuffer)
{
// clear all the midibuffers of the voices because they still contain the events from the last process Block
for(int index = 0; index < voices.size(); index++)
{
voices[index]->clearMidiBuffer();
}
// Midi and Voice Handler this is not correct yet i need to watch out for different note ons of the same note in one buffer and other stuff
if(takesMidi && !midiBuffer.isEmpty())
{
MidiMessage& message1 = *new MidiMessage();
ScopedPointer<MidiBuffer::Iterator> iterator = new MidiBuffer::Iterator(midiBuffer);
int sampleInBuffer = 0;
while(iterator->getNextEvent(message1, sampleInBuffer))
{
if(message1.isNoteOn())
{
// always take the first one and move it to the back => the oldest voice will be "overwritten"
voices[0]->setIsOn(true);
voices[0]->setMidiNote(message1.getNoteNumber());
voices[0]->addMidiEvent(message1, sampleInBuffer);
voices.move(0, voices.size()-1);
}
else if(message1.isNoteOff())
{
for(int index = 0; index < voices.size(); index++)
{
if(voices[index]->getMidiNote() == message1.getNoteNumber())
{
ScopedPointer<Voice> tempVoice = voices[index];
tempVoice->setIsOn(false);
tempVoice->addMidiEvent(message1, sampleInBuffer);
tempVoice->setMidiNote(-1); // this should be removed but just in case for now
break;
}
}
}
}
}
// Audio Handling of the voices
AudioBuffer<float> outBuffer = getBusBuffer(buffer, false, 0);
int numActive = 0; // eventually this could be a member variable
for(int index = 0; index < voices.size(); index++)
{
if(voices[index]->getIsOn())
{
numActive++;
voices[index]->clearAudioBuffer();
voices[index]->fillBufferEnvelope();
voices[index]->fillBufferAudio();
outBuffer.addFrom(0, 0, voices[index]->getOutBuffer(), 0, 0, outBuffer.getNumSamples());
}
}
outBuffer.applyGain(1.0f/numActive);
}
示例7: applyDryWetToBuffer
void DaalDelAudioProcessor::applyDryWetToBuffer(AudioBuffer<float>& buffer, const int channel, const int bufferLength, float* dryBuffer) {
// buffer.addFromWithRamp(channel, 0, dryBuffer, bufferLength, _delayDryWetGain, _delayDryWetGain); // If we're adding after delay
buffer.applyGain(channel, 0, bufferLength, _delayDryWetGain);
}