use of de.mossgrabers.controller.generic.flexihandler.utils.FlexiHandlerException in project DrivenByMoss by git-moss.
the class SceneHandler method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(final FlexiCommand command, final KnobMode knobMode, final MidiValue value) {
final boolean isButtonPressed = this.isButtonPressed(knobMode, value);
switch(command) {
// Scene 1-8: Launch Scene
case SCENE_1_LAUNCH_SCENE:
case SCENE_2_LAUNCH_SCENE:
case SCENE_3_LAUNCH_SCENE:
case SCENE_4_LAUNCH_SCENE:
case SCENE_5_LAUNCH_SCENE:
case SCENE_6_LAUNCH_SCENE:
case SCENE_7_LAUNCH_SCENE:
case SCENE_8_LAUNCH_SCENE:
if (isButtonPressed) {
final IScene scene = this.model.getSceneBank().getItem(command.ordinal() - FlexiCommand.SCENE_1_LAUNCH_SCENE.ordinal());
scene.select();
scene.launch();
}
break;
// Scene: Select Previous Bank
case SCENE_SELECT_PREVIOUS_BANK:
if (isButtonPressed)
this.model.getSceneBank().selectPreviousPage();
break;
// Scene: Select Next Bank
case SCENE_SELECT_NEXT_BANK:
if (isButtonPressed)
this.model.getSceneBank().selectNextPage();
break;
// Scene: Create Scene
case SCENE_CREATE_SCENE:
if (isButtonPressed)
this.model.getProject().createScene();
break;
// Scene: Create Scene from playing Clips
case SCENE_CREATE_SCENE_FROM_PLAYING_CLIPS:
if (isButtonPressed)
this.model.getProject().createSceneFromPlayingLauncherClips();
break;
default:
throw new FlexiHandlerException(command);
}
}
use of de.mossgrabers.controller.generic.flexihandler.utils.FlexiHandlerException in project DrivenByMoss by git-moss.
the class NoteInputHandler method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(final FlexiCommand command, final KnobMode knobMode, final MidiValue value) {
final boolean isButtonPressed = this.isButtonPressed(knobMode, value);
final GenericFlexiConfiguration configuration = this.surface.getConfiguration();
final Resolution[] resolutions = Resolution.values();
final Scales scales = this.model.getScales();
final double val = value.isHighRes() ? value.getValue() / 128.0 : value.getValue();
switch(command) {
// Note Repeat: Toggle Active
case NOTE_INPUT_REPEAT_ACTIVE:
if (isButtonPressed) {
configuration.toggleNoteRepeatActive();
this.mvHelper.delayDisplay(() -> "Repeat: " + (configuration.isNoteRepeatActive() ? "On" : "Off"));
}
break;
// Note Repeat: Set Period
case NOTE_INPUT_REPEAT_PERIOD:
final int selPeriod;
if (isAbsolute(knobMode))
selPeriod = (int) Math.min(Math.round(val / 127.0 * resolutions.length), resolutions.length - 1L);
else
selPeriod = Resolution.change(Resolution.getMatch(configuration.getNoteRepeatPeriod().getValue()), this.isIncrease(knobMode, value));
configuration.setNoteRepeatPeriod(resolutions[selPeriod]);
this.mvHelper.delayDisplay(() -> "Repeat Period: " + configuration.getNoteRepeatPeriod().getName());
break;
// Note Repeat: Set Length
case NOTE_INPUT_REPEAT_LENGTH:
if (this.model.getHost().supports(Capability.NOTE_REPEAT_LENGTH)) {
final int selLength;
if (isAbsolute(knobMode))
selLength = (int) Math.min(Math.round(val / 127.0 * resolutions.length), resolutions.length - 1L);
else
selLength = Resolution.change(Resolution.getMatch(configuration.getNoteRepeatLength().getValue()), this.isIncrease(knobMode, value));
configuration.setNoteRepeatLength(resolutions[selLength]);
this.mvHelper.delayDisplay(() -> "Repeat Length: " + configuration.getNoteRepeatLength().getName());
}
break;
case NOTE_INPUT_REPEAT_MODE:
if (this.host.supports(Capability.NOTE_REPEAT_MODE)) {
final List<ArpeggiatorMode> modes = configuration.getArpeggiatorModes();
final int newIndex;
if (isAbsolute(knobMode)) {
if (val >= modes.size())
return;
newIndex = (int) val;
} else {
final ArpeggiatorMode arpMode = configuration.getNoteRepeatMode();
final int modeIndex = configuration.lookupArpeggiatorModeIndex(arpMode);
final boolean increase = this.isIncrease(knobMode, value);
newIndex = Math.max(0, Math.min(modes.size() - 1, modeIndex + (increase ? 1 : -1)));
}
configuration.setNoteRepeatMode(modes.get(newIndex));
this.mvHelper.delayDisplay(() -> "Repeat Mode: " + modes.get(newIndex).getName());
}
break;
case NOTE_INPUT_REPEAT_OCTAVE:
if (this.host.supports(Capability.NOTE_REPEAT_OCTAVES)) {
final int octave;
if (isAbsolute(knobMode))
octave = (int) val;
else
octave = configuration.getNoteRepeatOctave() + (this.isIncrease(knobMode, value) ? 1 : -1);
configuration.setNoteRepeatOctave(octave);
this.mvHelper.delayDisplay(() -> "Repeat Octave: " + octave);
}
break;
case NOTE_INPUT_TRANSPOSE_OCTAVE_UP:
if (isButtonPressed) {
scales.incOctave();
this.updateOctave(scales);
}
break;
case NOTE_INPUT_TRANSPOSE_OCTAVE_DOWN:
if (isButtonPressed) {
scales.decOctave();
this.updateOctave(scales);
}
break;
default:
throw new FlexiHandlerException(command);
}
}
use of de.mossgrabers.controller.generic.flexihandler.utils.FlexiHandlerException in project DrivenByMoss by git-moss.
the class TrackHandler method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(final FlexiCommand command, final KnobMode knobMode, final MidiValue value) {
final ITrackBank trackBank = this.model.getCurrentTrackBank();
if (trackBank == null)
return;
final ICursorTrack cursorTrack = this.model.getCursorTrack();
final boolean isButtonPressed = this.isButtonPressed(knobMode, value);
switch(command) {
case TRACK_TOGGLE_TRACK_BANK:
if (isButtonPressed)
this.toggleTrackBankCommand.execute(ButtonEvent.DOWN, 127);
break;
// Track: Add Audio Track
case TRACK_ADD_AUDIO_TRACK:
if (isButtonPressed)
this.model.getTrackBank().addChannel(ChannelType.AUDIO);
break;
// Track: Add Effect Track
case TRACK_ADD_EFFECT_TRACK:
if (isButtonPressed)
this.model.getApplication().addEffectTrack();
break;
// Track: Add Instrument Track
case TRACK_ADD_INSTRUMENT_TRACK:
if (isButtonPressed)
this.model.getTrackBank().addChannel(ChannelType.INSTRUMENT);
break;
// Track: Select Previous Bank Page
case TRACK_SELECT_PREVIOUS_BANK_PAGE:
if (isButtonPressed)
this.scrollTrackLeft(true);
break;
// Track: Select Next Bank Page
case TRACK_SELECT_NEXT_BANK_PAGE:
if (isButtonPressed)
this.scrollTrackRight(true);
break;
// Track: Select Previous Track
case TRACK_SELECT_PREVIOUS_TRACK:
if (isButtonPressed)
this.scrollTrackLeft(false);
break;
// Track: Select Next Track
case TRACK_SELECT_NEXT_TRACK:
if (isButtonPressed)
this.scrollTrackRight(false);
break;
case TRACK_SCROLL_TRACKS:
this.scrollTrack(knobMode, value);
break;
// Track 1-8: Select
case TRACK_1_SELECT:
case TRACK_2_SELECT:
case TRACK_3_SELECT:
case TRACK_4_SELECT:
case TRACK_5_SELECT:
case TRACK_6_SELECT:
case TRACK_7_SELECT:
case TRACK_8_SELECT:
if (isButtonPressed) {
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_SELECT.ordinal()).selectOrExpandGroup();
this.mvHelper.notifySelectedTrack();
}
break;
// Track 1-8: Toggle Active
case TRACK_1_TOGGLE_ACTIVE:
case TRACK_2_TOGGLE_ACTIVE:
case TRACK_3_TOGGLE_ACTIVE:
case TRACK_4_TOGGLE_ACTIVE:
case TRACK_5_TOGGLE_ACTIVE:
case TRACK_6_TOGGLE_ACTIVE:
case TRACK_7_TOGGLE_ACTIVE:
case TRACK_8_TOGGLE_ACTIVE:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_TOGGLE_ACTIVE.ordinal()).toggleIsActivated();
break;
// Track 1-8: Set Active
case TRACK_1_SET_ACTIVE:
case TRACK_2_SET_ACTIVE:
case TRACK_3_SET_ACTIVE:
case TRACK_4_SET_ACTIVE:
case TRACK_5_SET_ACTIVE:
case TRACK_6_SET_ACTIVE:
case TRACK_7_SET_ACTIVE:
case TRACK_8_SET_ACTIVE:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_SET_ACTIVE.ordinal()).setIsActivated(value.isPositive());
break;
case TRACK_SELECTED_TOGGLE_ACTIVE:
if (isButtonPressed)
cursorTrack.toggleIsActivated();
break;
case TRACK_SELECTED_SET_ACTIVE:
if (isButtonPressed)
cursorTrack.setIsActivated(value.isPositive());
break;
// Track 1-8: Set Volume
case TRACK_1_SET_VOLUME:
case TRACK_2_SET_VOLUME:
case TRACK_3_SET_VOLUME:
case TRACK_4_SET_VOLUME:
case TRACK_5_SET_VOLUME:
case TRACK_6_SET_VOLUME:
case TRACK_7_SET_VOLUME:
case TRACK_8_SET_VOLUME:
this.changeTrackVolume(knobMode, command.ordinal() - FlexiCommand.TRACK_1_SET_VOLUME.ordinal(), value);
break;
// Track Selected: Set Volume Track
case TRACK_SELECTED_SET_VOLUME_TRACK:
this.changeTrackVolume(knobMode, -1, value);
break;
// Track 1-8: Set Panorama
case TRACK_1_SET_PANORAMA:
case TRACK_2_SET_PANORAMA:
case TRACK_3_SET_PANORAMA:
case TRACK_4_SET_PANORAMA:
case TRACK_5_SET_PANORAMA:
case TRACK_6_SET_PANORAMA:
case TRACK_7_SET_PANORAMA:
case TRACK_8_SET_PANORAMA:
this.changeTrackPanorama(knobMode, command.ordinal() - FlexiCommand.TRACK_1_SET_PANORAMA.ordinal(), value);
break;
// Track Selected: Set Panorama
case TRACK_SELECTED_SET_PANORAMA:
this.changeTrackPanorama(knobMode, -1, value);
break;
// Track 1-8: Toggle Mute
case TRACK_1_TOGGLE_MUTE:
case TRACK_2_TOGGLE_MUTE:
case TRACK_3_TOGGLE_MUTE:
case TRACK_4_TOGGLE_MUTE:
case TRACK_5_TOGGLE_MUTE:
case TRACK_6_TOGGLE_MUTE:
case TRACK_7_TOGGLE_MUTE:
case TRACK_8_TOGGLE_MUTE:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_TOGGLE_MUTE.ordinal()).toggleMute();
break;
// Track 1-8: Set Mute
case TRACK_1_SET_MUTE:
case TRACK_2_SET_MUTE:
case TRACK_3_SET_MUTE:
case TRACK_4_SET_MUTE:
case TRACK_5_SET_MUTE:
case TRACK_6_SET_MUTE:
case TRACK_7_SET_MUTE:
case TRACK_8_SET_MUTE:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_SET_MUTE.ordinal()).setMute(value.isPositive());
break;
// Track Selected: Toggle Mute
case TRACK_SELECTED_TOGGLE_MUTE:
if (isButtonPressed)
cursorTrack.toggleMute();
break;
// Track Selected: Set Mute
case TRACK_SELECTED_SET_MUTE:
if (isButtonPressed)
cursorTrack.setMute(value.isPositive());
break;
// Track 1-8: Toggle Solo
case TRACK_1_TOGGLE_SOLO:
case TRACK_2_TOGGLE_SOLO:
case TRACK_3_TOGGLE_SOLO:
case TRACK_4_TOGGLE_SOLO:
case TRACK_5_TOGGLE_SOLO:
case TRACK_6_TOGGLE_SOLO:
case TRACK_7_TOGGLE_SOLO:
case TRACK_8_TOGGLE_SOLO:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_TOGGLE_SOLO.ordinal()).toggleSolo();
break;
// Track 1-8: Set Solo
case TRACK_1_SET_SOLO:
case TRACK_2_SET_SOLO:
case TRACK_3_SET_SOLO:
case TRACK_4_SET_SOLO:
case TRACK_5_SET_SOLO:
case TRACK_6_SET_SOLO:
case TRACK_7_SET_SOLO:
case TRACK_8_SET_SOLO:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_SET_SOLO.ordinal()).setSolo(value.isPositive());
break;
// Track Selected: Toggle Solo
case TRACK_SELECTED_TOGGLE_SOLO:
if (isButtonPressed)
cursorTrack.toggleSolo();
break;
// Track Selected: Set Solo
case TRACK_SELECTED_SET_SOLO:
if (isButtonPressed)
cursorTrack.setSolo(value.isPositive());
break;
// Track 1-8: Toggle Arm
case TRACK_1_TOGGLE_ARM:
case TRACK_2_TOGGLE_ARM:
case TRACK_3_TOGGLE_ARM:
case TRACK_4_TOGGLE_ARM:
case TRACK_5_TOGGLE_ARM:
case TRACK_6_TOGGLE_ARM:
case TRACK_7_TOGGLE_ARM:
case TRACK_8_TOGGLE_ARM:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_TOGGLE_ARM.ordinal()).toggleRecArm();
break;
// Track 1-8: Set Arm
case TRACK_1_SET_ARM:
case TRACK_2_SET_ARM:
case TRACK_3_SET_ARM:
case TRACK_4_SET_ARM:
case TRACK_5_SET_ARM:
case TRACK_6_SET_ARM:
case TRACK_7_SET_ARM:
case TRACK_8_SET_ARM:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_SET_ARM.ordinal()).setRecArm(value.isPositive());
break;
// Track Selected: Toggle Arm
case TRACK_SELECTED_TOGGLE_ARM:
if (isButtonPressed)
cursorTrack.toggleRecArm();
break;
// Track Selected: Set Arm
case TRACK_SELECTED_SET_ARM:
if (isButtonPressed)
cursorTrack.setRecArm(value.isPositive());
break;
// Track 1-8: Toggle Monitor
case TRACK_1_TOGGLE_MONITOR:
case TRACK_2_TOGGLE_MONITOR:
case TRACK_3_TOGGLE_MONITOR:
case TRACK_4_TOGGLE_MONITOR:
case TRACK_5_TOGGLE_MONITOR:
case TRACK_6_TOGGLE_MONITOR:
case TRACK_7_TOGGLE_MONITOR:
case TRACK_8_TOGGLE_MONITOR:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_TOGGLE_MONITOR.ordinal()).toggleMonitor();
break;
// Track 1-8: Set Monitor
case TRACK_1_SET_MONITOR:
case TRACK_2_SET_MONITOR:
case TRACK_3_SET_MONITOR:
case TRACK_4_SET_MONITOR:
case TRACK_5_SET_MONITOR:
case TRACK_6_SET_MONITOR:
case TRACK_7_SET_MONITOR:
case TRACK_8_SET_MONITOR:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_SET_MONITOR.ordinal()).setMonitor(value.isPositive());
break;
// Track Selected: Toggle Monitor
case TRACK_SELECTED_TOGGLE_MONITOR:
if (isButtonPressed)
cursorTrack.toggleMonitor();
break;
// Track Selected: Set Monitor
case TRACK_SELECTED_SET_MONITOR:
if (isButtonPressed)
cursorTrack.setMonitor(value.isPositive());
break;
// Track 1: Toggle Auto Monitor
case TRACK_1_TOGGLE_AUTO_MONITOR:
case TRACK_2_TOGGLE_AUTO_MONITOR:
case TRACK_3_TOGGLE_AUTO_MONITOR:
case TRACK_4_TOGGLE_AUTO_MONITOR:
case TRACK_5_TOGGLE_AUTO_MONITOR:
case TRACK_6_TOGGLE_AUTO_MONITOR:
case TRACK_7_TOGGLE_AUTO_MONITOR:
case TRACK_8_TOGGLE_AUTO_MONITOR:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_TOGGLE_AUTO_MONITOR.ordinal()).toggleAutoMonitor();
break;
// Track 1: Set Auto Monitor
case TRACK_1_SET_AUTO_MONITOR:
case TRACK_2_SET_AUTO_MONITOR:
case TRACK_3_SET_AUTO_MONITOR:
case TRACK_4_SET_AUTO_MONITOR:
case TRACK_5_SET_AUTO_MONITOR:
case TRACK_6_SET_AUTO_MONITOR:
case TRACK_7_SET_AUTO_MONITOR:
case TRACK_8_SET_AUTO_MONITOR:
if (isButtonPressed)
trackBank.getItem(command.ordinal() - FlexiCommand.TRACK_1_SET_AUTO_MONITOR.ordinal()).setAutoMonitor(value.isPositive());
break;
// Track Selected: Toggle Auto Monitor
case TRACK_SELECTED_TOGGLE_AUTO_MONITOR:
if (isButtonPressed)
cursorTrack.toggleAutoMonitor();
break;
// Track Selected: Set Auto Monitor
case TRACK_SELECTED_SET_AUTO_MONITOR:
if (isButtonPressed)
cursorTrack.setAutoMonitor(value.isPositive());
break;
// Track Selected: Toggle Pinned
case TRACK_SELECTED_TOGGLE_PIN:
if (isButtonPressed)
cursorTrack.togglePinned();
break;
// Track Selected: Set Pinned
case TRACK_SELECTED_SET_PIN:
if (isButtonPressed)
cursorTrack.setPinned(value.isPositive());
break;
// Track 1-8: Set Send 1
case TRACK_1_SET_SEND_1:
case TRACK_2_SET_SEND_1:
case TRACK_3_SET_SEND_1:
case TRACK_4_SET_SEND_1:
case TRACK_5_SET_SEND_1:
case TRACK_6_SET_SEND_1:
case TRACK_7_SET_SEND_1:
case TRACK_8_SET_SEND_1:
this.changeSendVolume(command.ordinal() - FlexiCommand.TRACK_1_SET_SEND_1.ordinal(), 0, knobMode, value);
break;
// Track 1-8: Set Send 2
case TRACK_1_SET_SEND_2:
case TRACK_2_SET_SEND_2:
case TRACK_3_SET_SEND_2:
case TRACK_4_SET_SEND_2:
case TRACK_5_SET_SEND_2:
case TRACK_6_SET_SEND_2:
case TRACK_7_SET_SEND_2:
case TRACK_8_SET_SEND_2:
this.changeSendVolume(command.ordinal() - FlexiCommand.TRACK_1_SET_SEND_2.ordinal(), 1, knobMode, value);
break;
// Track 1-8: Set Send 3
case TRACK_1_SET_SEND_3:
case TRACK_2_SET_SEND_3:
case TRACK_3_SET_SEND_3:
case TRACK_4_SET_SEND_3:
case TRACK_5_SET_SEND_3:
case TRACK_6_SET_SEND_3:
case TRACK_7_SET_SEND_3:
case TRACK_8_SET_SEND_3:
this.changeSendVolume(command.ordinal() - FlexiCommand.TRACK_1_SET_SEND_3.ordinal(), 2, knobMode, value);
break;
// Track 1-8: Set Send 4
case TRACK_1_SET_SEND_4:
case TRACK_2_SET_SEND_4:
case TRACK_3_SET_SEND_4:
case TRACK_4_SET_SEND_4:
case TRACK_5_SET_SEND_4:
case TRACK_6_SET_SEND_4:
case TRACK_7_SET_SEND_4:
case TRACK_8_SET_SEND_4:
this.changeSendVolume(command.ordinal() - FlexiCommand.TRACK_1_SET_SEND_4.ordinal(), 3, knobMode, value);
break;
// Track 1: Set Send 5
case TRACK_1_SET_SEND_5:
case TRACK_2_SET_SEND_5:
case TRACK_3_SET_SEND_5:
case TRACK_4_SET_SEND_5:
case TRACK_5_SET_SEND_5:
case TRACK_6_SET_SEND_5:
case TRACK_7_SET_SEND_5:
case TRACK_8_SET_SEND_5:
this.changeSendVolume(command.ordinal() - FlexiCommand.TRACK_1_SET_SEND_5.ordinal(), 4, knobMode, value);
break;
// Track 1: Set Send 6
case TRACK_1_SET_SEND_6:
case TRACK_2_SET_SEND_6:
case TRACK_3_SET_SEND_6:
case TRACK_4_SET_SEND_6:
case TRACK_5_SET_SEND_6:
case TRACK_6_SET_SEND_6:
case TRACK_7_SET_SEND_6:
case TRACK_8_SET_SEND_6:
this.changeSendVolume(command.ordinal() - FlexiCommand.TRACK_1_SET_SEND_6.ordinal(), 5, knobMode, value);
break;
// Track 1-8: Set Send 7
case TRACK_1_SET_SEND_7:
case TRACK_2_SET_SEND_7:
case TRACK_3_SET_SEND_7:
case TRACK_4_SET_SEND_7:
case TRACK_5_SET_SEND_7:
case TRACK_6_SET_SEND_7:
case TRACK_7_SET_SEND_7:
case TRACK_8_SET_SEND_7:
this.changeSendVolume(command.ordinal() - FlexiCommand.TRACK_1_SET_SEND_7.ordinal(), 6, knobMode, value);
break;
// Track 1-8: Set Send 8
case TRACK_1_SET_SEND_8:
case TRACK_2_SET_SEND_8:
case TRACK_3_SET_SEND_8:
case TRACK_4_SET_SEND_8:
case TRACK_5_SET_SEND_8:
case TRACK_6_SET_SEND_8:
case TRACK_7_SET_SEND_8:
case TRACK_8_SET_SEND_8:
this.changeSendVolume(command.ordinal() - FlexiCommand.TRACK_1_SET_SEND_8.ordinal(), 7, knobMode, value);
break;
// Track Selected: Set Send 1-8
case TRACK_SELECTED_SET_SEND_1:
case TRACK_SELECTED_SET_SEND_2:
case TRACK_SELECTED_SET_SEND_3:
case TRACK_SELECTED_SET_SEND_4:
case TRACK_SELECTED_SET_SEND_5:
case TRACK_SELECTED_SET_SEND_6:
case TRACK_SELECTED_SET_SEND_7:
case TRACK_SELECTED_SET_SEND_8:
this.changeSendVolume(-1, command.ordinal() - FlexiCommand.TRACK_SELECTED_SET_SEND_1.ordinal(), knobMode, value);
break;
default:
throw new FlexiHandlerException(command);
}
}
Aggregations