use of de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface in project DrivenByMoss by git-moss.
the class KontrolProtocolControllerSetup method registerContinuousCommands.
/**
* {@inheritDoc}
*/
@Override
protected void registerContinuousCommands() {
final KontrolProtocolControlSurface surface = this.getSurface();
this.addFader(ContinuousID.HELLO, "Hello", surface::handshakeSuccess, BindType.CC, 15, KontrolProtocolControlSurface.CMD_HELLO);
this.addButton(surface, ButtonID.BANK_LEFT, "Left", (event, velocity) -> this.moveTrackBank(event, true), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS, 127, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS));
this.addButton(surface, ButtonID.BANK_RIGHT, "Right", (event, velocity) -> this.moveTrackBank(event, false), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS, 1, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS));
this.addButton(surface, ButtonID.MOVE_TRACK_LEFT, "Enc Left", (event, velocity) -> this.moveTrack(event, true), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS, 127, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS));
this.addButton(surface, ButtonID.MOVE_TRACK_RIGHT, "Enc Right", (event, velocity) -> this.moveTrack(event, false), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS, 1, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS));
this.addButton(surface, ButtonID.ARROW_UP, "Enc Up", (event, velocity) -> this.moveClips(event, true), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS, 127, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS));
this.addButton(surface, ButtonID.ARROW_DOWN, "Enc Down", (event, velocity) -> this.moveClips(event, false), 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS, 1, () -> this.getKnobValue(KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS));
this.addRelativeKnob(ContinuousID.MOVE_TRANSPORT, "Move Transport", value -> this.changeTransportPosition(value, 0), BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_MOVE_TRANSPORT);
this.addRelativeKnob(ContinuousID.MOVE_LOOP, "Move Loop", this::changeLoopPosition, BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_NAVIGATE_MOVE_LOOP);
// Only on S models
this.addRelativeKnob(ContinuousID.NAVIGATE_VOLUME, "Navigate Volume", value -> this.changeTransportPosition(value, 1), BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_CHANGE_SELECTED_TRACK_VOLUME);
this.addRelativeKnob(ContinuousID.NAVIGATE_PAN, "Navigate Pan", value -> this.changeTransportPosition(value, 2), BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_CHANGE_SELECTED_TRACK_PAN);
for (int i = 0; i < 8; i++) {
final int knobMidi1 = KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME + i;
final IHwRelativeKnob knob1 = this.addRelativeKnob(ContinuousID.get(ContinuousID.KNOB1, i), "Knob " + (i + 1), null, BindType.CC, 15, knobMidi1);
knob1.addOutput(() -> this.getKnobValue(knobMidi1), value -> surface.setTrigger(15, knobMidi1, value));
knob1.setIndexInGroup(i);
final int knobMidi2 = KontrolProtocolControlSurface.KONTROL_TRACK_PAN + i;
final IHwRelativeKnob knob2 = this.addRelativeKnob(ContinuousID.get(ContinuousID.FADER1, i), "Fader " + (i + 1), null, BindType.CC, 15, KontrolProtocolControlSurface.KONTROL_TRACK_PAN + i);
knob2.addOutput(() -> this.getKnobValue(knobMidi2), value -> surface.setTrigger(15, knobMidi2, value));
knob2.setIndexInGroup(i);
}
}
use of de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface in project DrivenByMoss by git-moss.
the class KontrolProtocolControllerSetup method registerTriggerCommands.
/**
* {@inheritDoc}
*/
@Override
protected void registerTriggerCommands() {
final KontrolProtocolControlSurface surface = this.getSurface();
final ITransport t = this.model.getTransport();
this.addButton(ButtonID.PLAY, "Play", new PlayCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_PLAY, t::isPlaying);
this.addButton(ButtonID.NEW, "Shift+\nPlay", new NewCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_RESTART);
final ConfiguredRecordCommand<KontrolProtocolControlSurface, KontrolProtocolConfiguration> recordCommand = new ConfiguredRecordCommand<>(false, this.model, surface);
this.addButton(ButtonID.RECORD, "Record", recordCommand, 15, KontrolProtocolControlSurface.KONTROL_RECORD, recordCommand::isLit);
final ConfiguredRecordCommand<KontrolProtocolControlSurface, KontrolProtocolConfiguration> shiftedRecordCommand = new ConfiguredRecordCommand<>(true, this.model, surface);
this.addButton(ButtonID.REC_ARM, "Shift+\nRecord", shiftedRecordCommand, 15, KontrolProtocolControlSurface.KONTROL_COUNT_IN, shiftedRecordCommand::isLit);
this.addButton(ButtonID.STOP, "Stop", new StopCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_STOP, () -> !t.isPlaying());
this.addButton(ButtonID.LOOP, "Loop", new ToggleLoopCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_LOOP, t::isLoop);
this.addButton(ButtonID.METRONOME, "Metronome", new MetronomeCommand<>(this.model, surface, false), 15, KontrolProtocolControlSurface.KONTROL_METRO, t::isMetronomeOn);
this.addButton(ButtonID.TAP_TEMPO, "Tempo", new TapTempoCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_TAP_TEMPO);
// Note: Since there is no pressed-state with this device, in the simulator-GUI the
// following buttons are always on
this.addButton(ButtonID.UNDO, "Undo", new UndoCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_UNDO, () -> this.model.getApplication().canUndo());
this.addButton(ButtonID.REDO, "Redo", new RedoCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_REDO, () -> this.model.getApplication().canRedo());
this.addButton(ButtonID.QUANTIZE, "Quantize", new QuantizeCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_QUANTIZE, () -> true);
this.addButton(ButtonID.AUTOMATION, "Automation", new WriteArrangerAutomationCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_AUTOMATION, t::isWritingArrangerAutomation);
this.addButton(ButtonID.DELETE, "Modes", new ModeMultiSelectCommand<>(this.model, surface, Modes.VOLUME, Modes.SEND, Modes.DEVICE_PARAMS), 15, KontrolProtocolControlSurface.KONTROL_CLEAR, () -> true);
this.addButton(ButtonID.CLIP, "Start Clip", new StartClipOrSceneCommand(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_PLAY_SELECTED_CLIP);
this.addButton(ButtonID.STOP_CLIP, "Stop Clip", new StopClipCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_STOP_CLIP);
// Not implemented in NIHIA
this.addButton(ButtonID.SCENE1, "Play Scene", new StartSceneCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_PLAY_SCENE);
// KONTROL_RECORD_SESSION - Not implemented in NIHIA
this.addButton(ButtonID.MUTE, "Mute", new MuteCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_MUTE, () -> {
final ITrackBank tb = this.model.getCurrentTrackBank();
final Optional<ITrack> selectedTrack = tb.getSelectedItem();
return selectedTrack.isPresent() && selectedTrack.get().isMute() ? 1 : 0;
});
this.addButton(ButtonID.SOLO, "Solo", new SoloCommand<>(this.model, surface), 15, KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_SOLO, () -> {
final ITrackBank tb = this.model.getCurrentTrackBank();
final Optional<ITrack> selectedTrack = tb.getSelectedItem();
return selectedTrack.isPresent() && selectedTrack.get().isSolo() ? 1 : 0;
});
this.addButtons(surface, 0, 8, ButtonID.ROW_SELECT_1, "Select", (event, index) -> {
if (event == ButtonEvent.DOWN)
this.model.getCurrentTrackBank().getItem(index).selectOrExpandGroup();
}, 15, KontrolProtocolControlSurface.KONTROL_TRACK_SELECTED, index -> this.model.getTrackBank().getItem(index).isSelected() ? 1 : 0);
this.addButtons(surface, 0, 8, ButtonID.ROW1_1, "Mute", (event, index) -> {
if (event == ButtonEvent.DOWN)
this.model.getTrackBank().getItem(index).toggleMute();
}, 15, KontrolProtocolControlSurface.KONTROL_TRACK_MUTE, index -> this.model.getTrackBank().getItem(index).isMute() ? 1 : 0);
this.addButtons(surface, 0, 8, ButtonID.ROW2_1, "Solo", (event, index) -> {
if (event == ButtonEvent.DOWN)
this.model.getTrackBank().getItem(index).toggleSolo();
}, 15, KontrolProtocolControlSurface.KONTROL_TRACK_SOLO, index -> this.model.getTrackBank().getItem(index).isSolo() ? 1 : 0);
this.addButtons(surface, 0, 8, ButtonID.ROW3_1, "Arm", (event, index) -> {
if (event == ButtonEvent.DOWN)
this.model.getTrackBank().getItem(index).toggleRecArm();
}, 15, KontrolProtocolControlSurface.KONTROL_TRACK_RECARM, index -> this.model.getTrackBank().getItem(index).isRecArm() ? 1 : 0);
this.addButton(ButtonID.F1, "", NopCommand.INSTANCE, 15, KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_AVAILABLE);
this.addButton(ButtonID.F2, "", NopCommand.INSTANCE, 15, KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_MUTED_BY_SOLO);
}
use of de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface in project DrivenByMoss by git-moss.
the class KontrolProtocolControllerSetup method createModes.
/**
* {@inheritDoc}
*/
@Override
protected void createModes() {
final KontrolProtocolControlSurface surface = this.getSurface();
final ModeManager modeManager = surface.getModeManager();
final List<ContinuousID> controls = ContinuousID.createSequentialList(ContinuousID.KNOB1, 8);
controls.addAll(ContinuousID.createSequentialList(ContinuousID.FADER1, 8));
modeManager.register(Modes.VOLUME, new MixerMode(surface, this.model, controls));
modeManager.register(Modes.SEND, new SendMode(surface, this.model, controls));
modeManager.register(Modes.DEVICE_PARAMS, new ParamsMode(surface, this.model, controls));
}
use of de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface in project DrivenByMoss by git-moss.
the class KontrolProtocolControllerSetup method flush.
/**
* {@inheritDoc}
*/
@Override
public void flush() {
// Do not flush until handshake has finished
if (!this.getSurface().isConnectedToNIHIA())
return;
final KontrolProtocolControlSurface surface = this.getSurface();
final String kompleteInstanceNew = this.getKompleteInstance();
if (!this.kompleteInstance.equals(kompleteInstanceNew)) {
this.kompleteInstance = kompleteInstanceNew;
surface.sendKontrolTrackSysEx(KontrolProtocolControlSurface.KONTROL_TRACK_INSTANCE, 0, 0, kompleteInstanceNew);
}
final ITrackBank bank = this.model.getCurrentTrackBank();
final boolean hasSolo = this.model.getProject().hasSolo();
for (int i = 0; i < 8; i++) {
final ITrack track = bank.getItem(i);
surface.sendKontrolTrackSysEx(KontrolProtocolControlSurface.KONTROL_TRACK_MUTE, track.isMute() ? 1 : 0, i);
surface.sendKontrolTrackSysEx(KontrolProtocolControlSurface.KONTROL_TRACK_SOLO, track.isSolo() ? 1 : 0, i);
surface.sendKontrolTrackSysEx(KontrolProtocolControlSurface.KONTROL_TRACK_MUTED_BY_SOLO, !track.isSolo() && hasSolo ? 1 : 0, i);
}
final ITrackBank tb = this.model.getCurrentTrackBank();
final Optional<ITrack> selectedTrack = tb.getSelectedItem();
surface.sendCommand(KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_AVAILABLE, selectedTrack.isPresent() ? TrackType.toTrackType(selectedTrack.get().getType()) : 0);
surface.sendCommand(KontrolProtocolControlSurface.KONTROL_SELECTED_TRACK_MUTED_BY_SOLO, selectedTrack.isPresent() && !selectedTrack.get().isSolo() && hasSolo ? 1 : 0);
super.flush();
}
use of de.mossgrabers.controller.ni.kontrol.mkii.controller.KontrolProtocolControlSurface in project DrivenByMoss by git-moss.
the class KontrolProtocolControllerSetup method createViews.
/**
* {@inheritDoc}
*/
@Override
protected void createViews() {
final KontrolProtocolControlSurface surface = this.getSurface();
final ViewManager viewManager = surface.getViewManager();
viewManager.register(Views.CONTROL, new ControlView(surface, this.model));
}
Aggregations