use of de.mossgrabers.controller.osc.module.IModule in project DrivenByMoss by git-moss.
the class OSCControllerSetup method createSurface.
/**
* {@inheritDoc}
*/
@Override
protected void createSurface() {
final IMidiAccess midiAccess = this.factory.createMidiAccess();
final IMidiInput input = midiAccess.createInput("OSC");
final OSCControlSurface surface = new OSCControlSurface(this.host, this.configuration, this.colorManager, input);
surface.addTextDisplay(new DummyDisplay(this.host));
this.surfaces.add(surface);
this.keyManager = new KeyManager(this.model, this.model.getScales(), surface.getPadGrid());
// Send OSC messages
final String sendHost = this.configuration.getSendHost();
final int sendPort = this.configuration.getSendPort();
this.host.println(String.format("Connecting to OSC server %s:%d", sendHost, Integer.valueOf(sendPort)));
final IOpenSoundControlClient oscClient = this.host.connectToOSCServer(sendHost, sendPort);
this.writer = new OSCWriter(this.host, this.model, oscClient, this.configuration);
// Receive OSC messages
final OSCParser parser = new OSCParser(this.host, surface, this.model, this.configuration, this.writer, input, this.keyManager);
final List<IModule> modules = new ArrayList<>();
modules.add(new TransportModule(this.host, this.model, surface, this.writer));
modules.add(new GlobalModule(this.host, this.model, this.writer));
modules.add(new LayoutModule(this.host, this.model, this.writer));
modules.add(new MarkerModule(this.host, this.model, this.writer));
modules.add(new ProjectModule(this.host, this.model, this.writer));
modules.add(new TrackModule(this.host, this.model, this.writer, this.configuration));
modules.add(new SceneModule(this.host, this.model, this.writer));
modules.add(new DeviceModule(this.host, this.model, this.writer, this.configuration));
modules.add(new BrowserModule(this.host, this.model, this.writer));
modules.add(new MidiModule(this.host, this.model, surface, this.writer, this.keyManager));
modules.add(new UserModule(this.host, this.model, this.writer));
modules.add(new ActionModule(this.host, this.model, this.writer, this.configuration));
modules.add(new ClipModule(this.host, this.model, this.writer));
modules.forEach(module -> {
this.writer.registerModule(module);
parser.registerModule(module);
});
this.oscServer = this.host.createOSCServer(parser);
}
use of de.mossgrabers.controller.osc.module.IModule in project DrivenByMoss by git-moss.
the class OSCParser method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(final IOpenSoundControlMessage message) {
this.logMessage(message);
final LinkedList<String> oscParts = parseAddress(message);
if (oscParts.isEmpty())
return;
final String command = oscParts.removeFirst();
if ("refresh".equals(command)) {
this.writer.flush(true);
return;
}
final Object[] values = message.getValues();
try {
final IModule module = this.modules.get(command);
if (module == null)
throw new UnknownCommandException(command);
if (values != null && values.length > 1)
module.execute(command, oscParts, values);
else
module.execute(command, oscParts, values == null || values.length == 0 ? null : values[0]);
} catch (final IllegalParameterException ex) {
this.host.println("Illegal parameter: " + message.getAddress() + " " + ex.getMessage());
} catch (final UnknownCommandException ex) {
this.host.println("Unknown OSC command: " + message.getAddress() + " " + ex.getMessage());
} catch (final MissingCommandException ex) {
this.host.println("Missing command: " + message.getAddress());
}
}
Aggregations