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


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

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


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

示例1: applyDelay

void JuceDemoPluginAudioProcessor::applyDelay (AudioBuffer<FloatType>& buffer, AudioBuffer<FloatType>& delayBuffer)
{
    const int numSamples = buffer.getNumSamples();
    const float delayLevel = *delayParam;

    int delayPos = 0;

    for (int channel = 0; channel < getNumInputChannels(); ++channel)
    {
        FloatType* const channelData = buffer.getWritePointer (channel);
        FloatType* const delayData = delayBuffer.getWritePointer (jmin (channel, delayBuffer.getNumChannels() - 1));
        delayPos = delayPosition;

        for (int i = 0; i < numSamples; ++i)
        {
            const FloatType in = channelData[i];
            channelData[i] += delayData[delayPos];
            delayData[delayPos] = (delayData[delayPos] + in) * delayLevel;

            if (++delayPos >= delayBuffer.getNumSamples())
                delayPos = 0;
        }
    }

    delayPosition = delayPos;
}
开发者ID:EdyJ,项目名称:JUCE,代码行数:26,代码来源:PluginProcessor.cpp

示例2: processBlock

void DaalDelAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
    ScopedNoDenormals noDenormals;
    
    auto totalNumInputChannels  = getTotalNumInputChannels();
    auto 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 (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
        buffer.clear (i, 0, buffer.getNumSamples());
    
    // ====
    // Lengths for circular buffer
    const int bufferLength = buffer.getNumSamples();
    const int delayBufferLength = _delayBuffer.getNumSamples();
    
    
    // This is the place where you'd normally do the guts of your plugin's
    // audio processing...
    // Make sure to reset the state if your inner loop is processing
    // the samples and the outer loop is handling the channels.
    // Alternatively, you can process the samples with the channels
    // interleaved by keeping the same state.
    for (int channel = 0; channel < totalNumInputChannels; ++channel)
    {
        //auto* channelData = buffer.getWritePointer (channel);

        // ..do something to the data...
        
        // Set up circular buffer
        const float* bufferData = buffer.getReadPointer(channel);
        const float* delayBufferData = _delayBuffer.getReadPointer(channel);
        float* dryBuffer = buffer.getWritePointer(channel);
        
        // Apply gains (now do this before getting from delay)
        applyDryWetToBuffer(buffer, channel, bufferLength, dryBuffer);
        
        // Copy data from main to delay buffer
        fillDelayBuffer(channel, bufferLength, delayBufferLength, bufferData, delayBufferData);
        
        // Copy data from delay buffer to output buffer
        getFromDelayBuffer(buffer, channel, bufferLength, delayBufferLength, bufferData, delayBufferData);
        
        // Feedback
        feedbackDelay(channel, bufferLength, delayBufferLength, dryBuffer);
    }
    
    _writePosition += bufferLength; // Increment
    _writePosition %= delayBufferLength; // Wrap around position index
    
    // Update values from tree
    updateTreeParams();
}
开发者ID:usdivad,项目名称:live_performance_setups,代码行数:58,代码来源:PluginProcessor.cpp

示例3: copyBufferToTemporaryLocation

    //==============================================================================
    void copyBufferToTemporaryLocation (const AudioBuffer<float>& buffer)
    {
        const SpinLock::ScopedLockType sl (processLock);

        auto numChannels = buffer.getNumChannels() > 1 ? 2 : 1;
        temporaryBuffer.setSize (numChannels, buffer.getNumSamples(), false, false, true);

        for (auto channel = 0; channel < numChannels; ++channel)
            temporaryBuffer.copyFrom (channel, 0, buffer, channel, 0, buffer.getNumSamples());
    }
开发者ID:COx2,项目名称:JUCE_JAPAN_DEMO,代码行数:11,代码来源:juce_Convolution.cpp

示例4: processBlock

    void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override
    {
        Reverb::Parameters reverbParameters;
        reverbParameters.roomSize = roomSizeParam->get();

        reverb.setParameters (reverbParameters);
        synth.renderNextBlock (buffer, midiMessages, 0, buffer.getNumSamples());

        if (getMainBusNumOutputChannels() == 1)
            reverb.processMono (buffer.getWritePointer (0), buffer.getNumSamples());
        else if (getMainBusNumOutputChannels() == 2)
            reverb.processStereo (buffer.getWritePointer (0), buffer.getWritePointer (1), buffer.getNumSamples());
    }
开发者ID:Neknail,项目名称:JUCE,代码行数:13,代码来源:AUv3SynthProcessor.cpp

示例5: process

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

示例6: applyGain

void JuceDemoPluginAudioProcessor::applyGain (AudioBuffer<FloatType>& buffer, AudioBuffer<FloatType>& delayBuffer)
{
	ignoreUnused (delayBuffer);
    const float gainLevel = *gainParam;

    for (int channel = 0; channel < getNumInputChannels(); ++channel)
        buffer.applyGain (channel, 0, buffer.getNumSamples(), gainLevel);
}
开发者ID:EdyJ,项目名称:JUCE,代码行数:8,代码来源:PluginProcessor.cpp

示例7: fillBufferSquarePulse

void VAOscillator::fillBufferSquarePulse(AudioBuffer<float>& buffer, AudioBuffer<float>& phaseModBuffer, AudioBuffer<float>& volumeModBuffer, AudioBuffer<float>& pitchModBuffer)
{
  if(isActive)
  {
    float* const data = buffer.getWritePointer(0);
    float const *phaseMod = phaseModBuffer.getReadPointer(0);
    float const *volMod = volumeModBuffer.getReadPointer(0);
    float const *pitchMod = pitchModBuffer.getReadPointer(0);
    
    //write momentary phase values into the buffer
    for(int sampleIndex = 0; sampleIndex < buffer.getNumSamples(); sampleIndex++)
    {
      double phase = currentPhase + phaseModAmp * phaseMod[sampleIndex];
      
      while (phase < 0)
      {
        phase += 2 * double_Pi;
      }
      while (phase > 2 * double_Pi)
      {
        phase -= 2 * double_Pi;
      }
      
      currentPhase += 2 * double_Pi * ((currentFrequency * (pitchMod[sampleIndex] + 2.0))/currentSampleRate);
      
      if(currentPhase > 2 * double_Pi)
      {
        currentPhase -= 2 * double_Pi;
      }
      
      if(phase < double_Pi)
      {
        data[sampleIndex] = -1;
      }
      else
      {
        data[sampleIndex] = 1;
      }

      data[sampleIndex] += getBlep(phase, currentFrequency);
        
      if(phase < double_Pi)
      {
        data[sampleIndex] -= getBlep(phase + double_Pi, currentFrequency);
      }
      if(phase > double_Pi)
      {
        data[sampleIndex] -= getBlep(phase - double_Pi, currentFrequency);
      }
      
      data[sampleIndex] *= (float)std::abs(0.5 * (volMod[sampleIndex] + 1));
    }
  }
  else
  {
    buffer.clear();
  }
}// end square pulse
开发者ID:jonathankakon,项目名称:supersynth,代码行数:58,代码来源:VAOscillator.cpp

示例8: postFilter

void VAOscillator::postFilter(AudioBuffer<float> buffer)
{
  float* const data = buffer.getWritePointer(0);
  for(int sampleIndex = 0; sampleIndex < buffer.getNumSamples(); sampleIndex++)
  {
    postFilterState = (1/0.65) * data[sampleIndex];
    data[sampleIndex] -= (float)((0.35/0.65) * postFilterState);
  }
}
开发者ID:jonathankakon,项目名称:supersynth,代码行数:9,代码来源:VAOscillator.cpp

示例9: fillBufferTriangle

void VAOscillator::fillBufferTriangle(AudioBuffer<float>& buffer, AudioBuffer<float>& phaseModBuffer, AudioBuffer<float>& volumeModBuffer, AudioBuffer<float>& pitchModBuffer)
{
  if(isActive)
  {
    float* const data = buffer.getWritePointer(0);
    float const *phaseMod = phaseModBuffer.getReadPointer(0);
    float const *volMod = volumeModBuffer.getReadPointer(0);
    float const *pitchMod = pitchModBuffer.getReadPointer(0);
    
    for(int sampleIndex = 0; sampleIndex < buffer.getNumSamples(); sampleIndex++)
    {
      double phase = currentPhase + phaseModAmp * phaseMod[sampleIndex];
      
      while (phase < 0)
      {
        phase += 2 * double_Pi;
      }
      while (phase > 2 * double_Pi)
      {
        phase -= 2 * double_Pi;
      }
          
      currentPhase += 2 * double_Pi * ((currentFrequency * (pitchMod[sampleIndex] + 2.0))/currentSampleRate);
      
      if(currentPhase > 2 * double_Pi)
      {
        currentPhase -= 2 * double_Pi;
      }
    
      if(phase < double_Pi)
      {
        data[sampleIndex] = (float)((2 * phase)/double_Pi - 1);
      }
      else
      {
        data[sampleIndex] = (float)((3 - 2 * phase/double_Pi));
      }
      
      //the 0.000026 is kind of a magic number i didnt calculate it just found it by trying out
      data[sampleIndex] += (float)(0.000026 * currentFrequency * getTriRes(phase, currentFrequency));
      if(phase < double_Pi)
      {
        data[sampleIndex] -= (float)(0.000026 * currentFrequency * getTriRes(phase + double_Pi, currentFrequency));
      }
      else if(phase >= double_Pi)
      {
        data[sampleIndex] -= (float)(0.000026 * currentFrequency * getTriRes(phase - double_Pi, currentFrequency));
      }
      
      data[sampleIndex] *= (float)std::abs(0.5 * (volMod[sampleIndex] + 1));
    }
  }
  else
  {
    buffer.clear();
  }
}// end triangle
开发者ID:jonathankakon,项目名称:supersynth,代码行数:57,代码来源:VAOscillator.cpp

示例10: isLooping

MemoryAudioSource::MemoryAudioSource (AudioBuffer<float>& bufferToUse, bool copyMemory, bool shouldLoop)
    : isLooping (shouldLoop)
{
    if (copyMemory)
        buffer.makeCopyOf (bufferToUse);
    else
        buffer.setDataToReferTo (bufferToUse.getArrayOfWritePointers(),
                                 bufferToUse.getNumChannels(),
                                 bufferToUse.getNumSamples());
}
开发者ID:julianstorer,项目名称:JUCE,代码行数:10,代码来源:juce_MemoryAudioSource.cpp

示例11: fillBufferNoise

void NoiseOscillator::fillBufferNoise(AudioBuffer<float> &buffer)
{
  float* const data = buffer.getWritePointer(0);
  
  for(int sampleIndex = 0; sampleIndex < buffer.getNumSamples(); sampleIndex++)
  {
    data[sampleIndex] = (2 * rand.nextFloat()) - 1;
  }

}
开发者ID:jonathankakon,项目名称:supersynth,代码行数:10,代码来源:NoiseOscillator.cpp

示例12: perform

    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;
    }
开发者ID:rorywalsh,项目名称:cabbage,代码行数:42,代码来源:juce_AudioProcessorGraph.cpp

示例13: fillBufferSine

void VAOscillator::fillBufferSine(AudioBuffer<float>& buffer, AudioBuffer<float>& phaseModBuffer, AudioBuffer<float>& volumeModBuffer, AudioBuffer<float>& pitchModBuffer, Array<int>& midiOns)// add midi buffer and know channel with control Voltage
{
  if(isActive)
  {
    float* const data = buffer.getWritePointer(0);
    float const *phaseMod = phaseModBuffer.getReadPointer(0);
    float const *volMod = volumeModBuffer.getReadPointer(0);
    float const *pitchMod = pitchModBuffer.getReadPointer(0);

    for(int sampleIndex = 0; sampleIndex < buffer.getNumSamples(); sampleIndex++)
    {
      //check if this is the best i can do
      if(midiOns.size() != 0)
      {
        if(sampleIndex == midiOns[0])
        {
          resetPhase();
          midiOns.remove(0);
        }
      }
      
      double phase = currentPhase + phaseModAmp * phaseMod[sampleIndex] + currentPhaseOffset;
      
      while (phase < 0)
      {
        phase += 2 * double_Pi;
      }
      while (phase > 2 * double_Pi)
      {
        phase -= 2 * double_Pi;
      }
      
      data[sampleIndex] = static_cast<float>(sin(phase) * std::abs(0.5 * (volMod[sampleIndex] + 1)));
      
      currentPhase += 2 * double_Pi * ((currentFrequency * (pitchMod[sampleIndex] + 2.0))/currentSampleRate);
      
      if(currentPhase > 2 * double_Pi)
      {
        currentPhase -= 2 * double_Pi;
      }
    }
  }
  else
  {
    buffer.clear();
  }
}// end sine
开发者ID:jonathankakon,项目名称:supersynth,代码行数:47,代码来源:VAOscillator.cpp

示例14: fillBufferFallingSaw

void VAOscillator::fillBufferFallingSaw(AudioBuffer<float>& buffer, AudioBuffer<float>& phaseModBuffer, AudioBuffer<float>& volumeModBuffer, AudioBuffer<float>& pitchModBuffer)
{
  if(isActive)
  {
    fillBufferRisingSaw(buffer, phaseModBuffer, volumeModBuffer, pitchModBuffer);
    
    float* const data = buffer.getWritePointer(0);
    
    for(int sampleIndex = 0; sampleIndex < buffer.getNumSamples(); sampleIndex++)
    {
      data[sampleIndex] *= -1;
    }
  }
  else
  {
    buffer.clear();
  }
}// end falling Saw
开发者ID:jonathankakon,项目名称:supersynth,代码行数:18,代码来源:VAOscillator.cpp

示例15: writeFromAudioSampleBuffer

bool AudioFormatWriter::writeFromAudioSampleBuffer (const AudioBuffer<float>& source, int startSample, int numSamples)
{
    auto numSourceChannels = source.getNumChannels();
    jassert (startSample >= 0 && startSample + numSamples <= source.getNumSamples() && numSourceChannels > 0);

    if (startSample == 0)
        return writeFromFloatArrays (source.getArrayOfReadPointers(), numSourceChannels, numSamples);

    const float* chans[256];
    jassert ((int) numChannels < numElementsInArray (chans));

    for (int i = 0; i < numSourceChannels; ++i)
        chans[i] = source.getReadPointer (i, startSample);

    chans[numSourceChannels] = nullptr;

    return writeFromFloatArrays (chans, numSourceChannels, numSamples);
}
开发者ID:rorywalsh,项目名称:cabbage,代码行数:18,代码来源:juce_AudioFormatWriter.cpp


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