当前位置: 首页>>代码示例>>C++>>正文


C++ AudioSampleBuffer::getNumSamples方法代码示例

本文整理汇总了C++中AudioSampleBuffer::getNumSamples方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioSampleBuffer::getNumSamples方法的具体用法?C++ AudioSampleBuffer::getNumSamples怎么用?C++ AudioSampleBuffer::getNumSamples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AudioSampleBuffer的用法示例。


在下文中一共展示了AudioSampleBuffer::getNumSamples方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processBlock

void JuceVibAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
	if (bypassed) {
		processBlockBypassed(buffer, midiMessages);
	}
	else {

		const int totalNumInputChannels = getTotalNumInputChannels();
		const int totalNumOutputChannels = getTotalNumOutputChannels();

		//Set parameters
		lfoFreq = freqParam->get();
		lfoAmp = depthParam->get();

		Vib->setFreq(lfoFreq*maxFreq);
		Vib->setDepth(lfoAmp);

		// In case we have more outputs than inputs, this code clears any output
		// channels that didn't contain input data, (because these aren't
		// guaranteed to be empty - they may contain garbage).
		// This is here to avoid people getting screaming feedback
		// when they first compile a plugin, but obviously you don't need to keep
		// this code if your algorithm always overwrites all the output channels.
		for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
			buffer.clear(i, 0, buffer.getNumSamples());

		float** ppfWriteBuffer = buffer.getArrayOfWritePointers();
		Vib->process(ppfWriteBuffer, ppfWriteBuffer, buffer.getNumSamples());
	}
}
开发者ID:gmhendler,项目名称:PluginDev,代码行数:30,代码来源:PluginProcessor.cpp

示例2: processBlock

void SoftSynthAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    MidiBuffer processedMidi;
    int time;
    MidiMessage m;
    
    for (MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);) {
        if (m.isNoteOn()) {
            m = MidiMessage::noteOn(m.getChannel(), m.getNoteNumber(), m.getVelocity());
            synth.keyPressed(m.getNoteNumber(), m.getVelocity());
        } else if (m.isNoteOff()) {
            m = MidiMessage::noteOff(m.getChannel(), m.getNoteNumber(), m.getVelocity());
            synth.keyReleased(m.getNoteNumber());
        }
        
        processedMidi.addEvent(m, time);
    }
    
    auto synthBuffer = synth.getNextBuffer(buffer.getNumSamples());
    float *leftData = buffer.getWritePointer(0);
    float *rightData = buffer.getWritePointer(1);
    for (int i = 0; i < buffer.getNumSamples(); ++i) {
        leftData[i] = synthBuffer[i];
        rightData[i] = synthBuffer[i];
    }
    
    midiMessages.swapWith(processedMidi);
}
开发者ID:tallen11,项目名称:polysynth-vst,代码行数:28,代码来源:PluginProcessor.cpp

示例3: handleIncomingMidiBuffer

void Pfm2AudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    handleIncomingMidiBuffer(midiMessages, buffer.getNumSamples());

    // Clear sound
    for (int i = 0; i < getNumOutputChannels(); ++i)
        buffer.clear (i, 0, buffer.getNumSamples());

    // dispatch realtime events to non realtime observer
    parameterSet.processRealtimeEvents();
    midiMessageCollector.removeNextBlockOfMessages(midiMessages,  buffer.getNumSamples());
    /*
    if (midiMessages.getNumEvents() > 0) {
        printf("processBlock : %d midi messages \n", midiMessages.getNumEvents());
    }
     */
    if (parametersToUpdate.size() > 0 ) {
		if (parametersToUpdateMutex.try_lock()) {
	        std::unordered_set<const char*> newSet;
			newSet.swap(parametersToUpdate);
			parametersToUpdateMutex.unlock();
			if (pfm2Editor) {
				pfm2Editor->updateUIWith(newSet);
			}
		}
    }
}
开发者ID:eriser,项目名称:preenfm2Controller,代码行数:27,代码来源:PluginProcessor.cpp

示例4: processBlock

void PitchestimatorpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    // In case we have more outputs than inputs, this code clears any output
    // channels that didn't contain input data
    for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
        buffer.clear (i, 0, buffer.getNumSamples());
 
    int bufsize = buffer.getNumSamples();
    
    //main process loop
    for (int channel = 0; channel < getNumInputChannels(); ++channel)
    {
        float* channelData = buffer.getWritePointer (channel);
        fft->processForward(channelData, fftData, bufsize, nFFT);
        buffer.applyGain (channel, 0, bufsize, gain);
    }
    for (int i=0; i<bufsize; i++) {
        X[i] = fft->cartopolRadius(fftData[i][0], fftData[i][1]);
    }
    
    HS->generateCost(X, f0Area, numberOfHarmonics, bufsize, f0AreaSize, getSampleRate(), nFFT);
    pitchEstimate = HS->estimatePitch(f0Area, f0AreaSize);
    
    pitchText = String (pitchEstimate, 1);

}
开发者ID:adamski,项目名称:Pitch-Estimator-Plugin,代码行数:26,代码来源:PluginProcessor.cpp

示例5: processBlock

void FilterGuiDemoAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    float numSamples = buffer.getNumSamples();
    float currentSampleRate = getSampleRate();
    
    //Handles filter being added onto an already playing audio track where some hosts will not call prepare to play method.
    if (filter1->getSampleRate() != currentSampleRate)
    {
        filter1->initializeFilter(currentSampleRate, defaultMinFilterFrequency, defaultMaxFilterFrequency);
    }
    
    // In case we have more outputs than inputs, this code clears any output
    // channels that didn't contain input data, (because these aren't
    // guaranteed to be empty - they may contain garbage).
    // I've added this to avoid people getting screaming feedback
    // when they first compile the plugin, but obviously you don't need to
    // this code if your algorithm already fills all the output channels.
    for (int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i)
        buffer.clear (i, 0, buffer.getNumSamples());

    // MAIN AUDIO PROCESSING BLOCK. PROCESS FILTER TWICE FOR STEREO CHANNELS
    for (int channel = 0; channel < getTotalNumInputChannels(); ++channel)
    {
        const float* input = buffer.getReadPointer(channel);
        float* output = buffer.getWritePointer (channel);
        
        for (int i = 0; i < numSamples; i++)
        {
            output[i] = filter1->processFilter(input[i], channel);
        }
    }
}
开发者ID:JoshMarler,项目名称:filter-gui-demo,代码行数:32,代码来源:PluginProcessor.cpp

示例6: process

void AudioNode::process(AudioSampleBuffer &buffer, 
                            MidiBuffer &midiMessages,
                            int& nSamples)
{

	buffer.clear(0,0,buffer.getNumSamples());
	buffer.clear(1,0,buffer.getNumSamples());

	for (int n = 0; n < leftChan.size(); n++) {
		buffer.addFrom(0,  // destination channel
					   0,  // destination start sample
					   buffer,      // source
					   leftChan[n]+2, // source channel
					   0,           // source start sample
					   buffer.getNumSamples(), //  number of samples
					   volume       // gain to apply
					   );
	}
	
	for (int n = 0; n < rightChan.size(); n++) {
		buffer.addFrom(1,  // destination channel
					   0,  // destination start sample
					   buffer,      // source
					   rightChan[n]+2, // source channel
					   0,           // source start sample
					   buffer.getNumSamples(), //  number of samples
					   volume       // gain to apply
					   );
	}
}
开发者ID:maureddino,项目名称:arte-ephys,代码行数:30,代码来源:AudioNode.cpp

示例7: 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);
}
开发者ID:soundradix,项目名称:JUCE,代码行数:28,代码来源:IAAEffectProcessor.cpp

示例8: writeBuffer

        void writeBuffer (const AudioSampleBuffer& buffer, Thread& thread)
        {
            jassert (buffer.getNumChannels() == bufferList.numChannels);
            jassert (buffer.getNumSamples() < bufferList.numSamples * bufferList.numBuffers);

            int offset = 0;
            int numSamples = buffer.getNumSamples();

            while (numSamples > 0)
            {
                int16* const destBuffer = bufferList.waitForFreeBuffer (thread);

                if (destBuffer == nullptr)
                    break;

                for (int i = 0; i < bufferList.numChannels; ++i)
                {
                    typedef AudioData::Pointer <AudioData::Int16,   AudioData::LittleEndian, AudioData::Interleaved, AudioData::NonConst> DstSampleType;
                    typedef AudioData::Pointer <AudioData::Float32, AudioData::NativeEndian, AudioData::NonInterleaved, AudioData::Const> SrcSampleType;

                    DstSampleType dstData (destBuffer + i, bufferList.numChannels);
                    SrcSampleType srcData (buffer.getSampleData (i, offset));
                    dstData.convertSamples (srcData, bufferList.numSamples);
                }

                check ((*playerBufferQueue)->Enqueue (playerBufferQueue, destBuffer, bufferList.getBufferSizeBytes()));
                bufferList.bufferSent();

                numSamples -= bufferList.numSamples;
                offset += bufferList.numSamples;
            }
        }
开发者ID:oeberhard,项目名称:BAVSN,代码行数:32,代码来源:juce_android_OpenSL.cpp

示例9: processBlock

void AudioFilterAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    // This is the place where you'd normally do the guts of your plugin's
    // audio processing...
    for (int channel = 0; channel < getNumInputChannels(); ++channel)
    {
        float* channelData = buffer.getSampleData (channel);

		for (int i = 0; i < buffer.getNumSamples(); i++)
		{
			//channelData[i] = atan(channelData[i]);
			if (channelData[i] > cutoff)
				channelData[i] = cutoff;
		}

        // ..do something to the data...
    }

    // 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, buffer.getNumSamples());
    }
}
开发者ID:robertgroarke,项目名称:CSC344,代码行数:26,代码来源:PluginProcessor.cpp

示例10:

void Csc344filterAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    const int numSamples = buffer.getNumSamples();
    int channel, dp = 0;
    
    // This is the place where you'd normally do the guts of your plugin's
    // audio processing...
    
    for (channel = 0; channel < getNumInputChannels(); ++channel)
    {
        float* channelData = buffer.getSampleData (channel);
        float* delayData = delayBuffer.getSampleData (jmin (channel, delayBuffer.getNumChannels() - 1));
        dp = delayPosition;
        
        for (int i = 0; i < numSamples; ++i)
        {
            const float in = channelData[i];
            channelData[i] += delayData[dp];
            delayData[dp] = (delayData[dp] + in) * delay;
            if (++dp >= delayBuffer.getNumSamples())
                dp = 0;
        }
    }

    // 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, buffer.getNumSamples());
    }
}
开发者ID:neobonzi,项目名称:CSC344,代码行数:32,代码来源:PluginProcessor.cpp

示例11: sizeof

void C74GenAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
	assureBufferSize(buffer.getNumSamples());
	
	// fill input buffers
	for (int i = 0; i < C74_GENPLUGIN::num_inputs(); i++) {
		if (i < getNumInputChannels()) {
			for (int j = 0; j < m_CurrentBufferSize; j++) {
				m_InputBuffers[i][j] = buffer.getReadPointer(i)[j];
			}
		} else {
			memset(m_InputBuffers[i], 0, m_CurrentBufferSize *  sizeof(double));
		}
	}
	
	// process audio
	C74_GENPLUGIN::perform(m_C74PluginState,
								  m_InputBuffers,
								  C74_GENPLUGIN::num_inputs(),
								  m_OutputBuffers,
								  C74_GENPLUGIN::num_outputs(),
								  buffer.getNumSamples());

	// fill output buffers
	for (int i = 0; i < getNumOutputChannels(); i++) {
		if (i < C74_GENPLUGIN::num_outputs()) {
			for (int j = 0; j < buffer.getNumSamples(); j++) {
				buffer.getWritePointer(i)[j] = m_OutputBuffers[i][j];
			}
		} else {
			buffer.clear (i, 0, buffer.getNumSamples());
		}
	}
}
开发者ID:drumgod24,项目名称:gen-plugin-export,代码行数:34,代码来源:PluginProcessor.cpp

示例12: processBlock

    void processBlock (AudioSampleBuffer& buffer, MidiBuffer&) override
    {
        for (int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i)
            buffer.clear (i, 0, buffer.getNumSamples());

        AudioSampleBuffer mainInputOutput = busArrangement.getBusBuffer (buffer, true, 0);
        AudioSampleBuffer sideChainInput  = busArrangement.getBusBuffer (buffer, true, 1);

        float alphaCopy = *alpha;
        float thresholdCopy = *threshold;

        for (int j = 0; j < buffer.getNumSamples(); ++j)
        {
            float mixedSamples = 0.0f;
            for (int i = 0; i < sideChainInput.getNumChannels(); ++i)
                mixedSamples += sideChainInput.getReadPointer (i) [j];

            mixedSamples /= static_cast<float> (sideChainInput.getNumChannels());
            lowPassCoeff = (alphaCopy * lowPassCoeff) + ((1.0f - alphaCopy) * mixedSamples);

            if (lowPassCoeff >= thresholdCopy)
                sampleCountDown = (int) getSampleRate();

            // very in-effective way of doing this
            for (int i = 0; i < mainInputOutput.getNumChannels(); ++i)
                *mainInputOutput.getWritePointer (i, j) = sampleCountDown > 0 ? *mainInputOutput.getReadPointer (i, j) : 0.0f;

            if (sampleCountDown > 0)
                --sampleCountDown;
        }
    }
开发者ID:cameronbroe,项目名称:helm,代码行数:31,代码来源:NoiseGate.cpp

示例13: processBlock

void TestFilterAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    const int totalNumInputChannels  = getTotalNumInputChannels();
    const int totalNumOutputChannels = getTotalNumOutputChannels();

    // In case we have more outputs than inputs, this code clears any output
    // channels that didn't contain input data, (because these aren't
    // guaranteed to be empty - they may contain garbage).
    // This is here to avoid people getting screaming feedback
    // when they first compile a plugin, but obviously you don't need to keep
    // this code if your algorithm always overwrites all the output channels.
    for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
        buffer.clear (i, 0, buffer.getNumSamples());

    // This is the place where you'd normally do the guts of your plugin's
    // audio processing...
    
    M2S.process(buffer);
    
    _corrCoeff = corrCoeff.findCorrCoeff(buffer.getArrayOfReadPointers(), buffer.getNumSamples());
    pPPM->ppmProcess( buffer.getArrayOfReadPointers(), buffer.getNumSamples());
    
    for (int channel=0; channel < buffer.getNumChannels(); channel++) {
        _peakVal[channel] = pPPM->getPeak(channel);
    }
    
}
开发者ID:RitheshKumar,项目名称:StereoPluginV2,代码行数:27,代码来源:PluginProcessor.cpp

示例14: readNextBlock

        void readNextBlock (AudioSampleBuffer& buffer, Thread& thread)
        {
            jassert (buffer.getNumChannels() == bufferList.numChannels);
            jassert (buffer.getNumSamples() < bufferList.numSamples * bufferList.numBuffers);
            jassert ((buffer.getNumSamples() % bufferList.numSamples) == 0);

            int offset = 0;
            int numSamples = buffer.getNumSamples();

            while (numSamples > 0)
            {
                int16* const srcBuffer = bufferList.waitForFreeBuffer (thread);

                if (srcBuffer == nullptr)
                    break;

                for (int i = 0; i < bufferList.numChannels; ++i)
                {
                    typedef AudioData::Pointer <AudioData::Float32, AudioData::NativeEndian, AudioData::NonInterleaved, AudioData::NonConst> DstSampleType;
                    typedef AudioData::Pointer <AudioData::Int16,   AudioData::LittleEndian, AudioData::Interleaved, AudioData::Const> SrcSampleType;

                    DstSampleType dstData (buffer.getSampleData (i, offset));
                    SrcSampleType srcData (srcBuffer + i, bufferList.numChannels);
                    dstData.convertSamples (srcData, bufferList.numSamples);
                }

                enqueueBuffer (srcBuffer);

                numSamples -= bufferList.numSamples;
                offset += bufferList.numSamples;
            }
        }
开发者ID:oeberhard,项目名称:BAVSN,代码行数:32,代码来源:juce_android_OpenSL.cpp

示例15: processBlock

void JuceDemoPluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    const int numSamples = buffer.getNumSamples();
    keyboardState.processNextMidiBuffer (midiMessages, 0, numSamples, true);
    synth.renderNextBlock (buffer, midiMessages, 0, numSamples);


    for (int channel = 0; channel < getNumInputChannels(); channel++)
    {
        float* channelData = buffer.getWritePointer (channel);
        std::deque<Particle> &particles = m_particles[channel];
        for(int sample = 0; sample < numSamples; sample++) {
            for(Particle& p : particles) {
                p.velocity() += p.acceleration() * 0.1 * 0.5;
                p.position() += p.velocity() * 0.1;
            }

            Particle* pFix = m_fixedParticle[channel];
            Particle* pOut = m_outputParticle[channel];
            Particle* pIn = m_inputParticle[channel];

            for(Particle& p : particles) {
                p.acceleration() = Vector3D(0.0, 0.0, 0.0);
            }

            pFix->position() = Vector3D(0.0, 0.0, 0.0);
            pIn->position() = Vector3D(channelData[sample] + m_particleCount + offset->getValue(), 0.0, 0.0);

            for(Spring& spring : m_springs[channel]) {
                Particle* pa = spring.from;
                Particle* pb = spring.to;

                double diff = pb->position().x - pa->position().x;
                double r = fabs(diff);

                double d = spring.d;
                double k = spring.k*springConstant->getValue();

                Vector3D force = Vector3D(k*(r-d), 0.0, 0.0);
                pa->acceleration() += force;
                pb->acceleration() -= force;
            }

            for(Particle& p : particles) {
                p.velocity() *= velocityFactor->getValue();
                p.velocity() += p.acceleration() * 0.1 * 0.5;
            }

            channelData[sample] = pOut->position().x - 1.0;
        }
    }

    // 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, buffer.getNumSamples());
}
开发者ID:dragly,项目名称:spring-all-year,代码行数:58,代码来源:PluginProcessor.cpp


注:本文中的AudioSampleBuffer::getNumSamples方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。