use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.
the class MCUControllerSetup method updateVUandFaders.
private void updateVUandFaders() {
final double upperBound = this.valueChanger.getUpperBound();
final boolean enableVUMeters = this.configuration.isEnableVUMeters();
final boolean hasMotorFaders = this.configuration.hasMotorFaders();
final IChannelBank tb = this.model.getCurrentTrackBank();
IMidiOutput output;
for (int index = 0; index < this.numMCUDevices; index++) {
final MCUControlSurface surface = this.getSurface(index);
output = surface.getOutput();
final int extenderOffset = surface.getExtenderOffset();
for (int i = 0; i < 8; i++) {
final int channel = extenderOffset + i;
final ITrack track = tb.getTrack(channel);
// Update VU LEDs of channel
if (enableVUMeters) {
final int vu = track.getVu();
if (vu != this.vuValues[channel]) {
this.vuValues[channel] = vu;
final int scaledValue = (int) Math.round(vu * 12 / upperBound);
output.sendChannelAftertouch(0x10 * i + scaledValue, 0);
}
}
// Update motor fader of channel
if (hasMotorFaders)
this.updateFaders(output, i, channel, track);
}
}
final IMasterTrack masterTrack = this.model.getMasterTrack();
final MCUControlSurface surface = this.getSurface();
output = surface.getOutput();
// Stereo VU of master channel
if (enableVUMeters) {
int vu = masterTrack.getVuLeft();
if (vu != this.masterVuValues[0]) {
this.masterVuValues[0] = vu;
final int scaledValue = (int) Math.round(vu * 12 / upperBound);
output.sendChannelAftertouch(1, scaledValue, 0);
}
vu = masterTrack.getVuRight();
if (vu != this.masterVuValues[1]) {
this.masterVuValues[1] = vu;
final int scaledValue = (int) Math.round(vu * 12 / upperBound);
output.sendChannelAftertouch(1, 0x10 + scaledValue, 0);
}
}
// Update motor fader of master channel
if (hasMotorFaders) {
final int volume = surface.isShiftPressed() ? this.model.getTransport().getMetronomeVolume() : masterTrack.getVolume();
if (volume != this.masterFaderValue) {
this.masterFaderValue = volume;
output.sendPitchbend(8, volume % 127, volume / 127);
}
}
}
use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.
the class SLControllerSetup method createSurface.
/**
* {@inheritDoc}
*/
@Override
protected void createSurface() {
final IMidiAccess midiAccess = this.factory.createMidiAccess();
final IMidiOutput output = midiAccess.createOutput();
final IMidiInput input = midiAccess.createInput(this.isMkII ? "Novation SL MkII (Drumpads)" : "Novation SL MkI (Drumpads)", "90????", "80????");
midiAccess.createInput(1, this.isMkII ? "Novation SL MkII (Keyboard)" : "Novation SL MkI (Keyboard)", "80????", "90????", "B0????", "D0????", "E0????");
final IHost hostProxy = this.model.getHost();
final SLControlSurface surface = new SLControlSurface(hostProxy, this.colorManager, this.configuration, output, input, this.isMkII);
surface.setDisplay(new SLDisplay(hostProxy, output));
this.surfaces.add(surface);
}
use of de.mossgrabers.framework.daw.midi.IMidiOutput in project DrivenByMoss by git-moss.
the class DeviceParamsMode method setLEDs.
/**
* Set the button LEDs.
*/
public void setLEDs() {
final boolean hasDevice = this.model.hasSelectedDevice();
final IMidiOutput output = this.surface.getOutput();
for (int i = 0; i < 8; i++) {
final int value = hasDevice ? this.model.getCursorDevice().getFXParam(i).getValue() : 0;
output.sendCC(0x70 + i, Math.min(value * 11 / 127, 11));
}
}
use of de.mossgrabers.framework.daw.midi.IMidiOutput 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.IMidiOutput in project DrivenByMoss by git-moss.
the class MCUControlSurface method switchVuMode.
// LEDs on/LEDs and VU-meter on display on/VU-meter on display on/all off
public void switchVuMode(final int mode) {
// Always horizontal
this.output.sendSysex(new StringBuilder(SYSEX_HDR).append("21 00 F7").toString());
if (this.activeVuMode != mode) {
if (this.activeVuMode < 5)
this.activeVuMode = mode;
else
this.activeVuMode = VUMODE_LED;
}
final IMidiOutput out = this.getMidiOutput();
// message
switch(this.activeVuMode) {
case VUMODE_LED:
for (int i = 0; i < 8; i++) {
// resets the leds (and vu-meters on the display?)
out.sendChannelAftertouch(0 + (i << 4), 0);
out.sendSysex(SYSEX_HDR + "20 0" + i + " 01 F7");
}
break;
case VUMODE_LED_AND_LCD:
for (int i = 0; i < 8; i++) {
out.sendChannelAftertouch(0 + (i << 4), 0);
out.sendSysex(SYSEX_HDR + "20 0" + i + " 03 F7");
}
break;
case VUMODE_LCD:
for (int i = 0; i < 8; i++) {
out.sendChannelAftertouch(0 + (i << 4), 0);
out.sendSysex(SYSEX_HDR + "20 0" + i + " 06 F7");
}
break;
case VUMODE_OFF:
for (int i = 0; i < 8; i++) {
out.sendChannelAftertouch(0 + (i << 4), 0);
out.sendSysex(SYSEX_HDR + "20 0" + i + " 00 F7");
}
break;
default:
// Not used
break;
}
}
Aggregations