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


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

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


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

示例1: getNextAudioBlock

 virtual void getNextAudioBlock(const AudioSourceChannelInfo& bufferToFill)
 {
   AudioSampleBuffer* destBuffer = bufferToFill.buffer;
   const int len = std::min(bufferToFill.numSamples, static_cast<int>(_len-_pos));
   if (destBuffer)
   {
     for (int channel=0; channel<destBuffer->getNumChannels(); ++channel)
     {
       if (channel == 0 && _buffer)
       {
         destBuffer->copyFrom(channel, bufferToFill.startSample, _buffer+_pos, len);
         if (len < bufferToFill.numSamples)
         {
           const int startClear = bufferToFill.startSample + len;
           const int lenClear = bufferToFill.numSamples - len;
           destBuffer->clear(startClear, lenClear);
         }
       }
       else
       {
         destBuffer->clear(channel, bufferToFill.startSample, len);
       }
     }
   }
   _pos += len;
 }
开发者ID:0x4d52,项目名称:KlangFalter,代码行数:26,代码来源:IRAgent.cpp

示例2: run

    void run()
    {
        const int bufferSize = currentBufferSizeSamples;

        HANDLE events[2];
        int numEvents = 0;
        if (inputDevice != 0)
            events [numEvents++] = inputDevice->clientEvent;
        if (outputDevice != 0)
            events [numEvents++] = outputDevice->clientEvent;

        const int numInputBuffers = getActiveInputChannels().countNumberOfSetBits();
        const int numOutputBuffers = getActiveOutputChannels().countNumberOfSetBits();

        AudioSampleBuffer ins (jmax (1, numInputBuffers), bufferSize + 32);
        AudioSampleBuffer outs (jmax (1, numOutputBuffers), bufferSize + 32);
        float** const inputBuffers = ins.getArrayOfChannels();
        float** const outputBuffers = outs.getArrayOfChannels();
        ins.clear();

        while (! threadShouldExit())
        {
            const DWORD result = WaitForMultipleObjects (numEvents, events, true, 1000);

            if (result == WAIT_TIMEOUT)
                continue;

            if (threadShouldExit())
                break;

            if (inputDevice != 0)
                inputDevice->copyBuffers (inputBuffers, numInputBuffers, bufferSize, *this);

            // Make the callback..
            {
                const ScopedLock sl (startStopLock);

                if (isStarted)
                {
                    JUCE_TRY
                    {
                        callback->audioDeviceIOCallback ((const float**) inputBuffers,
                                                         numInputBuffers,
                                                         outputBuffers,
                                                         numOutputBuffers,
                                                         bufferSize);
                    }
                    JUCE_CATCH_EXCEPTION
                }
                else
                {
                    outs.clear();
                }
            }

            if (outputDevice != 0)
                outputDevice->copyBuffers ((const float**) outputBuffers, numOutputBuffers, bufferSize, *this);
        }
开发者ID:alessandropetrolati,项目名称:juced,代码行数:58,代码来源:juce_win32_WASAPI.cpp

示例3: processBlock

void DiauproPluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    buffer.clear();
    
    
    if (tagCountdown > 0) {
        tagCountdown--;
        diauproNullProcessor.setTag((uint32) 0);
    }else{
        tagCountdown = 100;
        startTime = Time::getMillisecondCounterHiRes();
        diauproNullProcessor.setTag((uint32) 555);
    }
    diauproNullProcessor.processBlock(buffer, midiMessages);
    
    diauproVCOProcessor.setTag(diauproNullProcessor.getTag());
    diauproVCOProcessor.processBlock(buffer, midiMessages);
    
    diauproVCAProcessor.setTag(diauproVCOProcessor.getTag());
    diauproVCAProcessor.processBlock(buffer, midiMessages);
    
    if (diauproVCAProcessor.getTag() > 0) {
        audioLatency = Time::getMillisecondCounterHiRes() - startTime;
    }
    
    triggerAsyncUpdate ();
}
开发者ID:alexgustafson,项目名称:DiauproProject,代码行数:27,代码来源:PluginProcessor.cpp

示例4: 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

示例5: 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

示例6: 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

示例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: 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

示例9:

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

示例10: addAudioTrack

bool AudioCDBurner::addAudioTrack (AudioSource* audioSource, int numSamples)
{
    if (audioSource == 0)
        return false;

    ScopedPointer<AudioSource> source (audioSource);

    long bytesPerBlock;
    HRESULT hr = pimpl->redbook->GetAudioBlockSize (&bytesPerBlock);

    const int samplesPerBlock = bytesPerBlock / 4;
    bool ok = true;

    hr = pimpl->redbook->CreateAudioTrack ((long) numSamples / (bytesPerBlock * 4));

    HeapBlock <byte> buffer (bytesPerBlock);
    AudioSampleBuffer sourceBuffer (2, samplesPerBlock);
    int samplesDone = 0;

    source->prepareToPlay (samplesPerBlock, 44100.0);

    while (ok)
    {
        {
            AudioSourceChannelInfo info;
            info.buffer = &sourceBuffer;
            info.numSamples = samplesPerBlock;
            info.startSample = 0;
            sourceBuffer.clear();

            source->getNextAudioBlock (info);
        }

        buffer.clear (bytesPerBlock);

        typedef AudioData::Pointer <AudioData::Int16, AudioData::LittleEndian,
                AudioData::Interleaved, AudioData::NonConst> CDSampleFormat;

        typedef AudioData::Pointer <AudioData::Float32, AudioData::NativeEndian,
                AudioData::NonInterleaved, AudioData::Const> SourceSampleFormat;

        CDSampleFormat left (buffer, 2);
        left.convertSamples (SourceSampleFormat (sourceBuffer.getSampleData (0)), samplesPerBlock);
        CDSampleFormat right (buffer + 2, 2);
        right.convertSamples (SourceSampleFormat (sourceBuffer.getSampleData (1)), samplesPerBlock);

        hr = pimpl->redbook->AddAudioTrackBlocks (buffer, bytesPerBlock);

        if (FAILED (hr))
            ok = false;

        samplesDone += samplesPerBlock;

        if (samplesDone >= numSamples)
            break;
    }

    hr = pimpl->redbook->CloseAudioTrack();
    return ok && hr == S_OK;
}
开发者ID:georgekrueger,项目名称:LumaGen,代码行数:60,代码来源:juce_win32_AudioCDBurner.cpp

示例11: createTestSound

    void createTestSound()
    {
        const int length = ((int) sampleRate) / 4;
        testSound.setSize (1, length);
        testSound.clear();
        float* s = testSound.getSampleData (0, 0);

        Random rand (0);
        rand.setSeedRandomly();

        for (int i = 0; i < length; ++i)
            s[i] = (rand.nextFloat() - rand.nextFloat() + rand.nextFloat() - rand.nextFloat()) * 0.06f;

        spikes.clear();

        int spikePos = 0;
        int spikeDelta = 50;

        while (spikePos < length)
        {
            spikes.add (spikePos);

            s [spikePos] = 0.99f;
            s [spikePos + 1] = -0.99f;

            spikePos += spikeDelta;
            spikeDelta += spikeDelta / 6 + rand.nextInt (5);
        }
    }
开发者ID:baeksanchang,项目名称:juce,代码行数:29,代码来源:AudioDemoLatencyPage.cpp

示例12: createTestSound

    // create a test sound which consists of a series of randomly-spaced audio spikes..
    void createTestSound()
    {
        const int length = ((int) sampleRate) / 4;
        testSound.setSize (1, length);
        testSound.clear();

        Random rand;

        for (int i = 0; i < length; ++i)
            testSound.setSample (0, i, (rand.nextFloat() - rand.nextFloat() + rand.nextFloat() - rand.nextFloat()) * 0.06f);

        spikePositions.clear();

        int spikePos = 0;
        int spikeDelta = 50;

        while (spikePos < length - 1)
        {
            spikePositions.add (spikePos);

            testSound.setSample (0, spikePos,      0.99f);
            testSound.setSample (0, spikePos + 1, -0.99f);

            spikePos += spikeDelta;
            spikeDelta += spikeDelta / 6 + rand.nextInt (5);
        }
    }
开发者ID:alesaccoia,项目名称:JUCE,代码行数:28,代码来源:AudioLatencyDemo.cpp

示例13: processBlock

void NewProjectAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    const int numSamples = buffer.getNumSamples();

    // output buffers will initially be garbage, must be cleared:
    for (int i = 0; i < getNumOutputChannels(); ++i) {
        buffer.clear (i, 0, numSamples);
    }
    
    // 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 the synth to process these midi events and generate its output.
    synth.renderNextBlock (buffer, midiMessages, 0, numSamples);

    // ask the host for the current time so we can display it...
    AudioPlayHead::CurrentPositionInfo newTime;
    
    if (getPlayHead() != nullptr && getPlayHead()->getCurrentPosition (newTime))
    {
        // Successfully got the current time from the host..
        lastPosInfo = newTime;
    }
    else
    {
        // If the host fails to fill-in the current time, we'll just clear it to a default..
        lastPosInfo.resetToDefault();
    }

}
开发者ID:Birfudgees,项目名称:csc344,代码行数:31,代码来源:PluginProcessor.cpp

示例14: 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

示例15: 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


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