position property
Get the position of source.
Implementation
@override
SoundPosition get position {
final s = source;
if (s is DirectSource) {
return unpanned;
} else if (s is Source3D) {
final p = s.position.value;
return SoundPosition3d(x: p.x, y: p.y, z: p.z);
} else if (s is AngularPannedSource) {
return SoundPositionAngular(
azimuth: s.azimuth.value,
elevation: s.elevation.value,
);
} else if (s is ScalarPannedSource) {
return SoundPositionScalar(scalar: s.panningScalar.value);
} else {
throw UnimplementedError('Cannot handle source $s.');
}
}
Set the source position.
Implementation
@override
set position(final SoundPosition value) {
final s = source;
if (s is DirectSource) {
throw UnimplementedError(
'You cannot set the `position` for an unpanned source.',
);
} else if (s is Source3D) {
if (value is! SoundPosition3d) {
throw PositionMismatchError(this, value);
}
s.position.value = Double3(value.x, value.y, value.z);
} else if (s is AngularPannedSource) {
if (value is! SoundPositionAngular) {
throw PositionMismatchError(this, value);
}
s
..azimuth.value = value.azimuth
..elevation.value = value.elevation;
} else if (value is SoundPositionScalar) {
if (s is! ScalarPannedSource) {
throw PositionMismatchError(this, value);
}
s.panningScalar.value = value.scalar;
} else {
throw UnimplementedError('Cannot handle sound position $value.');
}
}