Search in sources :

Example 1 with MultiStateHardwareLight

use of com.bitwig.extension.controller.api.MultiStateHardwareLight in project DrivenByMoss by git-moss.

the class HwSurfaceFactoryImpl method createLight.

/**
 * {@inheritDoc}
 */
@Override
public IHwLight createLight(final int surfaceID, final OutputID outputID, final Supplier<ColorEx> supplier, final Consumer<ColorEx> sendValueConsumer) {
    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 RawColorLightState(supplier.get());
    final Consumer<InternalHardwareLightState> hardwareUpdater = state -> {
        final HardwareLightVisualState visualState = state == null ? null : state.getVisualState();
        final Color c = visualState == null ? Color.blackColor() : visualState.getColor();
        sendValueConsumer.accept(new ColorEx(c.getRed(), c.getGreen(), c.getBlue()));
    };
    return new HwLightImpl(this.host, hardwareLight, valueSupplier, hardwareUpdater);
}
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) Color(com.bitwig.extension.api.Color) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) HardwareLightVisualState(com.bitwig.extension.controller.api.HardwareLightVisualState)

Example 2 with MultiStateHardwareLight

use of com.bitwig.extension.controller.api.MultiStateHardwareLight 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)

Aggregations

Color (com.bitwig.extension.api.Color)2 HardwareButton (com.bitwig.extension.controller.api.HardwareButton)2 HardwareLightVisualState (com.bitwig.extension.controller.api.HardwareLightVisualState)2 HardwareSurface (com.bitwig.extension.controller.api.HardwareSurface)2 InternalHardwareLightState (com.bitwig.extension.controller.api.InternalHardwareLightState)2 MultiStateHardwareLight (com.bitwig.extension.controller.api.MultiStateHardwareLight)2 HostImpl (de.mossgrabers.bitwig.framework.daw.HostImpl)2 BitmapImpl (de.mossgrabers.bitwig.framework.graphics.BitmapImpl)2 ButtonID (de.mossgrabers.framework.controller.ButtonID)2 ContinuousID (de.mossgrabers.framework.controller.ContinuousID)2 OutputID (de.mossgrabers.framework.controller.OutputID)2 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)2 IHwAbsoluteKnob (de.mossgrabers.framework.controller.hardware.IHwAbsoluteKnob)2 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)2 IHwFader (de.mossgrabers.framework.controller.hardware.IHwFader)2 IHwGraphicsDisplay (de.mossgrabers.framework.controller.hardware.IHwGraphicsDisplay)2 IHwLight (de.mossgrabers.framework.controller.hardware.IHwLight)2 IHwPianoKeyboard (de.mossgrabers.framework.controller.hardware.IHwPianoKeyboard)2 IHwRelativeKnob (de.mossgrabers.framework.controller.hardware.IHwRelativeKnob)2 IHwSurfaceFactory (de.mossgrabers.framework.controller.hardware.IHwSurfaceFactory)2