This source file includes following definitions.
- m_oversample
- createKernel
- setCurve
- setOversample
- process
#include "config.h"
#if ENABLE(WEB_AUDIO)
#include "modules/webaudio/WaveShaperProcessor.h"
#include "modules/webaudio/WaveShaperDSPKernel.h"
namespace WebCore {
WaveShaperProcessor::WaveShaperProcessor(float sampleRate, size_t numberOfChannels)
: AudioDSPKernelProcessor(sampleRate, numberOfChannels)
, m_oversample(OverSampleNone)
{
}
WaveShaperProcessor::~WaveShaperProcessor()
{
if (isInitialized())
uninitialize();
}
PassOwnPtr<AudioDSPKernel> WaveShaperProcessor::createKernel()
{
return adoptPtr(new WaveShaperDSPKernel(this));
}
void WaveShaperProcessor::setCurve(Float32Array* curve)
{
MutexLocker processLocker(m_processLock);
m_curve = curve;
}
void WaveShaperProcessor::setOversample(OverSampleType oversample)
{
MutexLocker processLocker(m_processLock);
m_oversample = oversample;
if (oversample != OverSampleNone) {
for (unsigned i = 0; i < m_kernels.size(); ++i) {
WaveShaperDSPKernel* kernel = static_cast<WaveShaperDSPKernel*>(m_kernels[i].get());
kernel->lazyInitializeOversampling();
}
}
}
void WaveShaperProcessor::process(const AudioBus* source, AudioBus* destination, size_t framesToProcess)
{
if (!isInitialized()) {
destination->zero();
return;
}
bool channelCountMatches = source->numberOfChannels() == destination->numberOfChannels() && source->numberOfChannels() == m_kernels.size();
ASSERT(channelCountMatches);
if (!channelCountMatches)
return;
MutexTryLocker tryLocker(m_processLock);
if (tryLocker.locked()) {
for (unsigned i = 0; i < m_kernels.size(); ++i)
m_kernels[i]->process(source->channel(i)->data(), destination->channel(i)->mutableData(), framesToProcess);
} else {
destination->zero();
}
}
}
#endif