use of de.mossgrabers.framework.controller.grid.LightInfo in project DrivenByMoss by git-moss.
the class BeatstepControllerSetup method registerTriggerCommands.
/**
* {@inheritDoc}
*/
@Override
protected void registerTriggerCommands() {
final BeatstepControlSurface surface = this.getSurface();
final ViewManager viewManager = surface.getViewManager();
this.addButton(ButtonID.SHIFT, "Shift", (event, value) -> {
if (event == ButtonEvent.DOWN) {
viewManager.setActive(Views.SHIFT);
return;
}
if (event == ButtonEvent.UP) {
if (viewManager.isActive(Views.SHIFT))
viewManager.restore();
// Red LED is turned off on button release, restore the correct color
final BeatstepPadGrid beatstepPadGrid = (BeatstepPadGrid) surface.getPadGrid();
for (int note = 36; note < 52; note++) {
final LightInfo lightInfo = beatstepPadGrid.getLightInfo(note);
beatstepPadGrid.lightPad(note, lightInfo.getColor());
}
}
}, BeatstepControlSurface.BEATSTEP_SHIFT);
}
use of de.mossgrabers.framework.controller.grid.LightInfo in project DrivenByMoss by git-moss.
the class BeatstepControlSurface method handleGridNote.
/**
* {@inheritDoc}
*/
@Override
protected void handleGridNote(final ButtonEvent event, final int note, final int velocity) {
super.handleGridNote(event, note, velocity);
if (event == ButtonEvent.UP) {
// Red LED is turned off on button release, restore the correct color
final LightInfo lightInfo = this.padGrid.getLightInfo(note);
((BeatstepPadGrid) this.padGrid).lightPad(note, lightInfo.getColor());
}
}
use of de.mossgrabers.framework.controller.grid.LightInfo in project DrivenByMoss by git-moss.
the class AbstractLaunchpadDefinition method buildLEDUpdate.
/**
* {@inheritDoc}
*/
@Override
public List<String> buildLEDUpdate(final Map<Integer, LightInfo> padInfos) {
final StringBuilder sb = new StringBuilder(this.getSysExHeader()).append("03 ");
for (final Entry<Integer, LightInfo> e : padInfos.entrySet()) {
final int note = e.getKey().intValue();
final LightInfo info = e.getValue();
if (info.getBlinkColor() <= 0) {
// 00h: Static color from palette, Lighting data is 1 byte specifying palette
// entry.
sb.append("00 ").append(StringUtils.toHexStr(note)).append(' ').append(StringUtils.toHexStr(info.getColor())).append(' ');
} else {
if (info.isFast()) {
// 01h: Flashing color, Lighting data is 2 bytes specifying Color B and
// Color A.
sb.append("01 ").append(StringUtils.toHexStr(note)).append(' ').append(StringUtils.toHexStr(info.getBlinkColor())).append(' ').append(StringUtils.toHexStr(info.getColor())).append(' ');
} else {
// 02h: Pulsing color, Lighting data is 1 byte specifying palette entry.
sb.append("02 ").append(StringUtils.toHexStr(note)).append(' ').append(StringUtils.toHexStr(info.getColor())).append(' ');
}
}
}
return Collections.singletonList(sb.append("F7").toString());
}
use of de.mossgrabers.framework.controller.grid.LightInfo in project DrivenByMoss by git-moss.
the class MaschinePadGrid method updateController.
/**
* {@inheritDoc}
*/
@Override
protected void updateController() {
final int channel = 0;
for (final Entry<Integer, LightInfo> e : this.padInfos.entrySet()) {
final Integer note = e.getKey();
final LightInfo info = e.getValue();
// Note: The exact PADx is not needed for getting the color
this.output.sendNoteEx(channel, note.intValue(), info.getColor());
// way
if (info.getBlinkColor() > 0)
this.blinkingLights.put(note, info);
else
this.blinkingLights.remove(note);
}
// Toggle blink colors every 600ms
if (!this.checkBlinking())
return;
for (final Entry<Integer, LightInfo> value : this.blinkingLights.entrySet()) {
final LightInfo info = value.getValue();
final int colorIndex = this.isBlink ? info.getBlinkColor() : info.getColor();
final int note = value.getKey().intValue();
this.output.sendNoteEx(channel, note, colorIndex);
}
}
use of de.mossgrabers.framework.controller.grid.LightInfo in project DrivenByMoss by git-moss.
the class AbstractSessionView method drawBirdsEyeGrid.
/**
* Aggregate the content of 8 pads to 1 pads for quick navigation through the clip matrix.
*/
protected void drawBirdsEyeGrid() {
final ITrackBank tb = this.model.getCurrentTrackBank();
final ISceneBank sceneBank = this.model.getSceneBank();
final int numTracks = tb.getPageSize();
final int numScenes = sceneBank.getPageSize();
final int sceneCount = sceneBank.getItemCount();
final int trackCount = tb.getItemCount();
final int maxScenePads = sceneCount / numScenes + (sceneCount % numScenes > 0 ? 1 : 0);
final int maxTrackPads = trackCount / numTracks + (trackCount % numTracks > 0 ? 1 : 0);
final int scenePosition = sceneBank.getScrollPosition();
final int trackPosition = tb.getItem(0).getPosition();
final int sceneSelection = scenePosition / numScenes + (scenePosition % numScenes > 0 ? 1 : 0);
final int trackSelection = trackPosition / numTracks + (trackPosition % numTracks > 0 ? 1 : 0);
final boolean flipSession = this.surface.getConfiguration().isFlipSession();
int selX = flipSession ? sceneSelection : trackSelection;
int selY = flipSession ? trackSelection : sceneSelection;
final int padsX = flipSession ? this.rows : this.columns;
final int padsY = flipSession ? this.columns : this.rows;
final int offsetX = selX / padsX * padsX;
final int offsetY = selY / padsY * padsY;
final int maxX = (flipSession ? maxScenePads : maxTrackPads) - offsetX;
final int maxY = (flipSession ? maxTrackPads : maxScenePads) - offsetY;
selX -= offsetX;
selY -= offsetY;
final IPadGrid padGrid = this.surface.getPadGrid();
for (int x = 0; x < this.columns; x++) {
final LightInfo rowColor = x < maxX ? this.birdColorHasContent : this.clipColorHasNoContent;
for (int y = 0; y < this.rows; y++) {
LightInfo color = y < maxY ? rowColor : this.clipColorHasNoContent;
if (selX == x && selY == y)
color = this.birdColorSelected;
padGrid.lightEx(x, y, color.getColor(), color.getBlinkColor(), color.isFast());
}
}
}
Aggregations