use of de.mossgrabers.framework.controller.hardware.IHwButton in project DrivenByMoss by git-moss.
the class AbstractMode method setParameterProvider.
/**
* Set the parameters controlled by this mode if used with the given button combination.
*
* @param buttonID The ID of the button which can activate the given parameters
* @param parameterProvider Interface to get a number of parameters
*/
protected void setParameterProvider(final ButtonID buttonID, final IParameterProvider parameterProvider) {
if (this.controls.size() != parameterProvider.size())
throw new FrameworkException("Number of knobs must match the number of parameters!");
if (buttonID == null) {
this.defaultParameterProvider = parameterProvider;
return;
}
final IHwButton button = this.surface.getButton(buttonID);
if (button == null)
throw new FrameworkException("Attempt to set parameters for non-existing button " + buttonID + "!");
this.parameterProviders.put(buttonID, parameterProvider);
button.addEventHandler(ButtonEvent.DOWN, event -> this.bindControls());
button.addEventHandler(ButtonEvent.UP, event -> this.bindControls());
}
use of de.mossgrabers.framework.controller.hardware.IHwButton in project DrivenByMoss by git-moss.
the class AbstractDrumView method registerButtonMonitors.
private void registerButtonMonitors(final ButtonID buttonID) {
final IHwButton button = this.surface.getButton(buttonID);
if (button == null)
return;
button.addEventHandler(ButtonEvent.DOWN, this);
button.addEventHandler(ButtonEvent.UP, this);
}
use of de.mossgrabers.framework.controller.hardware.IHwButton in project DrivenByMoss by git-moss.
the class AbstractDrumView method handleSequencerAreaButtonCombinations.
/**
* Handle button combinations in the sequencer area.
*
* @param clip The sequenced MIDI clip
* @param channel The MIDI channel of the note
* @param step The step in the current page in the clip
* @param note The note in the current page of the pad in the clip
* @param velocity The velocity
* @return True if handled
*/
protected boolean handleSequencerAreaButtonCombinations(final INoteClip clip, final int channel, final int step, final int note, final int velocity) {
// Handle note duplicate function
if (this.isButtonCombination(ButtonID.DUPLICATE)) {
final IStepInfo noteStep = clip.getStep(channel, step, note);
if (noteStep.getState() == StepState.START)
this.copyNote = noteStep;
else if (this.copyNote != null)
clip.setStep(channel, step, note, this.copyNote);
return true;
}
if (this.isButtonCombination(ButtonID.MUTE)) {
final IStepInfo stepInfo = clip.getStep(channel, step, note);
final StepState isSet = stepInfo.getState();
if (isSet == StepState.START)
this.getClip().updateMuteState(channel, step, note, !stepInfo.isMuted());
return true;
}
// Change length of a note or create a new one with a length
for (int s = 0; s < step; s++) {
final int pad = this.getPadIndex(s);
final IHwButton button = this.surface.getButton(ButtonID.get(this.firstPad, pad));
if (button.isLongPressed()) {
button.setConsumed();
final int length = step - s + 1;
final double duration = length * Resolution.getValueAt(this.getResolutionIndex());
final StepState state = note < 0 ? StepState.OFF : clip.getStep(channel, s, note).getState();
if (state == StepState.START)
clip.updateStepDuration(channel, s, note, duration);
else
clip.setStep(channel, s, note, velocity, duration);
return true;
}
}
return false;
}
use of de.mossgrabers.framework.controller.hardware.IHwButton in project DrivenByMoss by git-moss.
the class HwSurfaceFactoryImpl method createLight.
/**
* {@inheritDoc}
*/
@Override
public IHwLight createLight(final int surfaceID, final OutputID outputID, final IntSupplier supplier, final IntConsumer sendValueConsumer, final IntFunction<ColorEx> stateToColorFunction, final IHwButton button) {
this.lightCounter++;
final String id = createID(surfaceID, outputID == null ? "LIGHT" + this.lightCounter : outputID.name());
final MultiStateHardwareLight hardwareLight = this.hardwareSurface.createMultiStateHardwareLight(id);
final Supplier<InternalHardwareLightState> valueSupplier = () -> new EncodedColorLightState(supplier.getAsInt(), stateToColorFunction);
final Consumer<InternalHardwareLightState> hardwareUpdater = state -> {
final HardwareLightVisualState visualState = state == null ? null : state.getVisualState();
final int encodedColorState = visualState == null ? 0 : supplier.getAsInt();
sendValueConsumer.accept(encodedColorState);
};
final HwLightImpl lightImpl = new HwLightImpl(this.host, hardwareLight, valueSupplier, hardwareUpdater);
if (button != null)
button.addLight(lightImpl);
return lightImpl;
}
use of de.mossgrabers.framework.controller.hardware.IHwButton in project DrivenByMoss by git-moss.
the class AbstractDrumView method unregisterButtonMonitors.
private void unregisterButtonMonitors(final ButtonID buttonID) {
final IHwButton button = this.surface.getButton(buttonID);
if (button == null)
return;
button.removeEventHandler(ButtonEvent.DOWN, this);
button.removeEventHandler(ButtonEvent.UP, this);
}
Aggregations