Skip to content

pokowaka/xmc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emotiva XMC-1 Control Library (xmc)

A Java library to control the Emotiva XMC-1 audio processor over the network protocol.

Features

  • Discovery: Automatically discover XMC-1 devices on the local network using UDP broadcast.
  • Control: Send commands to the device (volume, source, mute, modes, etc.).
  • Status Subscription: Subscribe to state changes and receive real-time updates from the device.

Requirements

  • Java 17 or higher
  • Gradle (wrapper included)

Building the Library

To build the library, run the following command in the project root:

./gradlew build

This will compile the code and run any tests. The resulting JAR file will be in build/libs/.

Usage Example

The following example shows how to discover a device, listen for state changes, and send a command. This is based on the Sample.java file.

import net.pokowaka.xmc.interactions.XmcState;
import net.pokowaka.xmc.interactions.ValueCommand;
import net.pokowaka.xmc.io.Xmc;
import net.pokowaka.xmc.io.XmcDiscovery;
import java.io.IOException;
import java.util.HashMap;

public class Sample {
    public static void main(String[] args) throws IOException, InterruptedException {
        // Discover the XMC-1 on the network
        Xmc xmc = XmcDiscovery.discover();

        if (xmc == null) {
            System.out.println("Cannot find Xmc-1");
            return;
        }

        // Register for state change events
        xmc.addXmc1StateListener((device, oldState, newState) -> {
            System.out.println("State Changed!");
            System.out.println("Old: " + oldState);
            System.out.println("New: " + newState);
        });

        // Subscribe to all states to receive updates
        xmc.subscribe(XmcState.values());

        // Send a command (e.g., increase volume by 1 step)
        xmc.send(ValueCommand.volume, 1);

        // Sleep for a while to receive updates...
        Thread.sleep(10000);

        // Clean up
        xmc.unsubscribe(XmcState.values());
        xmc.stop();
    }
}

Commands

There are two types of commands:

  1. SimpleCommand: Parameterless commands (e.g. mute, power_on, hdmi1).
    xmc.send(SimpleCommand.mute_on);
  2. ValueCommand: Commands that take a parameter (e.g. volume change, set_volume).
    xmc.send(ValueCommand.set_volume, -20); // Set volume to -20dB

Subscriptions

To receive updates for specific states, you must subscribe to them. Supported states are defined in XmcState enum (e.g. volume, source, power, audio_input, etc.).

Command Line Interface (CLI) Usage

The library includes a command-line interface to control the receiver directly. Since the application plugin is configured, you can execute commands using the Gradle wrapper.

Running via Gradle

Run the following command structure:

./gradlew run --args="[options]"

Examples:

  1. Print Current Status:

    ./gradlew run --args="--status"

    Output will display a list of all active receiver states (volume, source, power, audio mode, etc.).

  2. Power Control:

    # Turn Power On
    ./gradlew run --args="--power on"
    
    # Turn Power Off
    ./gradlew run --args="--power off"
  3. Source Input Selection:

    # Switch to HDMI 1
    ./gradlew run --args="--source hdmi1"
    
    # Switch to Tuner
    ./gradlew run --args="--source tuner"
  4. Volume Control:

    # Set Volume to specific dB level
    ./gradlew run --args="--volume -20"
    
    # Increment volume up/down by 1dB
    ./gradlew run --args="--volume-up"
    ./gradlew run --args="--volume-down"
  5. Mute Control:

    # Mute Audio
    ./gradlew run --args="--mute on"
    
    # Unmute Audio
    ./gradlew run --args="--mute off"
    
    # Toggle Mute
    ./gradlew run --args="--mute toggle"
  6. Chaining Commands: You can combine options to perform multiple operations at once:

    ./gradlew run --args="--power on --source hdmi2 --volume -25"
  7. Direct IP Connection (Bypass Discovery): By default, the tool uses UDP broadcast to find the device. If discovery fails or is blocked on your network, you can specify the IP address directly:

    ./gradlew run --args="--host 192.168.1.50 --status"
  8. Verbose Debug Logging: By default, the CLI is quiet. You can enable internal logs for troubleshooting:

    ./gradlew run --args="--status --verbose"

Building a standalone distribution

If you want to run it without Gradle, build the distribution:

./gradlew installDist

This generates startup scripts in build/install/xmc/bin/. You can then run:

./build/install/xmc/bin/xmc --status

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

About

A library to control the emotiva xmc-1 using the network protocol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages