Search in sources :

Example 6 with IHwButton

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());
}
Also used : FrameworkException(de.mossgrabers.framework.utils.FrameworkException) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 7 with IHwButton

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);
}
Also used : IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 8 with IHwButton

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;
}
Also used : StepState(de.mossgrabers.framework.daw.StepState) IStepInfo(de.mossgrabers.framework.daw.IStepInfo) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 9 with IHwButton

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;
}
Also used : IHwTextDisplay(de.mossgrabers.framework.controller.hardware.IHwTextDisplay) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton) HostImpl(de.mossgrabers.bitwig.framework.daw.HostImpl) Color(com.bitwig.extension.api.Color) IntConsumer(java.util.function.IntConsumer) IHwSurfaceFactory(de.mossgrabers.framework.controller.hardware.IHwSurfaceFactory) HardwareLightVisualState(com.bitwig.extension.controller.api.HardwareLightVisualState) OutputID(de.mossgrabers.framework.controller.OutputID) Supplier(java.util.function.Supplier) IHwPianoKeyboard(de.mossgrabers.framework.controller.hardware.IHwPianoKeyboard) RelativeEncoding(de.mossgrabers.framework.controller.valuechanger.RelativeEncoding) ButtonID(de.mossgrabers.framework.controller.ButtonID) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IntSupplier(java.util.function.IntSupplier) IntFunction(java.util.function.IntFunction) BitmapImpl(de.mossgrabers.bitwig.framework.graphics.BitmapImpl) IHwLight(de.mossgrabers.framework.controller.hardware.IHwLight) OperatingSystem(de.mossgrabers.framework.utils.OperatingSystem) MultiStateHardwareLight(com.bitwig.extension.controller.api.MultiStateHardwareLight) HardwareButton(com.bitwig.extension.controller.api.HardwareButton) ContinuousID(de.mossgrabers.framework.controller.ContinuousID) IHwFader(de.mossgrabers.framework.controller.hardware.IHwFader) Consumer(java.util.function.Consumer) IBitmap(de.mossgrabers.framework.graphics.IBitmap) IHwAbsoluteKnob(de.mossgrabers.framework.controller.hardware.IHwAbsoluteKnob) IHwGraphicsDisplay(de.mossgrabers.framework.controller.hardware.IHwGraphicsDisplay) IHwRelativeKnob(de.mossgrabers.framework.controller.hardware.IHwRelativeKnob) HardwareSurface(com.bitwig.extension.controller.api.HardwareSurface) InternalHardwareLightState(com.bitwig.extension.controller.api.InternalHardwareLightState) MultiStateHardwareLight(com.bitwig.extension.controller.api.MultiStateHardwareLight) InternalHardwareLightState(com.bitwig.extension.controller.api.InternalHardwareLightState) HardwareLightVisualState(com.bitwig.extension.controller.api.HardwareLightVisualState)

Example 10 with IHwButton

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);
}
Also used : IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Aggregations

IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)17 ButtonID (de.mossgrabers.framework.controller.ButtonID)4 IStepInfo (de.mossgrabers.framework.daw.IStepInfo)4 StepState (de.mossgrabers.framework.daw.StepState)4 IntSupplier (java.util.function.IntSupplier)4 BindType (de.mossgrabers.framework.controller.hardware.BindType)3 IMidiInput (de.mossgrabers.framework.daw.midi.IMidiInput)3 AbstractTriggerCommand (de.mossgrabers.framework.command.core.AbstractTriggerCommand)2 ContinuousCommand (de.mossgrabers.framework.command.core.ContinuousCommand)2 IHwLight (de.mossgrabers.framework.controller.hardware.IHwLight)2 IHost (de.mossgrabers.framework.daw.IHost)2 IMidiOutput (de.mossgrabers.framework.daw.midi.IMidiOutput)2 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)2 Views (de.mossgrabers.framework.view.Views)2 Color (com.bitwig.extension.api.Color)1 HardwareButton (com.bitwig.extension.controller.api.HardwareButton)1 HardwareLightVisualState (com.bitwig.extension.controller.api.HardwareLightVisualState)1 HardwareSurface (com.bitwig.extension.controller.api.HardwareSurface)1 InternalHardwareLightState (com.bitwig.extension.controller.api.InternalHardwareLightState)1 MultiStateHardwareLight (com.bitwig.extension.controller.api.MultiStateHardwareLight)1