Esempio n. 1
0
void JuceDemoPluginAudioProcessor::process (AudioBuffer<FloatType>& buffer,
                                            MidiBuffer& midiMessages,
                                            AudioBuffer<FloatType>& delayBuffer)
{
    const int numSamples = buffer.getNumSamples();

    // apply our gain-change to the incoming data..
    applyGain (buffer, delayBuffer);

    // Now pass any incoming midi messages to our keyboard state object, and let it
    // add messages to the buffer if the user is clicking on the on-screen keys
    keyboardState.processNextMidiBuffer (midiMessages, 0, numSamples, true);

    // and now get our synth to process these midi events and generate its output.
    synth.renderNextBlock (buffer, midiMessages, 0, numSamples);

    // Apply our delay effect to the new output..
    applyDelay (buffer, delayBuffer);

    // In case we have more outputs than inputs, we'll clear any output
    // channels that didn't contain input data, (because these aren't
    // guaranteed to be empty - they may contain garbage).
    for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
        buffer.clear (i, 0, numSamples);

    // Now ask the host for the current time so we can store it to be displayed later...
    updateCurrentTimeInfoFromHost();
}
Esempio n. 2
0
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);
}