This source file includes following definitions.
- setCurve
- curve
- setOversample
- oversample
#include "config.h"
#if ENABLE(WEB_AUDIO)
#include "modules/webaudio/WaveShaperNode.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "wtf/MainThread.h"
namespace WebCore {
WaveShaperNode::WaveShaperNode(AudioContext* context)
: AudioBasicProcessorNode(context, context->sampleRate())
{
ScriptWrappable::init(this);
m_processor = adoptPtr(new WaveShaperProcessor(context->sampleRate(), 1));
setNodeType(NodeTypeWaveShaper);
initialize();
}
void WaveShaperNode::setCurve(Float32Array* curve)
{
ASSERT(isMainThread());
waveShaperProcessor()->setCurve(curve);
}
Float32Array* WaveShaperNode::curve()
{
return waveShaperProcessor()->curve();
}
void WaveShaperNode::setOversample(const String& type, ExceptionState& exceptionState)
{
ASSERT(isMainThread());
AudioContext::AutoLocker contextLocker(context());
if (type == "none") {
waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSampleNone);
} else if (type == "2x") {
waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSample2x);
} else if (type == "4x") {
waveShaperProcessor()->setOversample(WaveShaperProcessor::OverSample4x);
} else {
exceptionState.throwDOMException(
InvalidStateError,
"The value provided ('" + type + "') is not one of 'none', '2x', or '4x'.");
}
}
String WaveShaperNode::oversample() const
{
switch (const_cast<WaveShaperNode*>(this)->waveShaperProcessor()->oversample()) {
case WaveShaperProcessor::OverSampleNone:
return "none";
case WaveShaperProcessor::OverSample2x:
return "2x";
case WaveShaperProcessor::OverSample4x:
return "4x";
default:
ASSERT_NOT_REACHED();
return "none";
}
}
}
#endif