roAudioOutput
7 min
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 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 "usb\ fid" where fid is the device’s friendly id as documented here rodeviceinfo getusbtopology docid\ utkdmpos1ulxaoylx1ns6 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 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 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 ' 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 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