audioSetVolume (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, NX-400

Firmware version:

1.00.00


The audioSetVolume function is used to control both the volume level used by an audio node and also for muting the node.

The volume level does not refer to an absolute level and may vary between different device types.

Muting can be done separately from changing the volume, to make it easier to manage custom volume levels.

 

Input:

node: SINT Default 0

The audio node to change the volume for.

Available nodes:

Node

Name

Muted by default

0

Microphone

No

1

Line-out

No

2

Speaker

Yes

 

volume: SINT (-1,0..100) Default -1

Volume level, where 0 is the lowest and 100 is the highest volume. Setting it to -1 leaves it at its current value.

 

mute: BOOL Default OFF

Controls whether the node should be muted or not.

 

 

Returns: INT

0

- Operation was successful.

-1

- Invalid volume

-2

- Unknown node

-3

- Invalid configuration (microphone can not be enabled without either Line-out or Speaker enabled).

 

Declaration:

FUNCTION audioSetVolume : INT;
VAR_INPUT
  node   : SINT := 0;
  volume : SINT := -1;
  mute   : BOOL := OFF;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
 
...
BEGIN
  ...
  // Set the Line-out volume to 90%
  audioSetVolume(node:=1, volume := 90);
  // Mute the speaker and set its volume to 10%
  audioSetVolume(node:=2, volume := 10, mute := ON);
  // Route audio between GSM modem and audio jacks
  gsmHeadset(enable:=TRUE);
  ...
END;
 
END_PROGRAM;