use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class MidiModule method parseNoteRepeat.
/**
* Parse note repeat parameters.
*
* @param path The rest of the path
* @param value The value
* @throws MissingCommandException Could not find the sub-command
* @throws UnknownCommandException Unknown sub-command
* @throws IllegalParameterException Added an illegal parameter
*/
private void parseNoteRepeat(final LinkedList<String> path, final Object value) throws MissingCommandException, UnknownCommandException, IllegalParameterException {
final INoteInput noteInput = this.surface.getMidiInput().getDefaultNoteInput();
if (noteInput == null)
return;
final INoteRepeat noteRepeat = noteInput.getNoteRepeat();
final String subCommand = getSubCommand(path);
switch(subCommand) {
case "isActive":
noteRepeat.setActive(toInteger(value) > 0);
break;
case "period":
if (value == null)
throw new IllegalParameterException("Value must not be empty.");
final Resolution period = Resolution.getByName(value.toString());
if (period == null)
throw new IllegalParameterException("Value must be one of {1/4, 1/4t, 1/8, 1/8t, 1/16, 1/16t, 1/32, 1/32t}.");
noteRepeat.setPeriod(period.getValue());
break;
case "length":
if (value == null)
throw new IllegalParameterException("Value must not be empty.");
final Resolution length = Resolution.getByName(value.toString());
if (length == null)
throw new IllegalParameterException("Value must be one of {1/4, 1/4t, 1/8, 1/8t, 1/16, 1/16t, 1/32, 1/32t}.");
noteRepeat.setNoteLength(length.getValue());
break;
default:
throw new UnknownCommandException(subCommand);
}
}
use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class SceneModule method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
if (!"scene".equals(command))
throw new UnknownCommandException(command);
final String sceneCommand = getSubCommand(path);
final ISceneBank sceneBank = this.model.getCurrentTrackBank().getSceneBank();
switch(sceneCommand) {
case "bank":
final String subCommand2 = getSubCommand(path);
switch(subCommand2) {
case "+":
if (isTrigger(value))
sceneBank.selectNextPage();
break;
case "-":
if (isTrigger(value))
sceneBank.selectPreviousPage();
break;
default:
throw new UnknownCommandException(subCommand2);
}
break;
case "+":
if (isTrigger(value))
sceneBank.scrollForwards();
break;
case "-":
if (isTrigger(value))
sceneBank.scrollBackwards();
break;
case "create":
if (isTrigger(value))
this.model.getProject().createSceneFromPlayingLauncherClips();
break;
case "add":
if (isTrigger(value))
this.model.getProject().createScene();
break;
default:
final int sceneIndex = Integer.parseInt(sceneCommand);
final IScene scene = sceneBank.getItem(sceneIndex - 1);
final String sceneCommand2 = getSubCommand(path);
switch(sceneCommand2) {
case "launch":
scene.launch();
break;
case TAG_DUPLICATE:
scene.duplicate();
break;
case TAG_REMOVE:
scene.remove();
break;
default:
throw new UnknownCommandException(sceneCommand2);
}
break;
}
}
use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class TransportModule method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
final boolean isTrigger = isTrigger(value);
switch(command) {
case "play":
final boolean isPlaying = this.transport.isPlaying();
if (isTrigger && !isPlaying || !isTrigger && isPlaying)
this.transport.play();
break;
case "playbutton":
if (isTrigger)
this.playCommand.execute(ButtonEvent.DOWN, 127);
break;
case "stop":
if (this.transport.isPlaying())
this.transport.stop();
else
this.transport.stopAndRewind();
break;
case "restart":
if (isTrigger)
this.transport.restart();
break;
case "record":
this.transport.startRecording();
break;
case "overdub":
if (!path.isEmpty() && TAG_LAUNCHER.equals(path.get(0)))
this.transport.toggleLauncherOverdub();
else
this.transport.toggleOverdub();
break;
case "repeat":
if (value == null)
this.transport.toggleLoop();
else
this.transport.setLoop(isTrigger);
break;
case "punchIn":
if (value == null)
this.transport.togglePunchIn();
else
this.transport.setPunchIn(isTrigger);
break;
case "punchOut":
if (value == null)
this.transport.togglePunchOut();
else
this.transport.setPunchOut(isTrigger);
break;
case "click":
if (path.isEmpty()) {
if (value == null)
this.transport.toggleMetronome();
else
this.transport.setMetronome(isTrigger);
break;
}
final String subCommand = getSubCommand(path);
switch(subCommand) {
case "volume":
this.transport.setMetronomeVolume(toInteger(value));
break;
case "ticks":
if (value == null)
this.transport.toggleMetronomeTicks();
else
this.transport.setMetronomeTicks(isTrigger);
break;
case TAG_PREROLL:
if (isTrigger)
this.transport.togglePrerollMetronome();
break;
default:
throw new UnknownCommandException(subCommand);
}
break;
case "quantize":
final IClip clip = this.getClip();
if (clip.doesExist())
clip.quantize(1);
break;
case "tempo":
final String tempoCommand = getSubCommand(path);
switch(tempoCommand) {
case "raw":
this.transport.setTempo(toNumber(value));
break;
case "tap":
if (isTrigger)
this.transport.tapTempo();
break;
case "+":
this.transport.setTempo(this.transport.getTempo() + toNumber(value, 1.0));
break;
case "-":
this.transport.setTempo(this.transport.getTempo() - toNumber(value, 1.0));
break;
default:
throw new UnknownCommandException(tempoCommand);
}
break;
case "time":
this.transport.setPosition(toNumber(value));
break;
case "position":
if (path.isEmpty()) {
final double numValue = toNumber(value);
this.transport.changePosition(numValue >= 0, Math.abs(numValue) <= 1);
break;
}
final String positionCommand = path.get(0);
switch(positionCommand) {
case "+":
this.transport.changePosition(true, true);
break;
case "-":
this.transport.changePosition(false, true);
break;
case "++":
this.transport.changePosition(true, false);
break;
case "--":
this.transport.changePosition(false, false);
break;
case "start":
this.transport.setPosition(0);
break;
default:
throw new UnknownCommandException(positionCommand);
}
break;
case "crossfade":
this.transport.setCrossfade(toInteger(value));
break;
case "autowrite":
if (!path.isEmpty() && TAG_LAUNCHER.equals(path.get(0)))
this.transport.toggleWriteClipLauncherAutomation();
else
this.transport.toggleWriteArrangerAutomation();
break;
case "automationWriteMode":
if (value != null)
this.transport.setAutomationWriteMode(AutomationMode.valueOf(value.toString().toUpperCase(Locale.US)));
break;
case TAG_PREROLL:
this.transport.setPrerollAsBars(toInteger(value));
break;
case TAG_LAUNCHER:
final String launcherCommand = path.get(0);
switch(launcherCommand) {
case "postRecordingAction":
this.transport.setClipLauncherPostRecordingAction(PostRecordingAction.lookup(value.toString()));
break;
case "postRecordingTimeOffset":
final double beats = Math.min(4000, Math.max(0, toNumber(value)));
this.transport.setClipLauncherPostRecordingTimeOffset(beats);
break;
case "defaultQuantization":
this.transport.setDefaultLaunchQuantization(LaunchQuantization.lookup(value.toString()));
break;
default:
throw new UnknownCommandException(launcherCommand);
}
break;
default:
throw new UnknownCommandException(command);
}
}
use of de.mossgrabers.controller.osc.exception.UnknownCommandException 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());
}
}
use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class ActionModule method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
if (!"action".equals(command))
throw new UnknownCommandException(command);
final String subCommand = getSubCommand(path);
try {
final int actionNo = Math.min(7, Math.max(0, Integer.parseInt(subCommand) - 1));
final String assignableActionID = this.configuration.getAssignableAction(actionNo);
if (assignableActionID != null)
this.model.getApplication().invokeAction(assignableActionID);
} catch (final NumberFormatException ex) {
throw new UnknownCommandException(subCommand);
}
}
Aggregations