processInto method
int
processInto(
- Float32List x,
- Float32List h,
- Float32List out, {
- ConvMode mode = ConvMode.convolution,
Computes into caller-provided out to avoid allocating a fresh output.
Returns the number of samples written.
out must be at least outLenFor(x.length, h.length) long.
Implementation
int processInto(
Float32List x,
Float32List h,
Float32List out, {
ConvMode mode = ConvMode.convolution,
}) {
final nx = x.length;
final nh = h.length;
final ny = outLenFor(nx, nh);
final r = res;
if (nx > xMax || nh > hMax) {
throw ArgumentError(
'input lengths exceed configured maxima (nx=$nx <= $xMax, nh=$nh <= $hMax)',
);
}
if (out.length < ny) {
throw ArgumentError('out length ${out.length} < required $ny');
}
_ensureXCapacity(nx);
_ensureHCapacity(nh);
_ensureYCapacity(ny);
r.xPtr.asTypedList(nx).setAll(0, x);
r.hPtr.asTypedList(nh).setAll(0, h);
final rc = yl_fftconv_ctx_process_f32(
r.ctx,
r.xPtr,
nx,
r.hPtr,
nh,
r.yPtr,
mode.value,
);
if (rc != 0) {
throw StateError('yl_fftconv_ctx_process_f32 failed with code $rc');
}
out.setRange(0, ny, r.yPtr.asTypedList(ny));
return ny;
}