setDynamicEq method

void setDynamicEq({
  1. required bool enable,
  2. required List<ViperDynamicEqBand> bands,
})

Dynamic EQ (up to 8 bands).

Implementation

void setDynamicEq({
  required bool enable,
  required List<ViperDynamicEqBand> bands,
}) {
  if (_enginePtr == ffi.nullptr) return;

  int count = bands.length;
  if (count > 8) count = 8;

  final ptr = _malloc(count * 7 * ffi.sizeOf<ffi.Float>()).cast<ffi.Float>();

  try {
    final list = ptr.asTypedList(count * 7);
    for (int i = 0; i < count; i++) {
      bands[i].writeToArray(list, i * 7);
    }

    _dynamicEq(_enginePtr, enable ? 1 : 0, count, ptr);
  } finally {
    _freePtr(ptr.cast<ffi.Void>());
  }
}