コード例 #1
0
 void processAudio(AudioBuffer &buffer){
   FloatArray left = buffer.getSamples(LEFT_CHANNEL);
   FloatArray right = buffer.getSamples(RIGHT_CHANNEL);
   leftBuffer->copyFrom(left);
   rightBuffer->copyFrom(right);
   leftPatch.processAudio(*leftBuffer);
   rightPatch.processAudio(*rightBuffer);
   left.copyFrom(*leftBuffer);
   right.copyFrom(*rightBuffer);
 }
コード例 #2
0
    void perform (AudioBuffer<FloatType>& buffer, MidiBuffer& midiMessages, AudioPlayHead* audioPlayHead)
    {
        auto numSamples = buffer.getNumSamples();
        auto maxSamples = renderingBuffer.getNumSamples();

        if (numSamples > maxSamples)
        {
            // being asked to render more samples than our buffers have, so slice things up...
            tempMIDI.clear();
            tempMIDI.addEvents (midiMessages, maxSamples, numSamples, -maxSamples);

            {
                AudioBuffer<FloatType> startAudio (buffer.getArrayOfWritePointers(), buffer.getNumChannels(), maxSamples);
                midiMessages.clear (maxSamples, numSamples);
                perform (startAudio, midiMessages, audioPlayHead);
            }

            AudioBuffer<FloatType> endAudio (buffer.getArrayOfWritePointers(), buffer.getNumChannels(), maxSamples, numSamples - maxSamples);
            perform (endAudio, tempMIDI, audioPlayHead);
            return;
        }

        currentAudioInputBuffer = &buffer;
        currentAudioOutputBuffer.setSize (jmax (1, buffer.getNumChannels()), numSamples);
        currentAudioOutputBuffer.clear();
        currentMidiInputBuffer = &midiMessages;
        currentMidiOutputBuffer.clear();

        {
            const Context context { renderingBuffer.getArrayOfWritePointers(), midiBuffers.begin(), audioPlayHead, numSamples };

            for (auto* op : renderOps)
                op->perform (context);
        }

        for (int i = 0; i < buffer.getNumChannels(); ++i)
            buffer.copyFrom (i, 0, currentAudioOutputBuffer, i, 0, numSamples);

        midiMessages.clear();
        midiMessages.addEvents (currentMidiOutputBuffer, 0, buffer.getNumSamples(), 0);
        currentAudioInputBuffer = nullptr;
    }
コード例 #3
0
// copy data from internal audio buffer to external audio buffer
void AverageLevelFiltered::copyTo(
    AudioBuffer<float> &destination,
    const int numberOfSamples)
{
    jassert(fftSampleBuffer_.getNumChannels() ==
            destination.getNumChannels());
    jassert(fftSampleBuffer_.getNumSamples() >=
            numberOfSamples);
    jassert(destination.getNumSamples() >=
            numberOfSamples);

    int numberOfChannels = fftSampleBuffer_.getNumChannels();

    // copy data to external buffer
    for (int channel = 0; channel < numberOfChannels; ++channel)
    {
        destination.copyFrom(channel, 0,
                             fftSampleBuffer_,
                             channel, 0,
                             numberOfSamples);
    }
}