Details of some of the internal controls.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

partonoffLock(int npart, int what)
  A semaphore locked version of:


partonoffWrite((int npart, int what)
  This sets or clears a part's status in one of 4 ways
  depending on the value of 'what'.

  Zero will always turn the part off, and 1 will always turn it on.

  -1 moves it toward off and 2 moves it towards on.

  The rationale here is that if a part status is unknown to a function, but it wants to perform an operation that needs the part to be off, but then wants to restore it to its original condition, it first uses -1. If it was already off it makes no difference, but if it was on it is now turned off. Once the operation has been completed it uses 2 to restore the original state, so if it was off, it still is, but if it was on it is now on again.

  The internal value will become progressively more negative as processes use -2 but will never become greater than +1 for 'on'

  If you want to set its state regardless of the previous setting (such as switching by a user) you use 0 and 1.


partonoffRead(int npart)
  This returns the part's current status as either 0 or 1.

  Be aware that the audio loop takes a copy of each part's state at the beginning of a period, and then uses that for all operations within that period, so any changes to partonoff will be ignored until the next period. This ensures there can be no inconsistencies.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Audio system Mute() / Unmute() / isMuted()
Although carying no parameters, Mute and Unmute behave in exactly the inverse way as PartonoffLock with 2 / -1.

mutewrite(int what) gives the full access as before, and isMuted() returns the current state.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

flagsWrite()
flagsRead()
flagsReadClear()

These functions provide a link from the realtime thread, to a low priority one.

This is now used for all the commands that need a fade-down and system mute. The flag is set with the required command at the end of the audio thread.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There is an integer written by the low priority 'indirect' thread and read only by main. This is only invoked when a new instance is started.
