use of de.mossgrabers.framework.command.core.ContinuousCommand in project DrivenByMoss by git-moss.
the class AbstractControllerSetup method test.
/**
* {@inheritDoc}
*/
@Override
public void test(final TestCallback callback) {
final TestFramework framework = new TestFramework(this.host);
this.getSurfaces().forEach(surface -> {
framework.scheduleFunction(() -> this.host.println("Testing controller: " + this.getClass().getName()));
final ViewManager viewManager = surface.getViewManager();
final ModeManager modeManager = surface.getModeManager();
final int max = this.model.getValueChanger().getUpperBound() - 1;
for (final Views viewID : Views.values()) {
if (viewManager.get(viewID) == null)
continue;
for (final Modes modeID : Modes.values()) {
if (modeManager.get(modeID) == null)
continue;
framework.scheduleFunction(() -> {
this.host.println("- View " + viewID + " Mode " + modeID);
viewManager.setActive(viewID);
modeManager.setActive(modeID);
for (final ButtonID buttonID : ButtonID.values()) {
final IHwButton button = surface.getButton(buttonID);
if (button == null)
continue;
button.trigger(ButtonEvent.DOWN);
button.trigger(ButtonEvent.LONG);
button.trigger(ButtonEvent.UP);
}
for (final ContinuousID continuousID : ContinuousID.values()) {
final IHwContinuousControl continuous = surface.getContinuous(continuousID);
if (continuous == null)
continue;
final TriggerCommand touchCommand = continuous.getTouchCommand();
if (touchCommand != null) {
touchCommand.execute(ButtonEvent.DOWN, 127);
touchCommand.execute(ButtonEvent.LONG, 127);
touchCommand.execute(ButtonEvent.UP, 0);
}
final ContinuousCommand command = continuous.getCommand();
if (command != null) {
command.execute(0);
command.execute(max);
command.execute(max / 2);
}
final PitchbendCommand pitchbendCommand = continuous.getPitchbendCommand();
if (pitchbendCommand != null) {
pitchbendCommand.onPitchbend(0, 0);
pitchbendCommand.onPitchbend(0, 127);
pitchbendCommand.onPitchbend(0, 64);
}
}
});
}
}
});
callback.startTesting();
framework.executeScheduler(callback);
}
use of de.mossgrabers.framework.command.core.ContinuousCommand in project DrivenByMoss by git-moss.
the class HUIControlSurface method handleMidi.
/**
* {@inheritDoc}
*/
@Override
protected void handleMidi(final int status, final int data1, final int data2) {
final int code = status & 0xF0;
if (code != 0xB0)
return;
switch(data1) {
// Move fader high-byte
case 0x00:
case 0x01:
case 0x02:
case 0x03:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
// This is an iCON extension
case 0x08:
this.faderHiValues[data1] = data2;
break;
case 0x0d:
final int d = ENCODER.encode(DECODER.decode(data2));
this.getContinuous(ContinuousID.PLAY_POSITION).getCommand().execute(d);
break;
// Button zone selection
case 0x0F:
this.zone = data2;
break;
// Move fader low-byte
case 0x20:
case 0x21:
case 0x22:
case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
final int chnl = data1 - 0x20;
final int value = (this.faderHiValues[chnl] << 7) + data2;
final ContinuousCommand command = this.getContinuous(ContinuousID.get(ContinuousID.FADER1, chnl)).getCommand();
((WorkaroundFader) command).executeHiRes(value);
break;
case 0x28:
final int masterValue = (this.faderHiValues[8] << 7) + data2;
((WorkaroundMasterFader) this.getContinuous(ContinuousID.FADER_MASTER).getCommand()).executeHiRes(masterValue);
break;
// Button port up/down (a button in the selected row)
case 0x2F:
final boolean isDown = data2 >= 0x40;
final int buttonIndex = this.zone * 8 + data2 % 8;
final IHwButton button = this.huiButtons.get(Integer.valueOf(buttonIndex));
if (button == null)
this.host.error("Button " + buttonIndex + " not supported (Zone: " + this.zone + " Index: " + data2 % 8 + ")");
else
button.trigger(isDown ? ButtonEvent.DOWN : ButtonEvent.UP);
break;
case 0x40:
case 0x41:
case 0x42:
case 0x43:
case 0x44:
case 0x45:
case 0x46:
case 0x47:
final int channel = data1 - 0x40;
final int v = data2 > 0x40 ? data2 - 0x40 : 128 - data2;
this.getContinuous(ContinuousID.get(ContinuousID.KNOB1, channel)).getCommand().execute(v);
break;
default:
this.host.println("Unhandled MIDI CC: " + data1);
break;
}
}
Aggregations