本文整理汇总了C++中AUD_Reference::createReader方法的典型用法代码示例。如果您正苦于以下问题:C++ AUD_Reference::createReader方法的具体用法?C++ AUD_Reference::createReader怎么用?C++ AUD_Reference::createReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AUD_Reference
的用法示例。
在下文中一共展示了AUD_Reference::createReader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AUD_readSoundBuffer
float* AUD_readSoundBuffer(const char* filename, float low, float high,
float attack, float release, float threshold,
int accumulate, int additive, int square,
float sthreshold, double samplerate, int* length)
{
AUD_Buffer buffer;
AUD_DeviceSpecs specs;
specs.channels = AUD_CHANNELS_MONO;
specs.rate = (AUD_SampleRate)samplerate;
AUD_Reference<AUD_IFactory> sound;
AUD_Reference<AUD_IFactory> file = new AUD_FileFactory(filename);
AUD_Reference<AUD_IReader> reader = file->createReader();
AUD_SampleRate rate = reader->getSpecs().rate;
sound = new AUD_ChannelMapperFactory(file, specs);
if(high < rate)
sound = new AUD_LowpassFactory(sound, high);
if(low > 0)
sound = new AUD_HighpassFactory(sound, low);
sound = new AUD_EnvelopeFactory(sound, attack, release, threshold, 0.1f);
sound = new AUD_LinearResampleFactory(sound, specs);
if(square)
sound = new AUD_SquareFactory(sound, sthreshold);
if(accumulate)
sound = new AUD_AccumulatorFactory(sound, additive);
else if(additive)
sound = new AUD_SumFactory(sound);
reader = sound->createReader();
if(reader.isNull())
return NULL;
int len;
int position = 0;
bool eos;
do
{
len = samplerate;
buffer.resize((position + len) * sizeof(float), true);
reader->read(len, eos, buffer.getBuffer() + position);
position += len;
} while(!eos);
float* result = (float*)malloc(position * sizeof(float));
memcpy(result, buffer.getBuffer(), position * sizeof(float));
*length = position;
return result;
}
示例2: play
AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep)
{
return play(factory->createReader(), keep);
}
示例3: play
AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep)
{
/* AUD_XXX disabled
AUD_OpenALHandle* sound = NULL;
lock();
try
{
// check if it is a buffered factory
for(AUD_BFIterator i = m_bufferedFactories->begin();
i != m_bufferedFactories->end(); i++)
{
if((*i)->factory == factory)
{
// create the handle
sound = new AUD_OpenALHandle;
sound->keep = keep;
sound->current = -1;
sound->isBuffered = true;
sound->eos = true;
sound->loopcount = 0;
sound->stop = NULL;
sound->stop_data = NULL;
alcSuspendContext(m_context);
// OpenAL playback code
try
{
alGenSources(1, &sound->source);
if(alGetError() != AL_NO_ERROR)
AUD_THROW(AUD_ERROR_OPENAL, gensource_error);
try
{
alSourcei(sound->source, AL_BUFFER, (*i)->buffer);
if(alGetError() != AL_NO_ERROR)
AUD_THROW(AUD_ERROR_OPENAL, queue_error);
}
catch(AUD_Exception&)
{
alDeleteSources(1, &sound->source);
throw;
}
}
catch(AUD_Exception&)
{
delete sound;
alcProcessContext(m_context);
throw;
}
// play sound
m_playingSounds->push_back(sound);
alSourcei(sound->source, AL_SOURCE_RELATIVE, 1);
start();
alcProcessContext(m_context);
}
}
}
catch(AUD_Exception&)
{
unlock();
throw;
}
unlock();
if(sound)
return sound;*/
return play(factory->createReader(), keep);
}