start method
Starts capturing audio from the device microphone.
Set enableFFT to true to receive frequency spectrum data in the stream.
Keep streamBytes false for lightweight visualizers that only need FFT.
Implementation
Future<bool> start({
bool enableFFT = false,
bool streamBytes = false,
int updateIntervalMs = 80,
bool autoRequestPermission = true,
}) async {
if (updateIntervalMs <= 0) {
throw ArgumentError.value(
updateIntervalMs,
'updateIntervalMs',
'Must be greater than zero.',
);
}
if (autoRequestPermission) {
final granted = await NexoraSdkPlatform.instance.requestAudioPermission();
if (!granted) return false;
}
final success = await NexoraSdkPlatform.instance.startAudio(
enableFFT: enableFFT,
streamBytes: streamBytes,
updateIntervalMs: updateIntervalMs,
);
if (success) {
_isRunning = true;
_lastEnableFFT = enableFFT;
_lastStreamBytes = streamBytes;
_lastUpdateIntervalMs = updateIntervalMs;
}
return success;
}