use of de.mossgrabers.framework.daw.data.bank.ITrackBank in project DrivenByMoss by git-moss.
the class PanSendCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event, final int velocity) {
if (event != ButtonEvent.DOWN)
return;
final ModeManager modeManager = this.surface.getModeManager();
final Modes currentMode = modeManager.getActiveID();
// Layer mode selection for Push 1
Modes mode;
final PushConfiguration config = this.surface.getConfiguration();
if (!config.isPush2() && this.surface.isSelectPressed() && Modes.isLayerMode(currentMode)) {
if (this.model.isEffectTrackBankActive()) {
// No Sends on FX tracks
mode = Modes.DEVICE_LAYER_PAN;
} else {
mode = Modes.get(currentMode, 1);
// Wrap
if (mode.ordinal() < Modes.DEVICE_LAYER_PAN.ordinal() || mode.ordinal() > Modes.DEVICE_LAYER_SEND8.ordinal())
mode = Modes.DEVICE_LAYER_PAN;
// Check if Send channel exists
final ITrackBank tb = this.model.getTrackBank();
if (mode.ordinal() < Modes.DEVICE_LAYER_SEND1.ordinal() || mode.ordinal() > Modes.DEVICE_LAYER_SEND8.ordinal() || tb.canEditSend(mode.ordinal() - Modes.DEVICE_LAYER_SEND1.ordinal()))
mode = Modes.DEVICE_LAYER_PAN;
}
modeManager.setActive(mode);
return;
}
if (this.model.isEffectTrackBankActive()) {
// No Sends on FX tracks
mode = Modes.PAN;
} else {
if (currentMode.ordinal() < Modes.SEND1.ordinal() || currentMode.ordinal() > Modes.SEND8.ordinal())
mode = Modes.SEND1;
else {
mode = Modes.get(currentMode, 1);
if (mode.ordinal() > Modes.SEND8.ordinal())
mode = Modes.PAN;
}
// Check if Send channel exists
final ITrackBank tb = this.model.getTrackBank();
if (mode.ordinal() < Modes.SEND1.ordinal() || mode.ordinal() > Modes.SEND8.ordinal() || !tb.canEditSend(mode.ordinal() - Modes.SEND1.ordinal()))
mode = Modes.PAN;
}
modeManager.setActive(mode);
}
use of de.mossgrabers.framework.daw.data.bank.ITrackBank in project DrivenByMoss by git-moss.
the class TrackEditing method onTrackKnob.
/**
* A knob is moved for changing a track parameter.
*
* @param index The index of the knob
* @param value The knobs value
* @param isTurnedRight The knob is turned to the right (positive value change)
*/
public void onTrackKnob(final int index, final int value, final boolean isTurnedRight) {
final ITrackBank tb = this.model.getCurrentTrackBank();
final Optional<ITrack> selectedTrack = tb.getSelectedItem();
if (selectedTrack.isEmpty())
return;
switch(index) {
case 0:
selectedTrack.get().changeVolume(value);
break;
case 1:
selectedTrack.get().changePan(value);
break;
case 2:
selectedTrack.get().setMute(isTurnedRight);
break;
case 3:
selectedTrack.get().setSolo(isTurnedRight);
break;
case 4:
selectedTrack.get().getCrossfadeParameter().changeValue(value);
break;
case 5:
this.model.getTransport().changeTempo(isTurnedRight, this.surface.isShiftPressed());
break;
case 6:
this.model.getTransport().changePosition(isTurnedRight, this.surface.isShiftPressed());
break;
case 7:
this.model.getMasterTrack().changeVolume(value);
break;
// Send 1 - 4
case 8:
case 9:
case 10:
case 11:
if (!this.model.isEffectTrackBankActive())
selectedTrack.get().getSendBank().getItem(index - 8).changeValue(value);
break;
default:
// Not used
break;
}
}
use of de.mossgrabers.framework.daw.data.bank.ITrackBank in project DrivenByMoss by git-moss.
the class GenericFlexiControllerSetup method updateIndication.
protected void updateIndication() {
final Set<FlexiCommand> commands = this.configuration.getMappedCommands();
final FlexiCommand[] allCommands = FlexiCommand.values();
final ITrackBank trackBank = this.model.getTrackBank();
final Optional<ITrack> selectedTrack = trackBank.getSelectedItem();
for (int i = 0; i < trackBank.getPageSize(); i++) {
final boolean hasTrackSel = selectedTrack.isPresent() && selectedTrack.get().getIndex() == i;
final ITrack track = trackBank.getItem(i);
track.setVolumeIndication(this.testVolumeIndication(commands, allCommands, i, hasTrackSel));
track.setPanIndication(this.testPanIndication(commands, allCommands, i, hasTrackSel));
final ISendBank sendBank = track.getSendBank();
final int sendPageSize = sendBank.getPageSize();
for (int j = 0; j < sendPageSize; j++) sendBank.getItem(j).setIndication(this.testSendIndication(commands, allCommands, i, hasTrackSel, sendPageSize, j));
}
final IMasterTrack masterTrack = this.model.getMasterTrack();
masterTrack.setVolumeIndication(commands.contains(FlexiCommand.MASTER_SET_VOLUME));
masterTrack.setPanIndication(commands.contains(FlexiCommand.MASTER_SET_PANORAMA));
final IParameterBank parameterBank = this.model.getCursorDevice().getParameterBank();
for (int i = 0; i < parameterBank.getPageSize(); i++) parameterBank.getItem(i).setIndication(this.testParameterIndication(commands, allCommands, i));
}
use of de.mossgrabers.framework.daw.data.bank.ITrackBank in project DrivenByMoss by git-moss.
the class GenericFlexiControllerSetup method createObservers.
/**
* {@inheritDoc}
*/
@Override
protected void createObservers() {
super.createObservers();
final GenericFlexiControlSurface surface = this.getSurface();
this.configuration.addSettingObserver(GenericFlexiConfiguration.SLOT_CHANGE, surface::updateKeyTranslation);
this.configuration.addSettingObserver(GenericFlexiConfiguration.SELECTED_MODE, this::selectMode);
final ITrackBank trackBank = this.model.getTrackBank();
trackBank.addSelectionObserver((index, selected) -> this.handleTrackChange(selected));
final ITrackBank effectTrackBank = this.model.getEffectTrackBank();
if (effectTrackBank != null)
effectTrackBank.addSelectionObserver((index, selected) -> this.handleTrackChange(selected));
surface.getModeManager().addChangeListener((oldMode, newMode) -> this.updateIndication());
// Handle configuration changes
this.createNoteRepeatObservers(this.configuration, surface);
this.configuration.registerDeactivatedItemsHandler(this.model);
this.configuration.addSettingObserver(GenericFlexiConfiguration.ENABLED_MPE_ZONES, () -> surface.scheduleTask(() -> {
final INoteInput input = surface.getMidiInput().getDefaultNoteInput();
final IMidiOutput output = surface.getMidiOutput();
final boolean mpeEnabled = this.configuration.isMPEEndabled();
input.enableMPE(mpeEnabled);
// Enable MPE zone 1 with all 15 channels
output.configureMPE(AbstractMidiOutput.ZONE_1, mpeEnabled ? 15 : 0);
// Disable MPE zone
output.configureMPE(AbstractMidiOutput.ZONE_2, 0);
}, 2000));
this.configuration.addSettingObserver(GenericFlexiConfiguration.MPE_PITCHBEND_RANGE, () -> surface.scheduleTask(() -> {
final INoteInput input = surface.getMidiInput().getDefaultNoteInput();
final IMidiOutput output = surface.getMidiOutput();
final int mpePitchBendRange = this.configuration.getMPEPitchBendRange();
input.setMPEPitchBendSensitivity(mpePitchBendRange);
output.sendMPEPitchbendRange(AbstractMidiOutput.ZONE_1, mpePitchBendRange);
}, 2000));
this.activateBrowserObserver(Modes.BROWSER);
}
use of de.mossgrabers.framework.daw.data.bank.ITrackBank in project DrivenByMoss by git-moss.
the class FxTrackHandler method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(final FlexiCommand command, final KnobMode knobMode, final MidiValue value) {
final ITrackBank effectTrackBank = this.model.getEffectTrackBank();
if (effectTrackBank == null)
return;
final boolean isButtonPressed = this.isButtonPressed(knobMode, value);
switch(command) {
// Track: Select Previous Bank Page
case FX_TRACK_SELECT_PREVIOUS_BANK_PAGE:
if (isButtonPressed)
this.scrollTrackLeft(true);
break;
// Track: Select Next Bank Page
case FX_TRACK_SELECT_NEXT_BANK_PAGE:
if (isButtonPressed)
this.scrollTrackRight(true);
break;
// Track: Select Previous Track
case FX_TRACK_SELECT_PREVIOUS_TRACK:
if (isButtonPressed)
this.scrollTrackLeft(false);
break;
// Track: Select Next Track
case FX_TRACK_SELECT_NEXT_TRACK:
if (isButtonPressed)
this.scrollTrackRight(false);
break;
case FX_TRACK_SCROLL_TRACKS:
this.scrollTrack(knobMode, value);
break;
// Track 1-8: Select
case FX_TRACK_1_SELECT:
case FX_TRACK_2_SELECT:
case FX_TRACK_3_SELECT:
case FX_TRACK_4_SELECT:
case FX_TRACK_5_SELECT:
case FX_TRACK_6_SELECT:
case FX_TRACK_7_SELECT:
case FX_TRACK_8_SELECT:
if (isButtonPressed) {
final ITrack track = effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_SELECT.ordinal());
track.select();
this.mvHelper.notifySelectedTrack();
}
break;
// Track 1-8: Toggle Active
case FX_TRACK_1_TOGGLE_ACTIVE:
case FX_TRACK_2_TOGGLE_ACTIVE:
case FX_TRACK_3_TOGGLE_ACTIVE:
case FX_TRACK_4_TOGGLE_ACTIVE:
case FX_TRACK_5_TOGGLE_ACTIVE:
case FX_TRACK_6_TOGGLE_ACTIVE:
case FX_TRACK_7_TOGGLE_ACTIVE:
case FX_TRACK_8_TOGGLE_ACTIVE:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_TOGGLE_ACTIVE.ordinal()).toggleIsActivated();
break;
// Track 1-8: Set Active
case FX_TRACK_1_SET_ACTIVE:
case FX_TRACK_2_SET_ACTIVE:
case FX_TRACK_3_SET_ACTIVE:
case FX_TRACK_4_SET_ACTIVE:
case FX_TRACK_5_SET_ACTIVE:
case FX_TRACK_6_SET_ACTIVE:
case FX_TRACK_7_SET_ACTIVE:
case FX_TRACK_8_SET_ACTIVE:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_SET_ACTIVE.ordinal()).setIsActivated(value.isPositive());
break;
// Track 1-8: Set Volume
case FX_TRACK_1_SET_VOLUME:
case FX_TRACK_2_SET_VOLUME:
case FX_TRACK_3_SET_VOLUME:
case FX_TRACK_4_SET_VOLUME:
case FX_TRACK_5_SET_VOLUME:
case FX_TRACK_6_SET_VOLUME:
case FX_TRACK_7_SET_VOLUME:
case FX_TRACK_8_SET_VOLUME:
this.changeTrackVolume(knobMode, command.ordinal() - FlexiCommand.FX_TRACK_1_SET_VOLUME.ordinal(), value);
break;
// Track 1-8: Set Panorama
case FX_TRACK_1_SET_PANORAMA:
case FX_TRACK_2_SET_PANORAMA:
case FX_TRACK_3_SET_PANORAMA:
case FX_TRACK_4_SET_PANORAMA:
case FX_TRACK_5_SET_PANORAMA:
case FX_TRACK_6_SET_PANORAMA:
case FX_TRACK_7_SET_PANORAMA:
case FX_TRACK_8_SET_PANORAMA:
this.changeTrackPanorama(knobMode, command.ordinal() - FlexiCommand.FX_TRACK_1_SET_PANORAMA.ordinal(), value);
break;
// Track 1-8: Toggle Mute
case FX_TRACK_1_TOGGLE_MUTE:
case FX_TRACK_2_TOGGLE_MUTE:
case FX_TRACK_3_TOGGLE_MUTE:
case FX_TRACK_4_TOGGLE_MUTE:
case FX_TRACK_5_TOGGLE_MUTE:
case FX_TRACK_6_TOGGLE_MUTE:
case FX_TRACK_7_TOGGLE_MUTE:
case FX_TRACK_8_TOGGLE_MUTE:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_TOGGLE_MUTE.ordinal()).toggleMute();
break;
// Track 1-8: Set Mute
case FX_TRACK_1_SET_MUTE:
case FX_TRACK_2_SET_MUTE:
case FX_TRACK_3_SET_MUTE:
case FX_TRACK_4_SET_MUTE:
case FX_TRACK_5_SET_MUTE:
case FX_TRACK_6_SET_MUTE:
case FX_TRACK_7_SET_MUTE:
case FX_TRACK_8_SET_MUTE:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_SET_MUTE.ordinal()).setMute(value.isPositive());
break;
// Track 1-8: Toggle Solo
case FX_TRACK_1_TOGGLE_SOLO:
case FX_TRACK_2_TOGGLE_SOLO:
case FX_TRACK_3_TOGGLE_SOLO:
case FX_TRACK_4_TOGGLE_SOLO:
case FX_TRACK_5_TOGGLE_SOLO:
case FX_TRACK_6_TOGGLE_SOLO:
case FX_TRACK_7_TOGGLE_SOLO:
case FX_TRACK_8_TOGGLE_SOLO:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_TOGGLE_SOLO.ordinal()).toggleSolo();
break;
// Track 1-8: Set Solo
case FX_TRACK_1_SET_SOLO:
case FX_TRACK_2_SET_SOLO:
case FX_TRACK_3_SET_SOLO:
case FX_TRACK_4_SET_SOLO:
case FX_TRACK_5_SET_SOLO:
case FX_TRACK_6_SET_SOLO:
case FX_TRACK_7_SET_SOLO:
case FX_TRACK_8_SET_SOLO:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_SET_SOLO.ordinal()).setSolo(value.isPositive());
break;
// Track 1-8: Toggle Arm
case FX_TRACK_1_TOGGLE_ARM:
case FX_TRACK_2_TOGGLE_ARM:
case FX_TRACK_3_TOGGLE_ARM:
case FX_TRACK_4_TOGGLE_ARM:
case FX_TRACK_5_TOGGLE_ARM:
case FX_TRACK_6_TOGGLE_ARM:
case FX_TRACK_7_TOGGLE_ARM:
case FX_TRACK_8_TOGGLE_ARM:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_TOGGLE_ARM.ordinal()).toggleRecArm();
break;
// Track 1-8: Set Arm
case FX_TRACK_1_SET_ARM:
case FX_TRACK_2_SET_ARM:
case FX_TRACK_3_SET_ARM:
case FX_TRACK_4_SET_ARM:
case FX_TRACK_5_SET_ARM:
case FX_TRACK_6_SET_ARM:
case FX_TRACK_7_SET_ARM:
case FX_TRACK_8_SET_ARM:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_SET_ARM.ordinal()).setRecArm(value.isPositive());
break;
// Track 1-8: Toggle Monitor
case FX_TRACK_1_TOGGLE_MONITOR:
case FX_TRACK_2_TOGGLE_MONITOR:
case FX_TRACK_3_TOGGLE_MONITOR:
case FX_TRACK_4_TOGGLE_MONITOR:
case FX_TRACK_5_TOGGLE_MONITOR:
case FX_TRACK_6_TOGGLE_MONITOR:
case FX_TRACK_7_TOGGLE_MONITOR:
case FX_TRACK_8_TOGGLE_MONITOR:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_TOGGLE_MONITOR.ordinal()).toggleMonitor();
break;
// Track 1-8: Set Monitor
case FX_TRACK_1_SET_MONITOR:
case FX_TRACK_2_SET_MONITOR:
case FX_TRACK_3_SET_MONITOR:
case FX_TRACK_4_SET_MONITOR:
case FX_TRACK_5_SET_MONITOR:
case FX_TRACK_6_SET_MONITOR:
case FX_TRACK_7_SET_MONITOR:
case FX_TRACK_8_SET_MONITOR:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_SET_MONITOR.ordinal()).setMonitor(value.isPositive());
break;
// Track 1: Toggle Auto Monitor
case FX_TRACK_1_TOGGLE_AUTO_MONITOR:
case FX_TRACK_2_TOGGLE_AUTO_MONITOR:
case FX_TRACK_3_TOGGLE_AUTO_MONITOR:
case FX_TRACK_4_TOGGLE_AUTO_MONITOR:
case FX_TRACK_5_TOGGLE_AUTO_MONITOR:
case FX_TRACK_6_TOGGLE_AUTO_MONITOR:
case FX_TRACK_7_TOGGLE_AUTO_MONITOR:
case FX_TRACK_8_TOGGLE_AUTO_MONITOR:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_TOGGLE_AUTO_MONITOR.ordinal()).toggleAutoMonitor();
break;
// Track 1: Set Auto Monitor
case FX_TRACK_1_SET_AUTO_MONITOR:
case FX_TRACK_2_SET_AUTO_MONITOR:
case FX_TRACK_3_SET_AUTO_MONITOR:
case FX_TRACK_4_SET_AUTO_MONITOR:
case FX_TRACK_5_SET_AUTO_MONITOR:
case FX_TRACK_6_SET_AUTO_MONITOR:
case FX_TRACK_7_SET_AUTO_MONITOR:
case FX_TRACK_8_SET_AUTO_MONITOR:
if (isButtonPressed)
effectTrackBank.getItem(command.ordinal() - FlexiCommand.FX_TRACK_1_SET_AUTO_MONITOR.ordinal()).setAutoMonitor(value.isPositive());
break;
default:
throw new FlexiHandlerException(command);
}
}
Aggregations