void AudioProcessing::convolution( const juce::AudioSampleBuffer & a, const juce::AudioSampleBuffer & b, juce::AudioSampleBuffer & result ) { jassert( b.getNumChannels() == 1 ); int sampleSize = a.getNumSamples() + b.getNumSamples(); result.setSize( a.getNumChannels(), sampleSize ); const float * bSignal = b.getArrayOfReadPointers()[ 0 ]; for ( int ch = 0 ; ch < a.getNumChannels() ; ++ch ) { const float * aSignal = a.getArrayOfReadPointers()[ ch ]; float * res = result.getArrayOfWritePointers()[ ch ]; for ( int i = 0 ; i < sampleSize ; ++i ) { float sum = 0.f; for ( int j = 0 ; j < b.getNumSamples() ; ++j ) { int indexA = i - j; if ( ( indexA >= 0 ) && ( indexA < a.getNumSamples() ) ) sum += ( aSignal[indexA] * bSignal[j] ); } res[i] = sum; } } }
void AudioProcessing::TruePeak::process( const juce::AudioSampleBuffer & buffer ) { if (m_inputs.getNumSamples() >= numCoeffs) { // we have enough data from a previous process for ( int ch = 0 ; ch < buffer.getNumChannels() ; ++ch ) { m_inputs.copyFrom( ch, 0, &m_inputs.getArrayOfReadPointers()[ch][m_inputs.getNumSamples() - numCoeffs], numCoeffs ); } // resize if necessary if ( m_inputs.getNumSamples() != numCoeffs + buffer.getNumSamples() ) m_inputs.setSize( buffer.getNumChannels(), numCoeffs + buffer.getNumSamples(), true, false, true ); } else { // setSize clears buffer content too m_inputs.setSize( buffer.getNumChannels(), numCoeffs + buffer.getNumSamples(), false, true ); } // copy buffer to inputs with numCoefs offset for ( int ch = 0 ; ch < buffer.getNumChannels() ; ++ch ) { m_inputs.copyFrom( ch, numCoeffs, buffer, ch, 0, buffer.getNumSamples() ); } processPolyphase4AbsMax( m_inputs ); }
void AudioProcessing::TruePeak::processPolyphase4AbsMax( const juce::AudioSampleBuffer & buffer ) { // reset current tru peak m_truePeakValue = 0.f; memset( m_truePeakChannelArray, 0, sizeof( m_truePeakChannelArray ) ); int sampleSize = buffer.getNumSamples(); for ( int ch = 0 ; ch < buffer.getNumChannels() ; ++ch ) { const float * input = buffer.getArrayOfReadPointers()[ ch ]; for ( int i = 0 ; i < sampleSize ; ++i ) { for ( int j = 0 ; j < 4 ; ++j ) // number of polyphase filters { float absSample = fabs( polyphase4ComputeSum( input, i, buffer.getNumSamples(), filterPhaseArray[j], numCoeffs ) ); if ( absSample > m_truePeakValue ) m_truePeakValue = absSample; if ( absSample > m_truePeakChannelArray[ch] ) m_truePeakChannelArray[ch] = absSample; } } } }
/** Upsample by 4 signal (polyphase coefficients are for a 48 kHz signal). Processes 4 samples of the output signal in a single loop iteration. In one loop, each of the 4 processed samples is filtered with its own set of coefficients */ void AudioProcessing::polyphase4( const juce::AudioSampleBuffer & source, juce::AudioSampleBuffer & result ) { int sampleSize = source.getNumSamples(); result.setSize( source.getNumChannels(), 4*source.getNumSamples() + numCoeffs, false, false, true ); for ( int ch = 0 ; ch < source.getNumChannels() ; ++ch ) { const float * input = source.getArrayOfReadPointers()[ ch ]; float * res = result.getArrayOfWritePointers()[ ch ]; for ( int i = 0 ; i < sampleSize ; ++i ) { res[4*i] = polyphase4ComputeSum( input, i, source.getNumSamples(), filterPhase0, numCoeffs ); res[4*i+1] = polyphase4ComputeSum( input, i, source.getNumSamples(), filterPhase1, numCoeffs ); res[4*i+2] = polyphase4ComputeSum( input, i, source.getNumSamples(), filterPhase2, numCoeffs ); res[4*i+3] = polyphase4ComputeSum( input, i, source.getNumSamples(), filterPhase3, numCoeffs ); } } }
void JLickshotProcessorBase::process(juce::AudioSampleBuffer &buffer, juce::MidiBuffer &midiData, int numSamples) { keyState_.processNextMidiBuffer (midiData, 0, numSamples, true); synth_.renderNextBlock (buffer, midiData, 0, numSamples); if (delayIsActive_) { delay_.processBlock(buffer); } if(reverbIsActive_){ mVerb_.process(buffer.getArrayOfReadPointers(), buffer.getArrayOfWritePointers(), numSamples); } const int channels = jmin(buffer.getNumChannels(), delay_.getNumChannels()); for(int i = 0; i < channels; i++){ buffer.applyGainRamp (i, 0, numSamples, lastGain_, gain_); } lastGain_ = gain_; }