Search in sources :

Example 1 with KontrolProtocolConfiguration

use of de.mossgrabers.controller.ni.kontrol.mkii.KontrolProtocolConfiguration in project DrivenByMoss by git-moss.

the class MixerMode method getKnobValue.

/**
 * {@inheritDoc}
 */
@Override
public int getKnobValue(final int index) {
    // Note: Since we need multiple value (more than 8), index is the MIDI CC of the knob
    final IValueChanger valueChanger = this.model.getValueChanger();
    if (index >= KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME && index < KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME + 8) {
        final ITrack track = this.bank.getItem(index - KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME);
        return valueChanger.toMidiValue(track.getVolume());
    }
    if (index >= KontrolProtocolControlSurface.KONTROL_TRACK_PAN && index < KontrolProtocolControlSurface.KONTROL_TRACK_PAN + 8) {
        final ITrack track = this.bank.getItem(index - KontrolProtocolControlSurface.KONTROL_TRACK_PAN);
        return valueChanger.toMidiValue(track.getPan());
    }
    final Optional<ITrack> selectedTrack = this.bank.getSelectedItem();
    final int scrollTracksState = (this.bank.canScrollBackwards() ? 1 : 0) + (this.bank.canScrollForwards() ? 2 : 0);
    int scrollClipsState = 0;
    if (selectedTrack.isPresent()) {
        final ISlotBank slotBank = selectedTrack.get().getSlotBank();
        scrollClipsState = (slotBank.canScrollBackwards() ? 1 : 0) + (slotBank.canScrollForwards() ? 2 : 0);
    }
    final ISceneBank sceneBank = this.model.getSceneBank();
    final int scrollScenesState = (sceneBank.canScrollBackwards() ? 1 : 0) + (sceneBank.canScrollForwards() ? 2 : 0);
    final KontrolProtocolConfiguration configuration = this.surface.getConfiguration();
    switch(index) {
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS:
            return (this.bank.canScrollPageBackwards() ? 1 : 0) + (this.bank.canScrollPageForwards() ? 2 : 0);
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS:
            if (configuration.isFlipTrackClipNavigation())
                return configuration.isFlipClipSceneNavigation() ? scrollScenesState : scrollClipsState;
            return scrollTracksState;
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS:
            if (configuration.isFlipTrackClipNavigation())
                return scrollTracksState;
            return configuration.isFlipClipSceneNavigation() ? scrollScenesState : scrollClipsState;
        default:
            return 0;
    }
}
Also used : ISlotBank(de.mossgrabers.framework.daw.data.bank.ISlotBank) ISceneBank(de.mossgrabers.framework.daw.data.bank.ISceneBank) ITrack(de.mossgrabers.framework.daw.data.ITrack) IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) KontrolProtocolConfiguration(de.mossgrabers.controller.ni.kontrol.mkii.KontrolProtocolConfiguration)

Example 2 with KontrolProtocolConfiguration

use of de.mossgrabers.controller.ni.kontrol.mkii.KontrolProtocolConfiguration in project DrivenByMoss by git-moss.

the class ParamsMode method getKnobValue.

/**
 * {@inheritDoc}
 */
@Override
public int getKnobValue(final int index) {
    // Note: Since we need multiple value (more than 8), index is the MIDI CC of the knob
    final IValueChanger valueChanger = this.model.getValueChanger();
    if (index >= KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME && index < KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME + 8) {
        final IParameter parameter = this.bank.getItem(index - KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME);
        return valueChanger.toMidiValue(parameter.getValue());
    }
    if (index >= KontrolProtocolControlSurface.KONTROL_TRACK_PAN && index < KontrolProtocolControlSurface.KONTROL_TRACK_PAN + 8) {
        final IParameter parameter = this.bank.getItem(index - KontrolProtocolControlSurface.KONTROL_TRACK_PAN);
        return valueChanger.toMidiValue(parameter.getValue());
    }
    final int scrollTracksState = (this.bank.canScrollBackwards() ? 1 : 0) + (this.bank.canScrollForwards() ? 2 : 0);
    final IDeviceBank deviceBank = this.cursorDevice.getDeviceBank();
    final int scrollScenesState = (deviceBank.canScrollBackwards() ? 1 : 0) + (deviceBank.canScrollForwards() ? 2 : 0);
    final KontrolProtocolConfiguration configuration = this.surface.getConfiguration();
    switch(index) {
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS:
            return (this.cursorDevice.canSelectPreviousFX() ? 1 : 0) + (this.cursorDevice.canSelectNextFX() ? 2 : 0);
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS:
            return configuration.isFlipTrackClipNavigation() ? scrollScenesState : scrollTracksState;
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS:
            return configuration.isFlipTrackClipNavigation() ? scrollTracksState : scrollScenesState;
        default:
            return 0;
    }
}
Also used : IParameter(de.mossgrabers.framework.daw.data.IParameter) IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) IDeviceBank(de.mossgrabers.framework.daw.data.bank.IDeviceBank) KontrolProtocolConfiguration(de.mossgrabers.controller.ni.kontrol.mkii.KontrolProtocolConfiguration)

Example 3 with KontrolProtocolConfiguration

use of de.mossgrabers.controller.ni.kontrol.mkii.KontrolProtocolConfiguration in project DrivenByMoss by git-moss.

the class SendMode method getKnobValue.

/**
 * {@inheritDoc}
 */
@Override
public int getKnobValue(final int index) {
    // Note: Since we need multiple value (more than 8), index is the MIDI CC of the knob
    final IValueChanger valueChanger = this.model.getValueChanger();
    final Optional<ITrack> selectedTrack = this.bank.getSelectedItem();
    final ISendBank sendBank = selectedTrack.isEmpty() ? null : selectedTrack.get().getSendBank();
    if (index >= KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME && index < KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME + 8) {
        final ISend send = sendBank == null ? EmptySend.INSTANCE : sendBank.getItem(index - KontrolProtocolControlSurface.KONTROL_TRACK_VOLUME);
        return valueChanger.toMidiValue(send.getValue());
    }
    if (index >= KontrolProtocolControlSurface.KONTROL_TRACK_PAN && index < KontrolProtocolControlSurface.KONTROL_TRACK_PAN + 8) {
        final ISend send = sendBank == null ? EmptySend.INSTANCE : sendBank.getItem(index - KontrolProtocolControlSurface.KONTROL_TRACK_PAN);
        return valueChanger.toMidiValue(send.getValue());
    }
    final int scrollTracksState = (sendBank != null && sendBank.canScrollPageBackwards() ? 1 : 0) + (sendBank != null && sendBank.canScrollPageForwards() ? 2 : 0);
    final int scrollScenesState = 0;
    final KontrolProtocolConfiguration configuration = this.surface.getConfiguration();
    switch(index) {
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_BANKS:
            return scrollTracksState;
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_TRACKS:
            return configuration.isFlipTrackClipNavigation() ? scrollScenesState : scrollTracksState;
        case KontrolProtocolControlSurface.KONTROL_NAVIGATE_CLIPS:
            return configuration.isFlipTrackClipNavigation() ? scrollTracksState : scrollScenesState;
        default:
            return 0;
    }
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) ISend(de.mossgrabers.framework.daw.data.ISend) KontrolProtocolConfiguration(de.mossgrabers.controller.ni.kontrol.mkii.KontrolProtocolConfiguration) ISendBank(de.mossgrabers.framework.daw.data.bank.ISendBank)

Aggregations

KontrolProtocolConfiguration (de.mossgrabers.controller.ni.kontrol.mkii.KontrolProtocolConfiguration)3 IValueChanger (de.mossgrabers.framework.controller.valuechanger.IValueChanger)3 ITrack (de.mossgrabers.framework.daw.data.ITrack)2 IParameter (de.mossgrabers.framework.daw.data.IParameter)1 ISend (de.mossgrabers.framework.daw.data.ISend)1 IDeviceBank (de.mossgrabers.framework.daw.data.bank.IDeviceBank)1 ISceneBank (de.mossgrabers.framework.daw.data.bank.ISceneBank)1 ISendBank (de.mossgrabers.framework.daw.data.bank.ISendBank)1 ISlotBank (de.mossgrabers.framework.daw.data.bank.ISlotBank)1