getPreviousMasterPan
Get the master pan value from before the last change. Use it to restore the pan after a temporary change or a reset.
getPreviousMasterPan(): number;
Parameters
This method takes no parameters.
Returns
number: the master pan before the last setGlobalPan or resetGlobalPan, from -1 to 1. Before any change it is defaultPan from the hub config, 0 when not set.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('music', '/audio/theme.mp3');
soundHub.setGlobalPan(0.5); // pan right
soundHub.resetGlobalPan(); // back to the centre
// Put the old value back
soundHub.setGlobalPan(soundHub.getPreviousMasterPan()); // 0.5 again
Good to know
- Only the master pan is tracked. There is no previous value per sound.
- Only one step is kept. Every
setGlobalPanoverwrites it, including the one insideresetGlobalPan. - This method exists on the
SoundHubclass but is not declared onSoundHubInterface, so code typed against the interface cannot see it.
See also
setGlobalPan: change the master pan.getGlobalPan: the current master pan.