use of de.mossgrabers.framework.daw.constants.Resolution in project DrivenByMoss by git-moss.
the class TouchstripCommand method updateValue.
/**
* Update the LED value of the ribbon strip.
*/
public void updateValue() {
final RibbonMode ribbonMode = this.surface.getConfiguration().getRibbonMode();
switch(ribbonMode) {
case PITCH_DOWN:
case PITCH_UP:
case PITCH_DOWN_UP:
case CC_1:
case CC_11:
this.surface.setRibbonValue(this.ribbonValue);
break;
case MASTER_VOLUME:
final ITrack t = this.model.getMasterTrack();
this.surface.setRibbonValue(t == null ? 0 : this.model.getValueChanger().toMidiValue(t.getVolume()));
break;
case NOTE_REPEAT_PERIOD:
case NOTE_REPEAT_LENGTH:
final Resolution[] values = Resolution.values();
final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
final double value = ribbonMode == RibbonMode.NOTE_REPEAT_PERIOD ? noteRepeat.getPeriod() : noteRepeat.getNoteLength();
final int index = Resolution.getMatch(value);
this.surface.setRibbonValue((int) Math.round(index * 127.0 / (values.length - 1)));
break;
default:
// Not used
break;
}
}
use of de.mossgrabers.framework.daw.constants.Resolution in project DrivenByMoss by git-moss.
the class TouchstripCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final int value) {
this.ribbonValue = value;
final MaschineConfiguration config = this.surface.getConfiguration();
final RibbonMode ribbonMode = config.getRibbonMode();
switch(ribbonMode) {
case PITCH_DOWN:
this.surface.sendMidiEvent(0xE0, 0, (127 - value) / 2);
break;
case PITCH_UP:
this.surface.sendMidiEvent(0xE0, 0, 64 + value / 2);
break;
case PITCH_DOWN_UP:
this.surface.sendMidiEvent(0xE0, 0, value);
break;
case CC_1:
this.surface.sendMidiEvent(0xB0, 1, value);
break;
case CC_11:
this.surface.sendMidiEvent(0xB0, 11, value);
break;
case MASTER_VOLUME:
this.model.getMasterTrack().setVolume(this.model.getValueChanger().toDAWValue(value));
break;
case NOTE_REPEAT_PERIOD:
case NOTE_REPEAT_LENGTH:
final Resolution[] values = Resolution.values();
final double scaled = (127 - value) / 127.0;
final int index = (int) Math.round(scaled * (values.length - 1));
final double resolutionValue = values[values.length - 1 - index].getValue();
final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
if (ribbonMode == RibbonMode.NOTE_REPEAT_PERIOD)
noteRepeat.setPeriod(resolutionValue);
else
noteRepeat.setNoteLength(resolutionValue);
break;
default:
// Not used
break;
}
}
use of de.mossgrabers.framework.daw.constants.Resolution in project DrivenByMoss by git-moss.
the class TouchstripCommand method onPitchbend.
/**
* {@inheritDoc}
*/
@Override
public void onPitchbend(final int data1, final int data2) {
if (this.surface.getViewManager().isActive(Views.SESSION)) {
final int value = this.surface.isShiftPressed() ? 63 : data2;
this.model.getTransport().setCrossfade(this.model.getValueChanger().toDAWValue(value));
this.surface.setRibbonValue(value);
return;
}
// Don't get in the way of configuration
if (this.surface.isShiftPressed())
return;
final PushConfiguration config = this.surface.getConfiguration();
final double scaled = data2 / 127.0;
// Check if Note Repeat is active and its settings should be changed
final int ribbonNoteRepeat = config.getRibbonNoteRepeat();
if (config.isNoteRepeatActive() && ribbonNoteRepeat > PushConfiguration.NOTE_REPEAT_OFF) {
final Resolution[] values = Resolution.values();
final int index = (int) Math.round(scaled * (values.length - 1));
final double value = values[values.length - 1 - index].getValue();
final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
if (ribbonNoteRepeat == PushConfiguration.NOTE_REPEAT_PERIOD)
noteRepeat.setPeriod(value);
else
noteRepeat.setNoteLength(value);
return;
}
switch(config.getRibbonMode()) {
case PushConfiguration.RIBBON_MODE_PITCH:
this.surface.sendMidiEvent(0xE0, data1, data2);
break;
case PushConfiguration.RIBBON_MODE_CC:
this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), data2);
this.pitchValue = data2;
break;
case PushConfiguration.RIBBON_MODE_CC_PB:
if (data2 > 64)
this.surface.sendMidiEvent(0xE0, data1, data2);
else if (data2 < 64)
this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), 127 - data2 * 2);
else {
this.surface.sendMidiEvent(0xE0, data1, data2);
this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), 0);
}
break;
case PushConfiguration.RIBBON_MODE_PB_CC:
if (data2 > 64)
this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), (data2 - 64) * 2);
else if (data2 < 64)
this.surface.sendMidiEvent(0xE0, data1, data2);
else {
this.surface.sendMidiEvent(0xE0, data1, data2);
this.surface.sendMidiEvent(0xB0, config.getRibbonModeCCVal(), 0);
}
break;
case PushConfiguration.RIBBON_MODE_FADER:
this.model.getCursorTrack().setVolume(this.model.getValueChanger().toDAWValue(data2));
return;
default:
// Not used
break;
}
this.surface.getMidiOutput().sendPitchbend(data1, data2);
}
use of de.mossgrabers.framework.daw.constants.Resolution in project DrivenByMoss by git-moss.
the class TouchstripCommand method updateValue.
/**
* {@inheritDoc}
*/
@Override
public void updateValue() {
if (this.surface.getViewManager().isActive(Views.SESSION)) {
this.surface.setRibbonValue(this.model.getValueChanger().toMidiValue(this.model.getTransport().getCrossfade()));
return;
}
final PushConfiguration config = this.surface.getConfiguration();
// Check if Note Repeat is active and its settings should be changed
final int ribbonNoteRepeat = config.getRibbonNoteRepeat();
if (config.isNoteRepeatActive() && ribbonNoteRepeat > PushConfiguration.NOTE_REPEAT_OFF) {
final Resolution[] values = Resolution.values();
final INoteRepeat noteRepeat = this.surface.getMidiInput().getDefaultNoteInput().getNoteRepeat();
final double value = ribbonNoteRepeat == PushConfiguration.NOTE_REPEAT_PERIOD ? noteRepeat.getPeriod() : noteRepeat.getNoteLength();
final int index = Resolution.getMatch(value);
this.surface.setRibbonValue(127 - (int) Math.round(index * 127.0 / (values.length - 1)));
return;
}
switch(config.getRibbonMode()) {
case PushConfiguration.RIBBON_MODE_CC:
this.surface.setRibbonValue(this.pitchValue);
break;
case PushConfiguration.RIBBON_MODE_FADER:
final ITrack t = this.model.getCursorTrack();
this.surface.setRibbonValue(this.model.getValueChanger().toMidiValue(t.getVolume()));
break;
default:
this.surface.setRibbonValue(64);
break;
}
}
use of de.mossgrabers.framework.daw.constants.Resolution 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);
}
}
Aggregations