Search in sources :

Example 21 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput 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)

Example 22 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.

the class GenericFlexiControllerSetup method createSurface.

/**
 * {@inheritDoc}
 */
@Override
protected void createSurface() {
    final IMidiAccess midiAccess = this.factory.createMidiAccess();
    final IMidiOutput output = midiAccess.createOutput();
    final String inputName;
    if (this.configuration.isMPEEndabled())
        inputName = "Generic Flexi (MPE)";
    else
        inputName = this.configuration.getKeyboardChannel() < 0 ? null : "Generic Flexi";
    final List<String> filters = this.getMidiFilters();
    final IMidiInput input = midiAccess.createInput(inputName, filters.toArray(new String[filters.size()]));
    final GenericFlexiControlSurface surface = new GenericFlexiControlSurface(this.host, this.configuration, this.colorManager, output, input);
    this.surfaces.add(surface);
    this.registerHandlers(surface);
    this.configuration.setCommandObserver(this);
}
Also used : GenericFlexiControlSurface(de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface) IMidiAccess(de.mossgrabers.framework.daw.midi.IMidiAccess) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput)

Example 23 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.

the class GenericFlexiControllerSetup method init.

/**
 * {@inheritDoc}
 */
@Override
public void init() {
    super.init();
    // Load program name file and create selection list if present
    final Optional<FileEx> programsFileOpt = this.configuration.getProgramsFile();
    if (programsFileOpt.isEmpty())
        return;
    try {
        final FileEx programsFile = programsFileOpt.get();
        final String nameWithoutType = programsFile.getNameWithoutType();
        this.banks.addAll(ProgramBank.parse(programsFile.readUTF8()));
        final IEnumSetting[] bankSettings = new IEnumSetting[this.banks.size()];
        for (int i = 0; i < this.banks.size(); i++) {
            final int bankPos = i;
            final ProgramBank pb = this.banks.get(bankPos);
            final String[] programs = pb.getPrograms();
            final String[] opts = new String[programs.length + 1];
            System.arraycopy(programs, 0, opts, 1, programs.length);
            opts[0] = PROGRAM_NONE;
            bankSettings[bankPos] = this.documentSettings.getEnumSetting(pb.getName(), nameWithoutType + " Program Banks", opts, opts[0]);
            bankSettings[bankPos].addValueObserver(value -> {
                final int program = pb.lookupProgram(value);
                if (program < 0)
                    return;
                final GenericFlexiControlSurface surface = this.getSurface();
                if (surface == null)
                    return;
                final IMidiOutput midiOutput = surface.getMidiOutput();
                if (midiOutput != null)
                    midiOutput.sendProgramChange(pb.getMidiChannel(), pb.getMSB(), pb.getLSB(), program);
                final int channel = pb.getMidiChannel();
                for (int b = 0; b < bankSettings.length; b++) {
                    if (bankPos != b && this.banks.get(b).getMidiChannel() == channel)
                        bankSettings[b].set(PROGRAM_NONE);
                }
            });
        }
    } catch (final IOException ex) {
        this.host.error("Could not load programs file.", ex);
    } catch (final ParseException ex) {
        this.host.error("Could not parse programs file.", ex);
    }
}
Also used : GenericFlexiControlSurface(de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface) FileEx(de.mossgrabers.framework.utils.FileEx) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) IOException(java.io.IOException) ParseException(java.text.ParseException) ProgramBank(de.mossgrabers.controller.generic.flexihandler.utils.ProgramBank) IEnumSetting(de.mossgrabers.framework.configuration.IEnumSetting)

Example 24 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.

the class BeatstepControllerSetup method createSurface.

/**
 * {@inheritDoc}
 */
@Override
protected void createSurface() {
    final IMidiAccess midiAccess = this.factory.createMidiAccess();
    final IMidiOutput output = midiAccess.createOutput();
    final IMidiInput input = midiAccess.createInput("Control/Pads", "82????", "92????", "A2????");
    // Sequencer 1 is on channel 1
    final INoteInput seqNoteInput = input.createNoteInput("Hardware Sequencer", "90????", "80????");
    final Integer[] table = new Integer[128];
    for (int i = 0; i < 128; i++) {
        // Block the Shift key
        table[i] = Integer.valueOf(i == 7 ? -1 : i);
    }
    seqNoteInput.setKeyTranslationTable(table);
    this.surfaces.add(new BeatstepControlSurface(this.host, this.colorManager, this.configuration, output, input));
}
Also used : IMidiAccess(de.mossgrabers.framework.daw.midi.IMidiAccess) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) BeatstepControlSurface(de.mossgrabers.controller.arturia.beatstep.controller.BeatstepControlSurface) INoteInput(de.mossgrabers.framework.daw.midi.INoteInput)

Example 25 with IMidiOutput

use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.

the class GenericFlexiControlSurface method reflectValue.

/**
 * Send back the current value type of a command slot to the device.
 *
 * @param slot The slot
 * @param value The value to reflect
 */
private void reflectValue(final CommandSlot slot, final int value) {
    if (value < 0 || value > 127) {
        this.host.error(String.format("Attempt to reflect value out of range from slot command: %s Value: %d", slot.getCommand().getName(), Integer.valueOf(value)));
        return;
    }
    final IMidiOutput output = this.getMidiOutput();
    final int midiChannel = slot.getMidiChannel();
    // Cannot reflect "All" setting
    if (midiChannel > 15)
        return;
    switch(slot.getType()) {
        case CommandSlot.TYPE_NOTE:
            output.sendNoteEx(midiChannel, slot.getNumber(), value);
            break;
        case CommandSlot.TYPE_CC:
            output.sendCCEx(midiChannel, slot.getNumber(), value);
            break;
        case CommandSlot.TYPE_PITCH_BEND:
            output.sendPitchbend(midiChannel, 0, value);
            break;
        default:
            // Other types not supported
            break;
    }
}
Also used : IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput)

Aggregations

IMidiOutput (de.mossgrabers.framework.daw.midi.IMidiOutput)28 IMidiAccess (de.mossgrabers.framework.daw.midi.IMidiAccess)16 IMidiInput (de.mossgrabers.framework.daw.midi.IMidiInput)16 ITrack (de.mossgrabers.framework.daw.data.ITrack)6 ColorManager (de.mossgrabers.framework.controller.color.ColorManager)4 DummyDisplay (de.mossgrabers.framework.controller.display.DummyDisplay)4 IChannelBank (de.mossgrabers.framework.daw.IChannelBank)4 IHost (de.mossgrabers.framework.daw.IHost)4 GenericFlexiControlSurface (de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface)3 ProgramBank (de.mossgrabers.controller.generic.flexihandler.utils.ProgramBank)2 MaschineControlSurface (de.mossgrabers.controller.ni.maschine.mk3.controller.MaschineControlSurface)2 LaunchkeyMk3ControlSurface (de.mossgrabers.controller.novation.launchkey.maxi.controller.LaunchkeyMk3ControlSurface)2 IEnumSetting (de.mossgrabers.framework.configuration.IEnumSetting)2 IMasterTrack (de.mossgrabers.framework.daw.data.IMasterTrack)2 MCUControlSurface (de.mossgrabers.mcu.controller.MCUControlSurface)2 ArrayList (java.util.ArrayList)2 APCControlSurface (de.mossgrabers.apc.controller.APCControlSurface)1 APCminiControlSurface (de.mossgrabers.apcmini.controller.APCminiControlSurface)1 BeatstepControlSurface (de.mossgrabers.beatstep.controller.BeatstepControlSurface)1 BeatstepControlSurface (de.mossgrabers.controller.arturia.beatstep.controller.BeatstepControlSurface)1