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);
}
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);
}
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));
}
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);
}
}
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;
}
}
Aggregations