Search in sources :

Example 1 with EncoderMode

use of de.mossgrabers.controller.ni.maschine.core.command.trigger.EncoderMode in project DrivenByMoss by git-moss.

the class MaschineControllerSetup method flush.

/**
 * {@inheritDoc}
 */
@Override
public void flush() {
    super.flush();
    final MaschineControlSurface surface = this.getSurface();
    final TouchstripCommand command = (TouchstripCommand) surface.getContinuous(ContinuousID.CROSSFADER).getCommand();
    if (command != null)
        command.updateValue();
    if (this.maschine == Maschine.STUDIO) {
        // Update main VU
        final IMidiOutput midiOutput = surface.getMidiOutput();
        final int value;
        if (this.encoderManager.isParameterMode()) {
            final EncoderMode activeEncoderMode = this.encoderManager.getActiveEncoderMode();
            switch(activeEncoderMode) {
                case MASTER_VOLUME:
                    value = this.valueChanger.toMidiValue(this.model.getMasterTrack().getVolume());
                    break;
                case MASTER_PANORAMA:
                    value = this.valueChanger.toMidiValue(this.model.getMasterTrack().getPan());
                    break;
                case SELECTED_TRACK_VOLUME:
                case SELECTED_TRACK_PANORAMA:
                    final ITrack track;
                    final Optional<ITrack> trackOptional = this.model.getTrackBank().getSelectedItem();
                    if (trackOptional.isPresent())
                        track = trackOptional.get();
                    else
                        track = EmptyTrack.INSTANCE;
                    value = this.valueChanger.toMidiValue(activeEncoderMode == EncoderMode.SELECTED_TRACK_VOLUME ? track.getVolume() : track.getPan());
                    break;
                case CUE_VOLUME:
                    value = this.valueChanger.toMidiValue(this.model.getProject().getCueVolume());
                    break;
                case CUE_MIX:
                    value = this.valueChanger.toMidiValue(this.model.getProject().getCueMix());
                    break;
                case METRONOME_VOLUME:
                    value = this.valueChanger.toMidiValue(this.model.getTransport().getMetronomeVolume());
                    break;
                default:
                    value = 0;
                    break;
            }
        } else {
            final ITrack track;
            if (this.encoderManager.isActiveEncoderMode(EncoderMode.SELECTED_TRACK_VOLUME)) {
                final Optional<ITrack> trackOptional = this.model.getTrackBank().getSelectedItem();
                if (trackOptional.isPresent())
                    track = trackOptional.get();
                else
                    track = EmptyTrack.INSTANCE;
            } else
                track = this.model.getMasterTrack();
            value = this.valueChanger.toMidiValue(track.getVu());
        }
        midiOutput.sendCC(MaschineControlSurface.MONITOR_ENCODER, value);
    }
}
Also used : EncoderMode(de.mossgrabers.controller.ni.maschine.core.command.trigger.EncoderMode) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) ITrack(de.mossgrabers.framework.daw.data.ITrack) MaschineControlSurface(de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface) TouchstripCommand(de.mossgrabers.controller.ni.maschine.mk3.command.continuous.TouchstripCommand)

Aggregations

EncoderMode (de.mossgrabers.controller.ni.maschine.core.command.trigger.EncoderMode)1 TouchstripCommand (de.mossgrabers.controller.ni.maschine.mk3.command.continuous.TouchstripCommand)1 MaschineControlSurface (de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface)1 ITrack (de.mossgrabers.framework.daw.data.ITrack)1 IMidiOutput (de.mossgrabers.framework.daw.midi.IMidiOutput)1