本文整理汇总了C++中Float32Array::length方法的典型用法代码示例。如果您正苦于以下问题:C++ Float32Array::length方法的具体用法?C++ Float32Array::length怎么用?C++ Float32Array::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Float32Array
的用法示例。
在下文中一共展示了Float32Array::length方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jsFloat32ArrayLength
JSValue jsFloat32ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSFloat32Array* castedThis = static_cast<JSFloat32Array*>(asObject(slotBase));
UNUSED_PARAM(exec);
Float32Array* imp = static_cast<Float32Array*>(castedThis->impl());
JSValue result = jsNumber(imp->length());
return result;
}
示例2: index
PassRefPtr<Float32Array> AudioBuffer::getChannelData(unsigned channelIndex, ExceptionState& exceptionState)
{
if (channelIndex >= m_channels.size()) {
exceptionState.throwDOMException(IndexSizeError, "channel index (" + String::number(channelIndex) + ") exceeds number of channels (" + String::number(m_channels.size()) + ")");
return nullptr;
}
Float32Array* channelData = m_channels[channelIndex].get();
return Float32Array::create(channelData->buffer(), channelData->byteOffset(), channelData->length());
}
示例3:
PassRefPtr<Float32Array> AudioBuffer::getChannelData(unsigned channelIndex, ExceptionCode& ec)
{
if (channelIndex >= m_channels.size()) {
ec = SYNTAX_ERR;
return nullptr;
}
Float32Array* channelData = m_channels[channelIndex].get();
return Float32Array::create(channelData->buffer(), channelData->byteOffset(), channelData->length());
}
示例4: processCurve
void WaveShaperDSPKernel::processCurve(const float* source, float* destination, size_t framesToProcess)
{
ASSERT(source && destination && waveShaperProcessor());
Float32Array* curve = waveShaperProcessor()->curve();
if (!curve) {
// Act as "straight wire" pass-through if no curve is set.
memcpy(destination, source, sizeof(float) * framesToProcess);
return;
}
float* curveData = curve->data();
int curveLength = curve->length();
ASSERT(curveData);
if (!curveData || !curveLength) {
memcpy(destination, source, sizeof(float) * framesToProcess);
return;
}
// Apply waveshaping curve.
for (unsigned i = 0; i < framesToProcess; ++i) {
const float input = source[i];
// Calculate a virtual index based on input -1 -> +1 with -1 being curve[0], +1 being
// curve[curveLength - 1], and 0 being at the center of the curve data. Then linearly
// interpolate between the two points in the curve.
double virtualIndex = 0.5 * (input + 1) * (curveLength - 1);
double output;
if (virtualIndex < 0) {
// input < -1, so use curve[0]
output = curveData[0];
} else if (virtualIndex >= curveLength - 1) {
// input >= 1, so use last curve value
output = curveData[curveLength - 1];
} else {
// The general case where -1 <= input < 1, where 0 <= virtualIndex < curveLength - 1,
// so interpolate between the nearest samples on the curve.
unsigned index1 = static_cast<unsigned>(virtualIndex);
unsigned index2 = index1 + 1;
double interpolationFactor = virtualIndex - index1;
double value1 = curveData[index1];
double value2 = curveData[index2];
output = (1.0 - interpolationFactor) * value1 + interpolationFactor * value2;
}
destination[i] = output;
}
}
示例5: processCurve
void WaveShaperDSPKernel::processCurve(const float* source, float* destination, size_t framesToProcess)
{
ASSERT(source && destination && waveShaperProcessor());
Float32Array* curve = waveShaperProcessor()->curve();
if (!curve) {
// Act as "straight wire" pass-through if no curve is set.
memcpy(destination, source, sizeof(float) * framesToProcess);
return;
}
float* curveData = curve->data();
int curveLength = curve->length();
ASSERT(curveData);
if (!curveData || !curveLength) {
memcpy(destination, source, sizeof(float) * framesToProcess);
return;
}
// Apply waveshaping curve.
for (unsigned i = 0; i < framesToProcess; ++i) {
const float input = source[i];
// Calculate a virtual index based on input -1 -> +1 with 0 being at the center of the curve data.
// Then linearly interpolate between the two points in the curve.
double virtualIndex = 0.5 * (input + 1) * curveLength;
int index1 = static_cast<int>(virtualIndex);
int index2 = index1 + 1;
double interpolationFactor = virtualIndex - index1;
// Clip index to the input range of the curve.
// This takes care of input outside of nominal range -1 -> +1
index1 = max(index1, 0);
index1 = min(index1, curveLength - 1);
index2 = max(index2, 0);
index2 = min(index2, curveLength - 1);
double value1 = curveData[index1];
double value2 = curveData[index2];
double output = (1.0 - interpolationFactor) * value1 + interpolationFactor * value2;
destination[i] = output;
}
}
示例6: lengthAttrGetter
static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.Float32Array.length._get");
Float32Array* imp = V8Float32Array::toNative(info.Holder());
return v8::Integer::NewFromUnsigned(imp->length());
}
示例7: valuesForTimeRangeImpl
//.........这里部分代码省略.........
case ParamEvent::ExponentialRampToValue:
{
currentTime = fillToTime;
// Simply stay at a constant value.
value = event.value();
for (; writeIndex < fillToFrame; ++writeIndex)
values[writeIndex] = value;
break;
}
case ParamEvent::SetTarget:
{
currentTime = fillToTime;
// Exponential approach to target value with given time constant.
float target = event.value();
float timeConstant = event.timeConstant();
float discreteTimeConstant = static_cast<float>(AudioUtilities::discreteTimeConstantForSampleRate(timeConstant, controlRate));
for (; writeIndex < fillToFrame; ++writeIndex) {
values[writeIndex] = value;
value += (target - value) * discreteTimeConstant;
}
break;
}
case ParamEvent::SetValueCurve:
{
Float32Array* curve = event.curve();
float* curveData = curve ? curve->data() : 0;
unsigned numberOfCurvePoints = curve ? curve->length() : 0;
// Curve events have duration, so don't just use next event time.
float duration = event.duration();
float durationFrames = duration * sampleRate;
float curvePointsPerFrame = static_cast<float>(numberOfCurvePoints) / durationFrames;
if (!curve || !curveData || !numberOfCurvePoints || duration <= 0 || sampleRate <= 0) {
// Error condition - simply propagate previous value.
currentTime = fillToTime;
for (; writeIndex < fillToFrame; ++writeIndex)
values[writeIndex] = value;
break;
}
// Save old values and recalculate information based on the curve's duration
// instead of the next event time.
unsigned nextEventFillToFrame = fillToFrame;
float nextEventFillToTime = fillToTime;
fillToTime = min(endTime, time1 + duration);
fillToFrame = AudioUtilities::timeToSampleFrame(fillToTime - startTime, sampleRate);
fillToFrame = min(fillToFrame, numberOfValues);
// Index into the curve data using a floating-point value.
// We're scaling the number of curve points by the duration (see curvePointsPerFrame).
float curveVirtualIndex = 0;
if (time1 < currentTime) {
// Index somewhere in the middle of the curve data.
// Don't use timeToSampleFrame() since we want the exact floating-point frame.
float frameOffset = (currentTime - time1) * sampleRate;
curveVirtualIndex = curvePointsPerFrame * frameOffset;
}