A Java library to control the Emotiva XMC-1 audio processor over the network protocol.
- 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.
- Java 17 or higher
- Gradle (wrapper included)
To build the library, run the following command in the project root:
./gradlew buildThis will compile the code and run any tests. The resulting JAR file will be in build/libs/.
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();
}
}There are two types of commands:
- SimpleCommand: Parameterless commands (e.g.
mute,power_on,hdmi1).xmc.send(SimpleCommand.mute_on);
- ValueCommand: Commands that take a parameter (e.g.
volumechange,set_volume).xmc.send(ValueCommand.set_volume, -20); // Set volume to -20dB
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.).
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.
Run the following command structure:
./gradlew run --args="[options]"-
Print Current Status:
./gradlew run --args="--status"Output will display a list of all active receiver states (volume, source, power, audio mode, etc.).
-
Power Control:
# Turn Power On ./gradlew run --args="--power on" # Turn Power Off ./gradlew run --args="--power off"
-
Source Input Selection:
# Switch to HDMI 1 ./gradlew run --args="--source hdmi1" # Switch to Tuner ./gradlew run --args="--source tuner"
-
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"
-
Mute Control:
# Mute Audio ./gradlew run --args="--mute on" # Unmute Audio ./gradlew run --args="--mute off" # Toggle Mute ./gradlew run --args="--mute toggle"
-
Chaining Commands: You can combine options to perform multiple operations at once:
./gradlew run --args="--power on --source hdmi2 --volume -25" -
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" -
Verbose Debug Logging: By default, the CLI is quiet. You can enable internal logs for troubleshooting:
./gradlew run --args="--status --verbose"
If you want to run it without Gradle, build the distribution:
./gradlew installDistThis generates startup scripts in build/install/xmc/bin/. You can then run:
./build/install/xmc/bin/xmc --statusThis project is licensed under the Apache 2.0 License - see the LICENSE file for details.