playSound method

  1. @override
SynthizerSound playSound({
  1. required AssetReference assetReference,
  2. bool keepAlive = false,
  3. double? gain,
  4. bool looping = false,
  5. double pitchBend = 1.0,
})
override

Play a sound with the given assetReference.

Implementation

@override
SynthizerSound playSound({
  required final AssetReference assetReference,
  final bool keepAlive = false,
  final double? gain,
  final bool looping = false,
  final double pitchBend = 1.0,
}) {
  final buffer = backend.bufferCache.getBuffer(assetReference);
  final generator = context.createBufferGenerator()
    ..gain.value = gain ?? assetReference.gain
    ..looping.value = looping
    ..pitchBend.value = pitchBend
    ..buffer.value = buffer;
  source.addGenerator(generator);
  configureLinger(generator: generator, keepAlive: keepAlive);
  return SynthizerSound(
    backend: backend,
    channel: this,
    keepAlive: keepAlive,
    generator: generator,
  );
}