本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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()));
}
}
示例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;
}