Skip to main content

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 setGlobalPan overwrites it, including the one inside resetGlobalPan.
  • This method exists on the SoundHub class but is not declared on SoundHubInterface, so code typed against the interface cannot see it.

See also​