Search in sources :

Example 1 with INoteInput

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

the class MidiModule method flush.

/**
 * {@inheritDoc}
 */
@Override
public void flush(final boolean dump) {
    final String noteAddress = "/vkb_midi/note/";
    for (int i = 0; i < 127; i++) {
        final double[] color = this.getNoteColor(i).toDoubleRGB();
        this.writer.sendOSCColor(noteAddress + i + "/color", color[0], color[1], color[2], dump);
    }
    // Flush note repeat
    final INoteInput noteInput = this.surface.getMidiInput().getDefaultNoteInput();
    if (noteInput == null)
        return;
    final INoteRepeat noteRepeat = noteInput.getNoteRepeat();
    final String noteRepeatAddress = "/vkb_midi/noterepeat/";
    this.writer.sendOSC(noteRepeatAddress + "isActive", noteRepeat.isActive(), dump);
    this.writer.sendOSC(noteRepeatAddress + "period", Resolution.getNameAt(Resolution.getMatch(noteRepeat.getPeriod())), dump);
    this.writer.sendOSC(noteRepeatAddress + "length", Resolution.getNameAt(Resolution.getMatch(noteRepeat.getNoteLength())), dump);
}
Also used : INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat) INoteInput(de.mossgrabers.framework.daw.midi.INoteInput)

Example 2 with INoteInput

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

the class GenericFlexiControllerSetup method createObservers.

/**
 * {@inheritDoc}
 */
@Override
protected void createObservers() {
    super.createObservers();
    final GenericFlexiControlSurface surface = this.getSurface();
    this.configuration.addSettingObserver(GenericFlexiConfiguration.SLOT_CHANGE, surface::updateKeyTranslation);
    this.configuration.addSettingObserver(GenericFlexiConfiguration.SELECTED_MODE, this::selectMode);
    final ITrackBank trackBank = this.model.getTrackBank();
    trackBank.addSelectionObserver((index, selected) -> this.handleTrackChange(selected));
    final ITrackBank effectTrackBank = this.model.getEffectTrackBank();
    if (effectTrackBank != null)
        effectTrackBank.addSelectionObserver((index, selected) -> this.handleTrackChange(selected));
    surface.getModeManager().addChangeListener((oldMode, newMode) -> this.updateIndication());
    // Handle configuration changes
    this.createNoteRepeatObservers(this.configuration, surface);
    this.configuration.registerDeactivatedItemsHandler(this.model);
    this.configuration.addSettingObserver(GenericFlexiConfiguration.ENABLED_MPE_ZONES, () -> surface.scheduleTask(() -> {
        final INoteInput input = surface.getMidiInput().getDefaultNoteInput();
        final IMidiOutput output = surface.getMidiOutput();
        final boolean mpeEnabled = this.configuration.isMPEEndabled();
        input.enableMPE(mpeEnabled);
        // Enable MPE zone 1 with all 15 channels
        output.configureMPE(AbstractMidiOutput.ZONE_1, mpeEnabled ? 15 : 0);
        // Disable MPE zone
        output.configureMPE(AbstractMidiOutput.ZONE_2, 0);
    }, 2000));
    this.configuration.addSettingObserver(GenericFlexiConfiguration.MPE_PITCHBEND_RANGE, () -> surface.scheduleTask(() -> {
        final INoteInput input = surface.getMidiInput().getDefaultNoteInput();
        final IMidiOutput output = surface.getMidiOutput();
        final int mpePitchBendRange = this.configuration.getMPEPitchBendRange();
        input.setMPEPitchBendSensitivity(mpePitchBendRange);
        output.sendMPEPitchbendRange(AbstractMidiOutput.ZONE_1, mpePitchBendRange);
    }, 2000));
    this.activateBrowserObserver(Modes.BROWSER);
}
Also used : GenericFlexiControlSurface(de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface) ModesHandler(de.mossgrabers.controller.generic.flexihandler.ModesHandler) SignedBitRelativeValueChanger(de.mossgrabers.framework.controller.valuechanger.SignedBitRelativeValueChanger) TwosComplementValueChanger(de.mossgrabers.framework.controller.valuechanger.TwosComplementValueChanger) ITrack(de.mossgrabers.framework.daw.data.ITrack) TrackSendMode(de.mossgrabers.framework.mode.track.TrackSendMode) DeviceID(de.mossgrabers.framework.daw.constants.DeviceID) AbstractControllerSetup(de.mossgrabers.framework.controller.AbstractControllerSetup) IEnumSetting(de.mossgrabers.framework.configuration.IEnumSetting) INoteInput(de.mossgrabers.framework.daw.midi.INoteInput) BrowserMode(de.mossgrabers.framework.mode.device.BrowserMode) GenericFlexiControlSurface(de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface) Locale(java.util.Locale) MasterHandler(de.mossgrabers.controller.generic.flexihandler.MasterHandler) ProgramBank(de.mossgrabers.controller.generic.flexihandler.utils.ProgramBank) ParseException(java.text.ParseException) IValueObserver(de.mossgrabers.framework.observer.IValueObserver) FxTrackHandler(de.mossgrabers.controller.generic.flexihandler.FxTrackHandler) DeviceHandler(de.mossgrabers.controller.generic.flexihandler.DeviceHandler) Modes(de.mossgrabers.framework.mode.Modes) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager) TrackHandler(de.mossgrabers.controller.generic.flexihandler.TrackHandler) Set(java.util.Set) IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) EqHandler(de.mossgrabers.controller.generic.flexihandler.EqHandler) ClipHandler(de.mossgrabers.controller.generic.flexihandler.ClipHandler) ISettingsUI(de.mossgrabers.framework.configuration.ISettingsUI) List(java.util.List) ActionHandler(de.mossgrabers.controller.generic.flexihandler.ActionHandler) UserHandler(de.mossgrabers.controller.generic.flexihandler.UserHandler) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) Optional(java.util.Optional) FileEx(de.mossgrabers.framework.utils.FileEx) TransportHandler(de.mossgrabers.controller.generic.flexihandler.TransportHandler) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) FlexiCommand(de.mossgrabers.controller.generic.controller.FlexiCommand) MidiCCHandler(de.mossgrabers.controller.generic.flexihandler.MidiCCHandler) ISetupFactory(de.mossgrabers.framework.controller.ISetupFactory) OffsetBinaryRelativeValueChanger(de.mossgrabers.framework.controller.valuechanger.OffsetBinaryRelativeValueChanger) TrackVolumeMode(de.mossgrabers.framework.mode.track.TrackVolumeMode) ModelSetup(de.mossgrabers.framework.daw.ModelSetup) TrackPanMode(de.mossgrabers.framework.mode.track.TrackPanMode) Scales(de.mossgrabers.framework.scale.Scales) AbstractMidiOutput(de.mossgrabers.framework.daw.midi.AbstractMidiOutput) ArrayList(java.util.ArrayList) MarkerHandler(de.mossgrabers.controller.generic.flexihandler.MarkerHandler) LayoutHandler(de.mossgrabers.controller.generic.flexihandler.LayoutHandler) IMasterTrack(de.mossgrabers.framework.daw.data.IMasterTrack) IHost(de.mossgrabers.framework.daw.IHost) ParameterMode(de.mossgrabers.framework.mode.device.ParameterMode) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) IMidiAccess(de.mossgrabers.framework.daw.midi.IMidiAccess) IOException(java.io.IOException) NoteInputHandler(de.mossgrabers.controller.generic.flexihandler.NoteInputHandler) ISendBank(de.mossgrabers.framework.daw.data.bank.ISendBank) IParameterBank(de.mossgrabers.framework.daw.data.bank.IParameterBank) BrowserHandler(de.mossgrabers.controller.generic.flexihandler.BrowserHandler) SceneHandler(de.mossgrabers.controller.generic.flexihandler.SceneHandler) ColorManager(de.mossgrabers.framework.controller.color.ColorManager) TrackMode(de.mossgrabers.framework.mode.track.TrackMode) Collections(java.util.Collections) GlobalHandler(de.mossgrabers.controller.generic.flexihandler.GlobalHandler) IMidiOutput(de.mossgrabers.framework.daw.midi.IMidiOutput) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) INoteInput(de.mossgrabers.framework.daw.midi.INoteInput)

Example 3 with INoteInput

use of de.mossgrabers.framework.daw.midi.INoteInput 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 4 with INoteInput

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

the class MidiModule method parseNoteRepeat.

/**
 * Parse note repeat parameters.
 *
 * @param path The rest of the path
 * @param value The value
 * @throws MissingCommandException Could not find the sub-command
 * @throws UnknownCommandException Unknown sub-command
 * @throws IllegalParameterException Added an illegal parameter
 */
private void parseNoteRepeat(final LinkedList<String> path, final Object value) throws MissingCommandException, UnknownCommandException, IllegalParameterException {
    final INoteInput noteInput = this.surface.getMidiInput().getDefaultNoteInput();
    if (noteInput == null)
        return;
    final INoteRepeat noteRepeat = noteInput.getNoteRepeat();
    final String subCommand = getSubCommand(path);
    switch(subCommand) {
        case "isActive":
            noteRepeat.setActive(toInteger(value) > 0);
            break;
        case "period":
            if (value == null)
                throw new IllegalParameterException("Value must not be empty.");
            final Resolution period = Resolution.getByName(value.toString());
            if (period == null)
                throw new IllegalParameterException("Value must be one of {1/4, 1/4t, 1/8, 1/8t, 1/16, 1/16t, 1/32, 1/32t}.");
            noteRepeat.setPeriod(period.getValue());
            break;
        case "length":
            if (value == null)
                throw new IllegalParameterException("Value must not be empty.");
            final Resolution length = Resolution.getByName(value.toString());
            if (length == null)
                throw new IllegalParameterException("Value must be one of {1/4, 1/4t, 1/8, 1/8t, 1/16, 1/16t, 1/32, 1/32t}.");
            noteRepeat.setNoteLength(length.getValue());
            break;
        default:
            throw new UnknownCommandException(subCommand);
    }
}
Also used : INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat) UnknownCommandException(de.mossgrabers.controller.osc.exception.UnknownCommandException) IllegalParameterException(de.mossgrabers.controller.osc.exception.IllegalParameterException) INoteInput(de.mossgrabers.framework.daw.midi.INoteInput) Resolution(de.mossgrabers.framework.daw.constants.Resolution)

Example 5 with INoteInput

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

the class NoteInputHandler method getCommandValue.

/**
 * {@inheritDoc}
 */
@Override
public int getCommandValue(final FlexiCommand command) {
    final INoteInput noteInput = this.surface.getMidiInput().getDefaultNoteInput();
    if (noteInput == null)
        return -1;
    final INoteRepeat noteRepeat = noteInput.getNoteRepeat();
    final GenericFlexiConfiguration configuration = this.surface.getConfiguration();
    switch(command) {
        case NOTE_INPUT_REPEAT_ACTIVE:
            return noteRepeat.isActive() ? 127 : 0;
        case NOTE_INPUT_REPEAT_PERIOD:
            return Resolution.getMatch(noteRepeat.getPeriod());
        case NOTE_INPUT_REPEAT_LENGTH:
            return Resolution.getMatch(noteRepeat.getNoteLength());
        case NOTE_INPUT_REPEAT_MODE:
            final ArpeggiatorMode am = noteRepeat.getMode();
            final int index = configuration.getArpeggiatorModes().indexOf(am);
            return Math.max(0, index);
        case NOTE_INPUT_REPEAT_OCTAVE:
            return noteRepeat.getOctaves();
        case NOTE_INPUT_TRANSPOSE_OCTAVE_UP:
        case NOTE_INPUT_TRANSPOSE_OCTAVE_DOWN:
            return this.model.getScales().getOctave();
        default:
            return -1;
    }
}
Also used : ArpeggiatorMode(de.mossgrabers.framework.daw.midi.ArpeggiatorMode) INoteRepeat(de.mossgrabers.framework.daw.midi.INoteRepeat) GenericFlexiConfiguration(de.mossgrabers.controller.generic.GenericFlexiConfiguration) INoteInput(de.mossgrabers.framework.daw.midi.INoteInput)

Aggregations

INoteInput (de.mossgrabers.framework.daw.midi.INoteInput)6 INoteRepeat (de.mossgrabers.framework.daw.midi.INoteRepeat)3 IMidiAccess (de.mossgrabers.framework.daw.midi.IMidiAccess)2 BeatstepControlSurface (de.mossgrabers.controller.arturia.beatstep.controller.BeatstepControlSurface)1 GenericFlexiConfiguration (de.mossgrabers.controller.generic.GenericFlexiConfiguration)1 FlexiCommand (de.mossgrabers.controller.generic.controller.FlexiCommand)1 GenericFlexiControlSurface (de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface)1 ActionHandler (de.mossgrabers.controller.generic.flexihandler.ActionHandler)1 BrowserHandler (de.mossgrabers.controller.generic.flexihandler.BrowserHandler)1 ClipHandler (de.mossgrabers.controller.generic.flexihandler.ClipHandler)1 DeviceHandler (de.mossgrabers.controller.generic.flexihandler.DeviceHandler)1 EqHandler (de.mossgrabers.controller.generic.flexihandler.EqHandler)1 FxTrackHandler (de.mossgrabers.controller.generic.flexihandler.FxTrackHandler)1 GlobalHandler (de.mossgrabers.controller.generic.flexihandler.GlobalHandler)1 LayoutHandler (de.mossgrabers.controller.generic.flexihandler.LayoutHandler)1 MarkerHandler (de.mossgrabers.controller.generic.flexihandler.MarkerHandler)1 MasterHandler (de.mossgrabers.controller.generic.flexihandler.MasterHandler)1 MidiCCHandler (de.mossgrabers.controller.generic.flexihandler.MidiCCHandler)1 ModesHandler (de.mossgrabers.controller.generic.flexihandler.ModesHandler)1 NoteInputHandler (de.mossgrabers.controller.generic.flexihandler.NoteInputHandler)1