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


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

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


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

示例1: resizeBuffers

void ChorusAudioProcessor::resizeBuffers(AudioSampleBuffer& depthOSC, AudioSampleBuffer& delayOSC, AudioSampleBuffer& delayBufferL, AudioSampleBuffer& delayBufferR)
{
	// Set the size all the buffers to be the same as the current sample rate
	// this is equivalent to 1 second
	delayBufferL.setSize(1, (int)getSampleRate(), false, true, true);
	delayBufferR.setSize(1, (int)getSampleRate(), false, true, true);
	depthOSC.setSize(1, (int)getSampleRate(), false, true, true);
	delayOSC.setSize(1, (int)getSampleRate(), false, true, true);

	// Update stored sample rate.
	FS = getSampleRate();

	// Update write pointers
	depthOSCwp = depthOSC.getWritePointer(0);
	delayOSCwp = delayOSC.getWritePointer(0);
	delayBufferLwp = delayBufferL.getWritePointer(0);
	delayBufferRwp = delayBufferR.getWritePointer(0);

	// Update read pointers
	depthOSCrp = depthOSC.getReadPointer(0);
	delayOSCrp = delayOSC.getReadPointer(0);
	delayBufferLrp = delayBufferL.getReadPointer(0);
	delayBufferRrp = delayBufferR.getReadPointer(0);
	LFOBuffer();

	// Update buffer index
	bidx = 0;
}
开发者ID:edStorey,项目名称:Chorus_Plugin,代码行数:28,代码来源:PluginProcessor.cpp

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

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

示例4: OggReader

    //==============================================================================
    OggReader (InputStream* const inp)
        : AudioFormatReader (inp, TRANS (oggFormatName)),
          reservoir (2, 4096),
          reservoirStart (0),
          samplesInReservoir (0)
    {
        using namespace OggVorbisNamespace;
        sampleRate = 0;
        usesFloatingPointData = true;

        callbacks.read_func = &oggReadCallback;
        callbacks.seek_func = &oggSeekCallback;
        callbacks.close_func = &oggCloseCallback;
        callbacks.tell_func = &oggTellCallback;

        const int err = ov_open_callbacks (input, &ovFile, 0, 0, callbacks);

        if (err == 0)
        {
            vorbis_info* info = ov_info (&ovFile, -1);
            lengthInSamples = (uint32) ov_pcm_total (&ovFile, -1);
            numChannels = info->channels;
            bitsPerSample = 16;
            sampleRate = info->rate;

            reservoir.setSize (numChannels,
                               (int) jmin (lengthInSamples, (int64) reservoir.getNumSamples()));
        }
    }
开发者ID:Labmind,项目名称:GUI,代码行数:30,代码来源:juce_OggVorbisAudioFormat.cpp

示例5: update

void Sample::update(const String& path, WavAudioFormat& wavAudioFormat)
{
	// Don't load a subsequent sample if a new sample is already loaded (but not yet played).
	if (_readyToSwap)
		return;

	// Find audio file.
	String fileName(path);
	fileName = File::addTrailingSeparator(fileName);
	fileName += _name;
	fileName += EXT;
	File file(fileName);

	Time modification = file.getLastModificationTime();
	if (modification <= _lastModification)
		return;

	// Read audio file. We only read the left channel, mono is good enough.
	AudioFormatReader* reader = wavAudioFormat.createReaderFor(file.createInputStream(), true);
	if (reader == nullptr)
		return;
	_lastModification = modification;

	int64 start = reader->searchForLevel(0, reader->lengthInSamples, SAMPLE_START_THRESHOLD, 1.0, 0);
	if (start == -1)
		start = 0;
	int count = (int)(reader->lengthInSamples - start);

	_processor->writeTrace(String() << "Loading " << _name << " from disk (skip=" << start << ")");

	int newIndex = !_bufferIndex;
	AudioSampleBuffer* buffer = &(_buffers[newIndex]);
	buffer->setSize(1, count);

	reader->read(buffer, 0, count, start, true, false);

	delete reader;

	// Done.
	_readyToSwap = true;
}
开发者ID:bystam,项目名称:remote-goat,代码行数:41,代码来源:PluginProcessor.cpp


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