use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class LayoutModule method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
switch(command) {
case "layout":
this.model.getApplication().setPanelLayout(toString(value).toUpperCase(Locale.US));
break;
case "panel":
final String subCommand = getSubCommand(path);
final IApplication app = this.model.getApplication();
switch(subCommand) {
case "noteEditor":
app.toggleNoteEditor();
break;
case "automationEditor":
app.toggleAutomationEditor();
break;
case "devices":
app.toggleDevices();
break;
case TAG_MIXER:
app.toggleMixer();
break;
case "fullscreen":
app.toggleFullScreen();
break;
default:
throw new UnknownCommandException(subCommand);
}
break;
case "arranger":
final String subCommand2 = getSubCommand(path);
final IArranger arrange = this.model.getArranger();
switch(subCommand2) {
case "cueMarkerVisibility":
arrange.toggleCueMarkerVisibility();
break;
case "playbackFollow":
arrange.togglePlaybackFollow();
break;
case "trackRowHeight":
arrange.toggleTrackRowHeight();
break;
case "clipLauncherSectionVisibility":
arrange.toggleClipLauncher();
break;
case "timeLineVisibility":
arrange.toggleTimeLine();
break;
case "ioSectionVisibility":
arrange.toggleIoSection();
break;
case "effectTracksVisibility":
arrange.toggleEffectTracks();
break;
default:
throw new UnknownCommandException(subCommand2);
}
break;
case TAG_MIXER:
final String subCommand3 = getSubCommand(path);
final IMixer mix = this.model.getMixer();
switch(subCommand3) {
case "clipLauncherSectionVisibility":
mix.toggleClipLauncherSectionVisibility();
break;
case "crossFadeSectionVisibility":
mix.toggleCrossFadeSectionVisibility();
break;
case "deviceSectionVisibility":
mix.toggleDeviceSectionVisibility();
break;
case "sendsSectionVisibility":
mix.toggleSendsSectionVisibility();
break;
case "ioSectionVisibility":
mix.toggleIoSectionVisibility();
break;
case "meterSectionVisibility":
mix.toggleMeterSectionVisibility();
break;
default:
throw new UnknownCommandException(subCommand3);
}
break;
default:
throw new UnknownCommandException(command);
}
}
use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class MidiModule method parseMidi.
/**
* Parse virtual MIDI note commands.
*
* @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 parseMidi(final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
final OSCConfiguration conf = this.surface.getConfiguration();
final String command = getSubCommand(path);
switch(command) {
case "velocity":
final int numValue = toInteger(value);
conf.setAccentEnabled(numValue > 0);
if (numValue > 0)
conf.setFixedAccentValue(numValue);
return;
case "noterepeat":
this.parseNoteRepeat(path, value);
return;
default:
// Fall through
break;
}
int midiChannel;
try {
midiChannel = Math.min(Math.max(0, Integer.parseInt(command) - 1), 15);
} catch (final NumberFormatException ex) {
throw new UnknownCommandException(command);
}
final String subCommand = getSubCommand(path);
final IMidiInput input = this.surface.getMidiInput();
final Scales scales = this.model.getScales();
switch(subCommand) {
case "note":
if (path.isEmpty()) {
final Object[] array = (Object[]) value;
final int note = ((Number) array[0]).intValue();
final int velocity = ((Number) array[1]).intValue();
this.sendNote(conf, midiChannel, input, note, velocity);
return;
}
final String n = getSubCommand(path);
switch(n) {
case "+":
if (isTrigger(value)) {
scales.incOctave();
this.updateNoteMatrix(scales);
}
break;
case "-":
if (isTrigger(value)) {
scales.decOctave();
this.updateNoteMatrix(scales);
}
break;
default:
this.sendNote(conf, midiChannel, input, Integer.parseInt(n), toInteger(value));
break;
}
break;
case "drum":
final String n2 = getSubCommand(path);
switch(n2) {
case "+":
if (isTrigger(value)) {
scales.incDrumOctave();
this.surface.getDisplay().notify(scales.getDrumRangeText());
}
break;
case "-":
if (isTrigger(value)) {
scales.decDrumOctave();
this.surface.getDisplay().notify(scales.getDrumRangeText());
}
break;
default:
final int note = Integer.parseInt(n2);
int numValue = toInteger(value);
if (numValue > 0)
numValue = conf.isAccentActive() ? conf.getFixedAccentValue() : numValue;
final int data0 = this.model.getScales().getDrumMatrix()[note];
if (data0 >= 0)
input.sendRawMidiEvent(0x90 + midiChannel, data0, numValue);
break;
}
break;
case "cc":
if (path.isEmpty()) {
this.host.println("Missing MIDI CC value.");
return;
}
final int cc = Integer.parseInt(path.removeFirst());
input.sendRawMidiEvent(0xB0 + midiChannel, cc, toInteger(value));
break;
case "aftertouch":
int numValue = toInteger(value);
if (numValue > 0)
numValue = conf.isAccentActive() ? conf.getFixedAccentValue() : numValue;
if (path.isEmpty()) {
input.sendRawMidiEvent(0xD0 + midiChannel, 0, numValue);
return;
}
final int note = Integer.parseInt(path.removeFirst());
input.sendRawMidiEvent(0xA0 + midiChannel, this.surface.getKeyTranslationTable()[note], numValue);
break;
case "pitchbend":
input.sendRawMidiEvent(0xE0 + midiChannel, 0, toInteger(value));
break;
default:
throw new UnknownCommandException(command);
}
}
use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class BrowserModule method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
if (!"browser".equals(command))
throw new UnknownCommandException(command);
final String subCommand = getSubCommand(path);
final IBrowser browser = this.model.getBrowser();
switch(subCommand) {
case "preset":
browser.replace(this.model.getCursorDevice());
break;
case "tab":
if (!browser.isActive())
return;
final String subCmd = getSubCommand(path);
if ("+".equals(subCmd))
browser.nextContentType();
else if ("-".equals(subCmd))
browser.previousContentType();
break;
case "device":
final String insertLocation = path.isEmpty() ? null : path.removeFirst();
if (insertLocation == null || "after".equals(insertLocation))
browser.insertAfterCursorDevice();
else
browser.insertBeforeCursorDevice();
break;
case "commit":
browser.stopBrowsing(true);
break;
case "cancel":
browser.stopBrowsing(false);
break;
case "filter":
final String indexCmd = getSubCommand(path);
int column = Integer.parseInt(indexCmd);
if (column < 1 || column > 6)
return;
column = column - 1;
if (!browser.isActive())
return;
final String cmd = getSubCommand(path);
if ("+".equals(cmd))
browser.selectNextFilterItem(column);
else if ("-".equals(cmd))
browser.selectPreviousFilterItem(column);
else if ("reset".equals(cmd))
browser.getFilterColumn(column).resetFilter();
break;
case "result":
if (!browser.isActive())
return;
final String direction = path.isEmpty() ? "+" : path.removeFirst();
if ("+".equals(direction))
browser.selectNextResult();
else
browser.selectPreviousResult();
break;
default:
throw new UnknownCommandException(command);
}
}
use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class ProjectModule method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final String command, final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
if (!"project".equals(command))
throw new UnknownCommandException(command);
final String subCommand = getSubCommand(path);
final IProject project = this.model.getProject();
switch(subCommand) {
case "+":
project.next();
break;
case "-":
project.previous();
break;
case "engine":
if (value == null)
this.model.getApplication().toggleEngineActive();
else
this.model.getApplication().setEngineActive(isTrigger(value));
break;
case "save":
project.save();
break;
default:
throw new UnknownCommandException(subCommand);
}
}
use of de.mossgrabers.controller.osc.exception.UnknownCommandException in project DrivenByMoss by git-moss.
the class UserModule method parseUserValue.
private void parseUserValue(final LinkedList<String> path, final Object value) throws UnknownCommandException, MissingCommandException, IllegalParameterException {
final IParameterBank parameterBank = this.model.getUserParameterBank();
final String subCommand = getSubCommand(path);
try {
final int paramNo = Integer.parseInt(subCommand) - 1;
parseFXParamValue(parameterBank.getItem(paramNo), path, value);
} catch (final NumberFormatException ex) {
switch(subCommand) {
case "+":
if (isTrigger(value))
parameterBank.selectNextPage();
break;
case "-":
if (isTrigger(value))
parameterBank.selectPreviousPage();
break;
case "page":
final String pageCommand = getSubCommand(path);
if ("select".equals(pageCommand) || "selected".equals(pageCommand)) {
this.selectPage(parameterBank, toInteger(value) - 1);
} else {
try {
final int index = Integer.parseInt(pageCommand) - 1;
this.selectPage(parameterBank, index);
} catch (final NumberFormatException ex2) {
throw new UnknownCommandException(pageCommand);
}
}
break;
default:
throw new UnknownCommandException(subCommand);
}
}
}
Aggregations