---
title: roAudioOutput
slug: develop/roaudiooutput
docTags: 
createdAt: 2025-03-11T07:07:18.732Z
---

This object allows individual control of audio outputs on the player. The JavaScript equivalent is [audiooutput](docId\:lXzJ2B4sOLXTNXKXXkOb5).

Object Creation: The *roAudioOutput* object requires a single output parameter upon creation.

```text
CreateObject("roAudioOutput", output As String)
```

The `output` parameter can take the following strings:

- `“none”`
- `"hdmi”` or `"hdmi-1"`, `"hdmi-2"`, `"hdmi-3"`, or `"hdmi-4`" for Series 5 players with multiple outputs
- `“usb”`
- `“spdif”`
- `"analog"` 
- `“analog:N”` (N specifies the port enumeration, which is useful for models with multiple analog-audio ports; you can also use `"analog:1"` to specify the analog output on a model with a single analog-audio port)
- `"earc"` (AU335 only)
- Support for multiple USB outputs using the USB port naming terminology.&#x20;
  - `"usb:fid"` where `fid` is the device’s Friendly ID as documented here:  [roDeviceInfo-getusbtopology](docId\:uTKDmpos1ulxaoYLx1nS6)

:::ExpandableHeading{indent="1"}
**Getting the Friendly ID**

The `"usb:fid"` form requires knowing the fid of the USB audio device. The fid is derived from the physical port the device is connected to and can be discovered at runtime using`roDeviceInfo.GetUSBTopology()`. For a player with two ports, a device connected directly to a port will have a `fid` such as `A:0` or `B:0`. If a device is connected via a hub, it may have a fid such as `B/2.0`. The following example prints all USB audio device fids:

```none
di = CreateObject("roDeviceInfo")
topo = di.GetUSBTopology({xml: true})
print topo

' Example output for a device on port B:
'   <device>
'     <raw>4-1:1.0</raw>
'     <fid>B.0</fid>
'     <category>AUDIO</category>
'     ...
'   </device>
```
:::

You can create any number of *roAudioOutput* objects. There can be multiple instances of this object that represent the same audio output, but in these cases one object will override another.

To wire the `roAudioOutput` object to the player, see this `SetPcmAudioOutputs` usage example:&#x20;

:::ExpandableHeading{indent="1"}
**Getting a USB Audio Output**

To create a USB audio output, the fid string to pass to `CreateObject` is `"usb:" + fid`, e.g. `"usb:B.0"` for a device connected directly to port B, or `"usb:B/2.0"` for a device on a hub attached to port B. The `"usb:"` prefix is matched case-insensitively; the fid portion must match exactly the value returned by `GetUSBTopology()`. The USB audio topology must be established **before the player boots**. Connecting or disconnecting USB audio devices after boot is not supported and will not update the available audio routes. If a USB audio device is not present at boot time, `CreateObject("roAudioOutput", "usb:fid")` will return `Invalid` for that fid.

The following script shows how to route audio to a USB device, given that the `fid` of the device is known.

```none
' Create an audio output for the USB device on port B
usbOut = CreateObject("roAudioOutput", "usb:B.0")

' Create a player and direct its PCM output to the USB device
player = CreateObject("roAudioPlayer")
player.SetPcmAudioOutputs([usbOut])

' Multiple USB devices (e.g. port A and port B) can be passed together
usbOutA = CreateObject("roAudioOutput", "usb:A.0")
usbOutB = CreateObject("roAudioOutput", "usb:B.0")
player.SetPcmAudioOutputs([usbOutA, usbOutB])
player.PlayFile("sd:/my.mp3")
```
:::

## ifAudioOutput

### SetVolume(a As Integer) As Boolean

Sets the volume of the specified output as a percentage represented by an integer between 0 and 100.

### SetVolume(parameters As roAssociativeArray) As Boolean

Sets the volume of the specified output using the parameters passed:

- db: The required volume in decibels. Allowed values are up to 0.0, which represents full volume.

### SetTone(treble As Integer, bass As Integer) As Boolean

Sets the treble and bass of the specified output. The treble and bass integers can range from -1000 to 1000, with 0 indicating no modification to the audio signal. Each increment represents a change of 0.01db.

### SetMute(a As Boolean) As Boolean

Mutes the specified output if `True`. This method is set to `False` by default.

### GetOutput() As String

Returns the string with which the *roAudioOutput* object was created.

### SetAudioDelay(delay\_in\_milliseconds As Integer) As Boolean

Delays the audio for a specific audio output by lagging decoded samples before they reach that output. Delays are limited to 150ms or less. Currently, the system software only supports positive delays; therefore, if you need to set the audio ahead of the video, you will need to use *roVideoPlayer.SetVideoDelay()* instead.

### GetPlugState( ) As Boolean

This function returns `true` if the corresponding output has a plug in it, `false` if it does not, or `Invalid` if the plug state cannot be determined on the current hardware or OS version. This is supported only on MD435, MD455, EV445, EV455, XD236, XD1036, HD226 and HD1026 players in BOS 9.0.163 onwards.

The `SetVolume()` and `SetMute()` methods work in conjunction with the volume and mute functionality offered by *roAudioPlayer*. The *roAudioPlayer* volume settings affect the audio decoder volume. The audio stream is then sent to the assigned outputs, which have an additional level of volume control enabled by *roAudioOutput*.

The *roAudioOutput* object affects the absolute volume (as well as mute settings) for an audio output. If two players are streaming to the same output, both will be affected by any settings implemented through *roAudioOutput*.

:::hint{type="info"}
To control which audio outputs connect to audio player outputs generated by *roAudioOutput*, use the SetPcmAudioOutputs() and   SetCompressedAudioOutputs() methods, which can be used for *roVideoPlayer* and  *roAudioPlayer*. See the *roAudioPlayer* entry for further explanation of these methods.
:::

