use of de.mossgrabers.framework.controller.IValueChanger in project DrivenByMoss by git-moss.
the class DeviceParamsMode method updateDisplay2.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay2() {
final PushDisplay display = (PushDisplay) this.surface.getDisplay();
final DisplayMessage message = display.createMessage();
final ICursorDevice cd = this.model.getCursorDevice();
if (!cd.hasSelectedDevice()) {
for (int i = 0; i < 8; i++) message.addOptionElement(i == 2 ? "Please select a device or press 'Add Device'..." : "", i == 7 ? "Up" : "", true, "", "", false, true);
display.send(message);
return;
}
final IChannelBank tb = this.model.getCurrentTrackBank();
final String color = tb.getSelectedTrackColorEntry();
final IValueChanger valueChanger = this.model.getValueChanger();
final String[] pages = cd.getParameterPageNames();
final int page = Math.min(Math.max(0, cd.getSelectedParameterPage()), pages.length - 1);
final int start = page / 8 * 8;
final boolean hasPinning = this.model.getHost().hasPinning();
for (int i = 0; i < 8; i++) {
boolean isTopMenuOn;
switch(i) {
case 0:
isTopMenuOn = cd.isEnabled();
break;
case 1:
isTopMenuOn = cd.isParameterPageSectionVisible();
break;
case 2:
isTopMenuOn = cd.isExpanded();
break;
case 4:
isTopMenuOn = !this.showDevices;
break;
case 5:
isTopMenuOn = hasPinning && cd.isPinned();
break;
case 6:
isTopMenuOn = cd.isWindowOpen();
break;
case 7:
isTopMenuOn = true;
break;
default:
// Not used
isTopMenuOn = false;
break;
}
String bottomMenu;
final String bottomMenuIcon = "";
boolean isBottomMenuOn;
if (this.showDevices) {
bottomMenu = cd.doesSiblingExist(i) ? cd.getSiblingDeviceName(i, 12) : "";
isBottomMenuOn = i == cd.getPositionInBank();
} else {
final int index = start + i;
bottomMenu = index < pages.length ? pages[index] : "";
if (bottomMenu.length() > 12)
bottomMenu = bottomMenu.substring(0, 12);
isBottomMenuOn = index == page;
}
final double[] bottomMenuColor = BitwigColors.getColorEntry(color);
final IParameter param = cd.getFXParam(i);
final boolean exists = param.doesExist();
final String parameterName = exists ? param.getName(9) : "";
final int parameterValue = valueChanger.toDisplayValue(exists ? param.getValue() : 0);
final String parameterValueStr = exists ? param.getDisplayedValue(8) : "";
final boolean parameterIsActive = this.isKnobTouched[i];
final int parameterModulatedValue = valueChanger.toDisplayValue(exists ? param.getModulatedValue() : -1);
message.addParameterElement(i != 5 || hasPinning ? MENU[i] : "", isTopMenuOn, bottomMenu, bottomMenuIcon, bottomMenuColor, isBottomMenuOn, parameterName, parameterValue, parameterValueStr, parameterIsActive, parameterModulatedValue);
}
display.send(message);
}
use of de.mossgrabers.framework.controller.IValueChanger in project DrivenByMoss by git-moss.
the class MasterMode method updateDisplay2.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay2() {
final IMasterTrack master = this.model.getMasterTrack();
final IValueChanger valueChanger = this.model.getValueChanger();
final PushDisplay display = (PushDisplay) this.surface.getDisplay();
final DisplayMessage message = display.createMessage();
message.addChannelElement("Volume", false, master.getName(), ChannelType.MASTER, master.getColor(), master.isSelected(), valueChanger.toDisplayValue(master.getVolume()), valueChanger.toDisplayValue(master.getModulatedVolume()), this.isKnobTouched[0] ? master.getVolumeStr(8) : "", valueChanger.toDisplayValue(master.getPan()), valueChanger.toDisplayValue(master.getModulatedPan()), this.isKnobTouched[1] ? master.getPanStr(8) : "", valueChanger.toDisplayValue(this.surface.getConfiguration().isEnableVUMeters() ? master.getVu() : 0), master.isMute(), master.isSolo(), master.isRecArm(), 0);
for (int i = 1; i < 4; i++) {
message.addChannelSelectorElement(i == 1 ? "Pan" : "", false, "", null, new double[] { 0.0, 0.0, 0.0 }, false);
}
message.addOptionElement("", "", false, "Audio Engine", this.model.getApplication().isEngineActive() ? "Active" : "Off", false, false);
message.addOptionElement("", "", false, "", "", false, false);
message.addOptionElement("Project:", "", false, this.model.getProject().getName(), "Previous", false, false);
message.addOptionElement("", "", false, "", "Next", false, false);
display.send(message);
}
use of de.mossgrabers.framework.controller.IValueChanger in project DrivenByMoss by git-moss.
the class NoteMode method onValueKnob.
/**
* {@inheritDoc}
*/
@Override
public void onValueKnob(final int index, final int value) {
final IValueChanger valueChanger = this.model.getValueChanger();
switch(index) {
case 0:
if (!this.increaseKnobMovement())
return;
final double speed = valueChanger.calcKnobSpeed(value, 1);
this.noteLength += speed;
this.clip.clearStep(this.step, this.note);
this.clip.setStep(this.step, this.note, this.noteVelocity, this.noteLength);
break;
case 1:
if (!this.increaseKnobMovement())
return;
final double speed2 = valueChanger.calcKnobSpeed(value, 0.1);
this.noteLength += speed2;
this.clip.clearStep(this.step, this.note);
this.clip.setStep(this.step, this.note, this.noteVelocity, this.noteLength);
break;
case 2:
this.noteVelocity = valueChanger.changeValue(value, this.noteVelocity, 1, 128);
this.clip.clearStep(this.step, this.note);
this.clip.setStep(this.step, this.note, this.noteVelocity, this.noteLength);
break;
}
}
use of de.mossgrabers.framework.controller.IValueChanger in project DrivenByMoss by git-moss.
the class DeviceLayerMode method updateDisplayElements.
/**
* Update all 8 elements.
*
* @param message The display message
* @param cd The cursor device
* @param l The channel data
*/
protected void updateDisplayElements(final DisplayMessage message, final ICursorDevice cd, final IChannel l) {
// Drum Pad Bank has size of 16, layers only 8
final int offset = getDrumPadIndex(cd);
// Get the index at which to draw the Sends element
int sendsIndex = l == null ? -1 : l.getIndex() - offset + 1;
if (sendsIndex == 8)
sendsIndex = 6;
final PushConfiguration config = this.surface.getConfiguration();
for (int i = 0; i < 8; i++) {
final IChannel layer = cd.getLayerOrDrumPad(offset + i);
// The menu
String topMenu;
boolean topMenuSelected;
if (config.isMuteLongPressed() || config.isMuteSoloLocked() && config.isMuteState()) {
topMenu = layer.doesExist() ? "Mute" : "";
topMenuSelected = layer.isMute();
} else if (config.isSoloLongPressed() || config.isMuteSoloLocked() && config.isSoloState()) {
topMenu = layer.doesExist() ? "Solo" : "";
topMenuSelected = layer.isSolo();
} else {
topMenu = this.menu[i];
topMenuSelected = i == 7;
}
// Channel info
final String bottomMenu = layer.doesExist() ? layer.getName(12) : "";
final double[] bottomMenuColor = layer.getColor();
final boolean isBottomMenuOn = layer.isSelected();
if (layer.isSelected()) {
final IValueChanger valueChanger = this.model.getValueChanger();
message.addChannelElement(topMenu, topMenuSelected, bottomMenu, ChannelType.LAYER, bottomMenuColor, isBottomMenuOn, valueChanger.toDisplayValue(layer.getVolume()), valueChanger.toDisplayValue(layer.getModulatedVolume()), this.isKnobTouched[0] ? layer.getVolumeStr(8) : "", valueChanger.toDisplayValue(layer.getPan()), valueChanger.toDisplayValue(layer.getModulatedPan()), this.isKnobTouched[1] ? layer.getPanStr(8) : "", valueChanger.toDisplayValue(config.isEnableVUMeters() ? layer.getVu() : 0), layer.isMute(), layer.isSolo(), false, 0);
} else if (sendsIndex == i && l != null) {
final IChannelBank fxTrackBank = this.model.getEffectTrackBank();
final String[] sendName = new String[4];
final String[] valueStr = new String[4];
final int[] value = new int[4];
final int[] modulatedValue = new int[4];
final boolean[] selected = new boolean[4];
for (int j = 0; j < 4; j++) {
final int sendOffset = config.isSendsAreToggled() ? 4 : 0;
final int sendPos = sendOffset + j;
final ISend send = l.getSend(sendPos);
sendName[j] = fxTrackBank == null ? send.getName() : fxTrackBank.getTrack(sendPos).getName();
final boolean doesExist = send.doesExist();
valueStr[j] = doesExist && this.isKnobTouched[4 + j] ? send.getDisplayedValue() : "";
value[j] = doesExist ? send.getValue() : 0;
modulatedValue[j] = doesExist ? send.getModulatedValue() : 0;
selected[j] = true;
}
message.addSendsElement(topMenu, topMenuSelected, layer.doesExist() ? layer.getName() : "", ChannelType.LAYER, cd.getLayerOrDrumPad(offset + i).getColor(), layer.isSelected(), sendName, valueStr, value, modulatedValue, selected, true);
} else
message.addChannelSelectorElement(topMenu, topMenuSelected, bottomMenu, ChannelType.LAYER, bottomMenuColor, isBottomMenuOn);
}
}
use of de.mossgrabers.framework.controller.IValueChanger in project DrivenByMoss by git-moss.
the class DeviceLayerMode method updateChannelDisplay.
// Called from sub-classes
protected void updateChannelDisplay(final DisplayMessage message, final ICursorDevice cd, final int selectedMenu, final boolean isVolume, final boolean isPan) {
this.updateMenu();
final PushConfiguration config = this.surface.getConfiguration();
// Drum Pad Bank has size of 16, layers only 8
final int offset = getDrumPadIndex(cd);
final IValueChanger valueChanger = this.model.getValueChanger();
for (int i = 0; i < 8; i++) {
final IChannel layer = cd.getLayerOrDrumPad(offset + i);
// The menu item
String topMenu;
boolean isTopMenuOn;
if (config.isMuteLongPressed() || config.isMuteSoloLocked() && config.isMuteState()) {
topMenu = layer.doesExist() ? "Mute" : "";
isTopMenuOn = layer.isMute();
} else if (config.isSoloLongPressed() || config.isMuteSoloLocked() && config.isSoloState()) {
topMenu = layer.doesExist() ? "Solo" : "";
isTopMenuOn = layer.isSolo();
} else {
topMenu = this.menu[i];
isTopMenuOn = i == 7 || i == selectedMenu - 1;
}
message.addChannelElement(selectedMenu, topMenu, isTopMenuOn, layer.doesExist() ? layer.getName() : "", ChannelType.LAYER, cd.getLayerOrDrumPad(offset + i).getColor(), layer.isSelected(), valueChanger.toDisplayValue(layer.getVolume()), valueChanger.toDisplayValue(layer.getModulatedVolume()), isVolume && this.isKnobTouched[i] ? layer.getVolumeStr(8) : "", valueChanger.toDisplayValue(layer.getPan()), valueChanger.toDisplayValue(layer.getModulatedPan()), isPan && this.isKnobTouched[i] ? layer.getPanStr() : "", valueChanger.toDisplayValue(config.isEnableVUMeters() ? layer.getVu() : 0), layer.isMute(), layer.isSolo(), false, 0);
}
}
Aggregations