use of de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface 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.controller.generic.controller.GenericFlexiControlSurface in project DrivenByMoss by git-moss.
the class GenericFlexiControllerSetup method selectMode.
private void selectMode() {
final String selectedModeName = this.configuration.getSelectedModeName();
if (selectedModeName == null)
return;
final GenericFlexiControlSurface surface = this.getSurface();
final Modes modeID = surface.getModeManager().get(selectedModeName);
if (modeID != null)
surface.activateMode(modeID);
}
use of de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface in project DrivenByMoss by git-moss.
the class GenericFlexiControllerSetup method startup.
/**
* {@inheritDoc}
*/
@Override
public void startup() {
this.configuration.clearNoteMap();
final GenericFlexiControlSurface surface = this.getSurface();
surface.getModeManager().setActive(Modes.TRACK);
// Load last configuration
this.host.scheduleTask(() -> this.host.println(surface.loadFile(this.configuration.getFilename())), 2000);
}
use of de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface 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);
}
use of de.mossgrabers.controller.generic.controller.GenericFlexiControlSurface in project DrivenByMoss by git-moss.
the class GenericFlexiControllerSetup method createModes.
/**
* {@inheritDoc}
*/
@Override
protected void createModes() {
final GenericFlexiControlSurface surface = this.getSurface();
final ModeManager modeManager = surface.getModeManager();
modeManager.register(Modes.TRACK, new TrackMode<>(surface, this.model, true));
modeManager.register(Modes.VOLUME, new TrackVolumeMode<>(surface, this.model, true));
modeManager.register(Modes.PAN, new TrackPanMode<>(surface, this.model, true));
for (int i = 0; i < 8; i++) modeManager.register(Modes.get(Modes.SEND1, i), new TrackSendMode<>(i, surface, this.model, true));
modeManager.register(Modes.DEVICE_PARAMS, new ParameterMode<>(surface, this.model, true));
modeManager.register(Modes.BROWSER, new BrowserMode<>(surface, this.model));
modeManager.setDefaultID(Modes.VOLUME);
}
Aggregations