extract static method

Stream<WaveformProgress> extract({
  1. required File audioInFile,
  2. required File waveOutFile,
  3. WaveformZoom zoom = const WaveformZoom.pixelsPerSecond(100),
})

Extract a Waveform from audioInFile and write it to waveOutFile at the specified zoom level.

Implementation

// XXX: It would be better to return a stream of the actual [Waveform], with
// progress => wave.data.length / (wave.length*2)
static Stream<WaveformProgress> extract({
  required File audioInFile,
  required File waveOutFile,
  WaveformZoom zoom = const WaveformZoom.pixelsPerSecond(100),
}) {
  final progressController = StreamController<WaveformProgress>.broadcast();
  _progressControllers[waveOutFile.path] = progressController;

  progressController.add(WaveformProgress._(0.0, null));
  _channel.invokeMethod('extract', {
    'audioInPath': audioInFile.path,
    'waveOutPath': waveOutFile.path,
    'samplesPerPixel': zoom._samplesPerPixel,
    'pixelsPerSecond': zoom._pixelsPerSecond,
  }).catchError(progressController.addError);
  return progressController.stream;
}