createSoundChannel method

  1. @override
SynthizerSoundChannel createSoundChannel({
  1. SoundPosition position = unpanned,
  2. double gain = 0.7,
})
override

Get a sound channel.

Implementation

@override
SynthizerSoundChannel createSoundChannel({
  final SoundPosition position = unpanned,
  final double gain = 0.7,
}) {
  final Source source;
  if (position == unpanned) {
    source = context.createDirectSource();
  } else if (position is SoundPosition3d) {
    source = context.createSource3D(
      x: position.x,
      y: position.y,
      z: position.z,
    );
  } else if (position is SoundPositionAngular) {
    source = context.createAngularPannedSource(
      azimuth: position.azimuth,
      elevation: position.elevation,
    );
  } else if (position is SoundPositionScalar) {
    source = context.createScalarPannedSource(
      panningScalar: position.scalar,
    );
  } else {
    throw StateError('Cannot create a source for $position.');
  }
  return SynthizerSoundChannel(
    backend: this,
    source: source,
  )..gain = gain;
}