getAudioBufferReader method

Future<Vst3AudioBufferReader?> getAudioBufferReader({
  1. bool forceRefresh = false,
})

Obtains direct zero-copy read access to the audio buffers in shared memory.

Implementation

Future<Vst3AudioBufferReader?> getAudioBufferReader(
    {bool forceRefresh = false}) async {
  if (_audioReader != null && !forceRefresh) return _audioReader;
  try {
    final info = await _channel
        .invokeMapMethod<String, dynamic>('getSharedMemoryInfo');
    if (info != null) {
      final addr = (info['address'] as num?)?.toInt() ?? 0;
      _audioReader = Vst3AudioBufferReader.fromAddress(addr);
      _setDspStopped(addr != 0 && _audioReader == null);
    }
  } on MissingPluginException {
    // Standalone Flutter has no host channel.
  }
  return _audioReader;
}