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


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

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


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

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

示例2: writeFromAudioSampleBuffer

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

    if (startSample == 0)
        return writeFromFloatArrays ((const float**) source.getArrayOfChannels(), numSourceChannels, numSamples);

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

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

    chans[numSourceChannels] = nullptr;

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

示例3: process

void FilterNode::process(AudioSampleBuffer &buffer, 
                            MidiBuffer &midiMessages,
                            int& nSamples)
{
	//std::cout << "Filter node processing." << std::endl;
	//std::cout << buffer.getNumChannels() << std::endl;
	//::cout << buffer.getNumSamples() << std::endl;

	//int nSamps = getNumSamples(midiMessages);
	//std::cout << nSamples << std::endl;
    filter->process (nSamples, buffer.getArrayOfChannels());

    //std::cout << "Filter node:" << *buffer.getSampleData(0,0);


    //int ts = checkForMidiEvents(midiMessages);

    //std::cout << "Timestamp = " << ts << std::endl;
}
开发者ID:karlssonm,项目名称:GUI,代码行数:19,代码来源:FilterNode.cpp

示例4: processBlock

void DemoJuceFilter::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{	
	assert(mpDSP->getNumInputs()<= buffer.getNumChannels());
	assert(mpDSP->getNumOutputs()<= buffer.getNumChannels());
	if(mpDSP	&& mpDSP->getNumInputs()<= buffer.getNumChannels() 
						&& mpDSP->getNumOutputs() <= buffer.getNumChannels() )
	{
		mpDSP->compute(buffer.getNumSamples(), 
									 buffer.getArrayOfChannels(), 
									 buffer.getArrayOfChannels());
	}
	
	// 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:remymuller,项目名称:faust2juce,代码行数:20,代码来源:DemoJuceFilter.cpp

示例5: readFromInputDevice

    bool readFromInputDevice (AudioSampleBuffer& inputChannelBuffer, const int numSamples)
    {
        jassert (numChannelsRunning <= inputChannelBuffer.getNumChannels());
        float** const data = inputChannelBuffer.getArrayOfChannels();

        if (isInterleaved)
        {
            scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false);
            scratch.fillWith (0); // (not clearing this data causes warnings in valgrind)

            snd_pcm_sframes_t num = snd_pcm_readi (handle, scratch.getData(), numSamples);

            if (failed (num))
            {
                if (num == -EPIPE)
                {
                    if (failed (snd_pcm_prepare (handle)))
                        return false;
                }
                else if (num != -ESTRPIPE)
                    return false;
            }

            for (int i = 0; i < numChannelsRunning; ++i)
                converter->convertSamples (data[i], 0, scratch.getData(), i, numSamples);
        }
        else
        {
            snd_pcm_sframes_t num = snd_pcm_readn (handle, (void**) data, numSamples);

            if (failed (num) && num != -EPIPE && num != -ESTRPIPE)
                return false;

            for (int i = 0; i < numChannelsRunning; ++i)
                converter->convertSamples (data[i], data[i], numSamples);
        }

        return true;
    }
开发者ID:AndyBrown91,项目名称:JuceMonome,代码行数:39,代码来源:juce_linux_ALSA.cpp

示例6: writeToOutputDevice

    //==============================================================================
    bool writeToOutputDevice (AudioSampleBuffer& outputChannelBuffer, const int numSamples)
    {
        jassert (numChannelsRunning <= outputChannelBuffer.getNumChannels());
        float** const data = outputChannelBuffer.getArrayOfChannels();
        snd_pcm_sframes_t numDone = 0;

        if (isInterleaved)
        {
            scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false);

            for (int i = 0; i < numChannelsRunning; ++i)
                converter->convertSamples (scratch.getData(), i, data[i], 0, numSamples);

            numDone = snd_pcm_writei (handle, scratch.getData(), numSamples);
        }
        else
        {
            for (int i = 0; i < numChannelsRunning; ++i)
                converter->convertSamples (data[i], data[i], numSamples);

            numDone = snd_pcm_writen (handle, (void**) data, numSamples);
        }

        if (failed (numDone))
        {
            if (numDone == -EPIPE)
            {
                if (failed (snd_pcm_prepare (handle)))
                    return false;
            }
            else if (numDone != -ESTRPIPE)
                return false;
        }

        return true;
    }
开发者ID:AndyBrown91,项目名称:JuceMonome,代码行数:37,代码来源:juce_linux_ALSA.cpp

示例7: readMaxLevels

void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples,
                                       float& lowestLeft, float& highestLeft,
                                       float& lowestRight, float& highestRight)
{
    if (numSamples <= 0)
    {
        lowestLeft = 0;
        lowestRight = 0;
        highestLeft = 0;
        highestRight = 0;
        return;
    }

    const int bufferSize = (int) jmin (numSamples, (int64) 4096);
    AudioSampleBuffer tempSampleBuffer (numChannels, bufferSize);

    float** const floatBuffer = tempSampleBuffer.getArrayOfChannels();
    int* const* intBuffer = reinterpret_cast<int* const*> (floatBuffer);

    if (usesFloatingPointData)
    {
        float lmin = 1.0e6f;
        float lmax = -lmin;
        float rmin = lmin;
        float rmax = lmax;

        while (numSamples > 0)
        {
            const int numToDo = (int) jmin (numSamples, (int64) bufferSize);
            if (! read (intBuffer, 2, startSampleInFile, numToDo, false))
                break;

            numSamples -= numToDo;
            startSampleInFile += numToDo;
            getStereoMinAndMax (floatBuffer, numChannels, numToDo, lmin, lmax, rmin, rmax);
        }

        lowestLeft   = lmin;
        highestLeft  = lmax;
        lowestRight  = rmin;
        highestRight = rmax;
    }
    else
    {
        int lmax = std::numeric_limits<int>::min();
        int lmin = std::numeric_limits<int>::max();
        int rmax = std::numeric_limits<int>::min();
        int rmin = std::numeric_limits<int>::max();

        while (numSamples > 0)
        {
            const int numToDo = (int) jmin (numSamples, (int64) bufferSize);
            if (! read (intBuffer, 2, startSampleInFile, numToDo, false))
                break;

            numSamples -= numToDo;
            startSampleInFile += numToDo;
            getStereoMinAndMax (intBuffer, numChannels, numToDo, lmin, lmax, rmin, rmax);
        }

        lowestLeft   = lmin / (float) std::numeric_limits<int>::max();
        highestLeft  = lmax / (float) std::numeric_limits<int>::max();
        lowestRight  = rmin / (float) std::numeric_limits<int>::max();
        highestRight = rmax / (float) std::numeric_limits<int>::max();
    }
}
开发者ID:zenAudio,项目名称:beatmatic-xcode,代码行数:66,代码来源:juce_AudioFormatReader.cpp


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