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
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | required | The 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
createVariationsagain to change the takes. - Use it to tell a variation name from a sound id:
hasSoundisfalsefor a variation name.
See also
createVariations: make a variation name.removeVariations: forget it again.