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


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

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


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

示例1: processBlock

void OOTrack::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    
    updatePendingLooperState(OOServer::getInstance()->looperState.timeInSamples);
    OOServer::getInstance()->updateGlobalTime(this,buffer.getNumSamples());
    // RECORDING
    if (*isRecording)
    {
        if(recordNeedle.get() + buffer.getNumSamples()> getSampleRate() * MAX_LOOP_LENGTH_S){
            *shouldRecord = false;
            *isRecording = false;
        };
        monoLoopSample.copyFrom(0, recordNeedle.get(), buffer, 0, 0, buffer.getNumSamples());
        recordNeedle += buffer.getNumSamples();
        rmsOut = (1-rmsAlpha)*rmsOut+ rmsAlpha*buffer.getRMSLevel(0, 0, buffer.getNumSamples());
        
        
    }
    else{
        streamBipBuffer.writeBlock(buffer);
    }
    // PLAYING
    // allow circular reading , although not sure that overflow need to be handled as its written with same block sizes than read
    // we may need it if we start to use a different clock  than looperState in OOServer that has a granularity of blockSize
    // or if we dynamicly change blockSize
    if (*isPlaying && recordNeedle.get()>0 && monoLoopSample.getNumSamples())
    {
        if ( (playNeedle + buffer.getNumSamples()) > recordNeedle.get())
        {
            
            //assert false for now see above
//            jassert(false);
            int firstSegmentLength = recordNeedle.get() - playNeedle;
            int secondSegmentLength = buffer.getNumSamples() - firstSegmentLength;
            buffer.copyFrom(0, 0, monoLoopSample, 0, playNeedle, firstSegmentLength);
            buffer.copyFrom(0, 0, monoLoopSample, 0, 0, secondSegmentLength);
            playNeedle = secondSegmentLength;
            
        }else{
            buffer.copyFrom(0, 0, monoLoopSample, 0, playNeedle, buffer.getNumSamples());
            playNeedle += buffer.getNumSamples();
            playNeedle %= recordNeedle.get();
        }
            buffer.applyGainRamp(0, 0, buffer.getNumSamples(), lastVolume,*volume);
            lastVolume = *volume;
        
        
        
            rmsOut = (1-rmsAlpha)*rmsOut+ rmsAlpha*buffer.getRMSLevel(0, 0, buffer.getNumSamples());
    }
    else{
        // silence output buffer
        buffer.applyGain(0, 0, buffer.getNumSamples(), 0);
    }

}
开发者ID:MartinHN,项目名称:Blooper,代码行数:56,代码来源:OOTrack.cpp

示例2: processBlock

void PluginWrapper::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    //this processBlock merely processes a loaded VST.
    if(!isBypassed)
    {
        vstInstance->processBlock(buffer,midiMessages);
    }

    if(isMuted)
        buffer.clear();



    rmsLeft = buffer.getRMSLevel(0, 0, buffer.getNumSamples());
    rmsRight = buffer.getRMSLevel(1, 0, buffer.getNumSamples());


    if(updateCounter==0)
        sendActionMessage("rmsValues "+String(rmsLeft)+" "+String(rmsRight));

    updateCounter++;
    if(updateCounter>5)
        updateCounter=0;
}
开发者ID:aisis,项目名称:cabbage,代码行数:24,代码来源:PluginWrapperProcessor.cpp

示例3: processBlock

void UGenPlugin::processBlock(AudioSampleBuffer& buffer,
							  MidiBuffer& /*midiMessages*/)
{	
	clearExtraChannels(buffer); // see below
	
	int numSamples = buffer.getNumSamples();
	
	if(inputBuffer.size() < numSamples)
		inputBuffer = Buffer::newClear(numSamples, getNumInputChannels(), true);
	
	for(int i = 0; i < getNumInputChannels(); i++)
	{
		float *inputData = inputBuffer.getData(i);
		memcpy(inputData, buffer.getSampleData(i), numSamples * sizeof(float));
		inputUGen.setInput(inputData, numSamples, i);
	}
	
	const int numOutputChannels = jmin(getNumOutputChannels(), outputUGen.getNumChannels());
	for(int i = 0; i < numOutputChannels; i++)
	{
		outputUGen.setOutput(buffer.getSampleData(i), numSamples, i);
	}
	
    outputLock.enter();
	outputUGen.prepareAndProcessBlock(numSamples, blockID, -1);
    outputLock.exit();
	
	// quick and dirty metering...
	channelLevel0 += buffer.getRMSLevel(UGenAudio::Output0, 0, buffer.getNumSamples());
	channelLevel1 += buffer.getRMSLevel(UGenAudio::Output1, 0, buffer.getNumSamples());
	
	numMeasurements++;
	if(numMeasurements >= 4)
	{
		setMeterLevel(UGenInterface::Meters::OutL, channelLevel0);
		setMeterLevel(UGenInterface::Meters::OutR, channelLevel1);
		channelLevel0 = channelLevel1 = 0.f;
		numMeasurements = 0;
    }
	
	blockID += numSamples;
}
开发者ID:0x4d52,项目名称:ugen,代码行数:42,代码来源:UGenPlugin.cpp


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