loadWaveform method

Future<AudioSource> loadWaveform(
  1. WaveForm waveform,
  2. bool superWave,
  3. double scale,
  4. double detune,
)

Load a new waveform to be played once or multiple times later.

Specify the type of the waveform (such as sine or square or saw) with waveform.

You must also specify if the waveform should be a superWave, and what the superwave's scale and detune should be.

Throws SoLoudNotInitializedException if the engine is not initialized.

Returns the new sound as AudioSource.

Implementation

Future<AudioSource> loadWaveform(
  WaveForm waveform,
  bool superWave,
  double scale,
  double detune,
) async {
  if (!isInitialized) {
    throw const SoLoudNotInitializedException();
  }
  final ret = _controller.soLoudFFI.loadWaveform(
    waveform,
    superWave,
    scale,
    detune,
  );

  if (ret.error == PlayerErrors.noError) {
    final newSound = AudioSource(ret.soundHash);
    _activeSounds.add(newSound);
    return newSound;
  }
  _logPlayerError(ret.error, from: 'loadWaveform() result');
  throw SoLoudCppException.fromPlayerError(ret.error);
}