Example threaded script - power up mute delay

This example uses a Live Python threaded script to mute the audio outputs of a NION as soon as the project starts running. The unit is then kept muted until a set time has elapsed, allowing other devices in the system, like amps, for example, to finish their own boot up sequence, which could take longer.

Using a Live Python block allows the code to run immediately – as soon as the NION powers up – and mute the outputs before performing any other functions, and without user interaction.

The project contains a NioNode block with the controls on the Mute tab copied out to the design page. The Unit mute (for the individual NION) is wired to a control block, which will control when the NION is muted.

Note: The unit mute is used, rather than the system mute. This is because different NIONs in a project may take different lengths of time to start up. Attempting to mute all the NIONs in the project at the same time using the system mute may result in only some of the units being muted.

Inside the Power Up Mute Delay block, a control with a delay value (8000 milliseconds) is wired to the input on the Live Python block. This is the length of time the control output on the Live Python block will remain set to 1 (muting the NION) before being set to 0 (unmuting the NION).

The Live Python code sets the output on the block to 1 to action the mute immediately. It then waits for the length of time specified by the wired input control. Finally, it sets the output on the block to 0 to switch off the mute.

outputs[0].value_set(1)
event.wait(inputs[0].value_get())
outputs[0].value_set(0)

Note: Most threaded scripts are configured to run continuously in the background, using a loop and the event.wait() statement. This example, however, is designed to run only once, at start up.

See also

Syntax and structure of a threaded script

Example threaded script - counter