Anytime Help Center

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Support
  • Guest
  • Log In
  • AKG
    Microphones Wireless Integrated Systems Automatic Mixers Headphones Discontinued Products (AKG) Video Manual Series (AKG) General AKG Inquiries Certifications (AKG)
  • AMX
    Networked A/V Distribution (AVoIP) Traditional A/V Distribution Video Signal Processing Architectural Connectivity User Interfaces Control Processing Power (AMX) Programming (AMX) Software (AMX) Discontinued Products (AMX) Video Manual Series (AMX) General AMX Inquiries Certifications (AMX)
  • BSS
    Soundweb™ Omni Soundweb™ London Soundweb™ Contrio™ Software (BSS) Discontinued Products (BSS) Video Manual Series (BSS) General BSS Inquiries Certifications (BSS)
  • Crown
    CDi DriveCore Series CDi Series Commercial Series ComTech Series DCi DriveCore Series I-Tech HD Series XLC series XLi Series XLS DriveCore 2 Series XTi 2 Series Software (Crown) Discontinued Products (Crown) Video Manual Series (Crown) General Crown Inquiries Certifications (Crown)
  • dbx
    CX Series 500 Series DriveRack Personal Monitor Control ZonePRO Zone Controllers FeedBack Suppression Microphone Preamps Dynamics Processors Crossovers Equalizers Software (dbx) Discontinued Products (dbx) General dbx Inquiries Certifications (dbx)
  • FLUX::
    Immersive Processing Analysis Subscriptions General FLUX: Inquiries
  • JBL
    Cinema Sound Installed Live Portable Tour Sound Recording & Broadcast Software (JBL) Discontinued Products (JBL) Video Manual Series (JBL) General JBL Inquiries Certifications (JBL)
  • Lexicon
    Plugins Effects Processors Cinema Discontinued Products (Lexicon) Video Manual Series (Lexicon) General Lexicon Inquiries Certifications (Lexicon)
  • Martin
    Atomic ELP ERA Exterior MAC Macula P3 VC VDO Tools Discontinued Products (Martin) General Martin Inquiries Certifications (Martin)
  • Soundcraft
    Digital Analog Connected Analog Only Discontinued Products (Soundcraft) Video Manual Series (Soundcraft) General Soundcraft Inquiries Certifications (Soundcraft)
  • General HARMAN Inquiries
    Dante
+ More
  • Home
  • AMX
  • Programming (AMX)
  • Muse

Script-as-Device Example

Coding Example


Written by Wesley Moore

Updated at September 2nd, 2026

Table of Contents

Brand: Models/Languages: Overview: Usage:  Downloads:  Code: 

Brand:

  • AMX

Models/Languages:

  • MUSE
    • Python
    • Automator

Overview:

Exporting script functionality, also known as script-as-device, allows you to expose portions of your script to other scripts in the form of a virtual device.  Exposing portions of your control scripts can allow other scripts or controllers to access devices outside of their normal scope.  It can allow the creation of programs that monitor other programs and the states of their devices for centralized monitoring, or possibly utilize touch points of other programs in combine/uncombine spaces.  Instead of creating logic for every combination of a space, you could simply access those control points necessary to organize the space to the desired configuration.


Usage: 

  • Utilizing this functionality requires three pieces of code
    • Descriptor - Expanding the default program.json file of a MUSE program allows you to create your own descriptor files that, through the virtual device, inform other programs how the device is to be used.
    • Script-as-Device Program - This is the script that utilizes the program.json descriptor file to create a virtual device.  It's then used to process changes to parameters, run commands, and report events.
      • context.export - Object used to report changes in parameters or events to other scripts.
        • context.export.update(path, value) - Method used when updating parameters to other scripts.
        • context.export.dispatch(path, args) - Method used when updating events to other scripts.
      • set(path, value) & call(path, args) - Default functions for parameters and events, respectively.  If no specific function name is called out in the descriptor, these are the functions that are utilized when a parameter is changed on a device or a command is called.
    • Interface Program - Basic script written to control the created virtual device like any other device on a MUSE controller.  
  • For further information on creating Descriptors, see the Device Descriptor Guide on the help site.

Downloads: 

Script-as-Device.zip


Code: 

Descriptor (Driver/program.json)

{
  ".metadata" : {
    "id": "Driver",
    "name": "Driver",
    "description": "description",
    "disabled": false,
    "provider": "python",
    "scope": "",
    "script": "index.py",
    "envvars": {}
  },

  "led": {
    ".kind": "array",
    ".prototype": {
      ".kind": "param",
      ".type": "enum",
      ".enums": ["OFF", "ON"],
      ".metadata": { 
        "setter" : "setLED"
      }         
    },
    ".size": 5     
  }, 

  "setAllLeds": {
    ".kind": "command",
    ".arguments": { 
      "value": {  
        ".type": "enum", 
        ".enums": ["OFF", "ON"]
      }
    }     
  }, 

  "power": { 
    ".kind": "param",
    ".type": "boolean"
  }, 

  "status": {
    ".kind": "event",
    ".arguments": {
      "communications": {
        ".type": "string"
      }
    }
  }
}

 

Script-as-Device (Driver/index.py)

from mojo import context

context.log.info('Sample Python program')

dvTP = context.devices.get("dvTP")

export = context.export

def set(path,value):
    context.log.info(f"Setting {path} to {value}")
    export.update(path,value)

def call(path,args):
    context.log.info(f"Calling {path} with argument {args.get('value')}")
    export.update(path,args)

def setLED(path,value):
    context.log.info(f"Setting LED at {path} to {value}")
    export.update(path,value)

def status(event):
    if(event.value):
        communications = "ONLINE"
        context.log.info(f"Status is set to {communications}")
        export.dispatch("status", {"communications":communications})
    else:
        communications = "OFFLINE"
        context.log.info(f"Status is set to {communications}")
        export.dispatch("status", {"communications":communications})

dvTP.port[1].button[1].watch(status)

# leave this as the last line in the Python script
context.run(globals())

 

Interface (Interface Program/index.py)

from mojo import context

context.log.info('Sample Python program')

dvTP = context.devices.get("dvTP")
dvDriver = context.devices.get("Driver")

def ledSet(event):
    if(event.value):
        dvDriver.led[1].value = "ON"
    else:
        dvDriver.led[1].value = "OFF"

dvTP.port[1].button[2].watch(ledSet)

def led1Watch(event):
    context.log.info(f"LED 1 changed: {event.value}")

dvDriver.led[1].watch(led1Watch)

def allLEDs(event):
    if(event.value):
        dvDriver.setAllLeds("ON")
    else:
        dvDriver.setAllLeds("OFF")

dvTP.port[1].button[3].watch(allLEDs)

def powerFunc(event):
    if(event.value):
        dvDriver.power.value = True
    else:
        dvDriver.power.value = False

dvTP.port[1].button[4].watch(powerFunc)

def powerChange(event):
    context.log.info(f"Power value changed to {event.value}")

dvDriver.power.watch(powerChange)


def statusEvent(event):
    context.log.info(f"Incoming status event: {event.__dict__}")

dvDriver.status.listen(statusEvent)



# leave this as the last line in the Python script
context.run(globals())

 

Related Videos

Was this article helpful?

Yes
No
Give feedback about this article

Table of Contents

Brand: Models/Languages: Overview: Usage:  Downloads:  Code: 

Related Articles

  • Muse Mutually Exclusive helper
  • File Read Write with MUSE
  • MUSE Controller-to-Controller Programming with Python
  • Controlling CE-REL8 Relay Ports with Python Code
  • Controlling MUSE Relay Ports with Python Code

Related Articles

  • Muse Mutually Exclusive helper
  • File Read Write with MUSE
  • MUSE Controller-to-Controller Programming with Python
  • Controlling CE-REL8 Relay Ports with Python Code
  • Controlling MUSE Relay Ports with Python Code
Copyright © HARMAN Professional. All rights reserved. Privacy Policy | Terms of Use
Expand