Skip to main content

getVariations

Added in 6.5.0

Get the ids of the takes behind a variation name, in the order you gave them to createVariations.

getVariations(id: string): string[] | undefined;

Parameters​

ParameterTypeDefaultDescription
idstringrequiredThe variation name.

Returns​

string[] | undefined: the ids of the takes, or undefined when there is no variation by that name.

Example​

soundHub.createVariations('footstep', ['step1', 'step2', 'step3']);

soundHub.getVariations('footstep'); // ['step1', 'step2', 'step3']
soundHub.getVariations('music'); // undefined, a sound and not a variation name

Preload only what a set needs​

const takes = soundHub.getVariations('footstep') ?? [];
const missing = takes.filter((id) => !soundHub.isSoundLoaded(id));

Good to know​

  • The array is a copy. Changing it does not change the set. Call createVariations again to change the takes.
  • Use it to tell a variation name from a sound id: hasSound is false for a variation name.

See also​