use of de.mossgrabers.framework.daw.IStepInfo in project DrivenByMoss by git-moss.
the class AbstractDrumView method drawSequencerSteps.
/**
* Draw the sequencer steps.
*
* @param clip The clip
* @param isActive Is there an active clip?
* @param noteRow The note for which to draw the row
* @param rowColor The color to use the notes of the row
* @param yModifier Flips the Y order if true
*/
protected void drawSequencerSteps(final INoteClip clip, final boolean isActive, final int noteRow, final Optional<ColorEx> rowColor, final IntUnaryOperator yModifier) {
final int step = clip.getCurrentStep();
final int hiStep = this.isInXRange(step) ? step % this.sequencerSteps : -1;
final int editMidiChannel = this.configuration.getMidiEditChannel();
final IPadGrid padGrid = this.surface.getPadGrid();
final List<GridStep> editNotes = this.getEditNotes();
for (int col = 0; col < this.sequencerSteps; col++) {
final IStepInfo stepInfo = clip.getStep(editMidiChannel, col, noteRow);
final boolean hilite = col == hiStep;
final int x = col % this.numColumns;
int y = col / this.numColumns;
if (yModifier != null)
y = yModifier.applyAsInt(y);
padGrid.lightEx(x, y, isActive ? this.getStepColor(stepInfo, hilite, rowColor, editMidiChannel, col, noteRow, editNotes) : AbstractSequencerView.COLOR_NO_CONTENT);
}
}
use of de.mossgrabers.framework.daw.IStepInfo in project DrivenByMoss by git-moss.
the class AbstractPolySequencerView method handleSequencerAreaButtonCombinations.
/**
* Handle button combinations in the sequencer area.
*
* @param clip The sequenced MIDI clip
* @param channel The MIDI channel of the note
* @param step The step in the current page in the clip
* @return True if handled
*/
protected boolean handleSequencerAreaButtonCombinations(final INoteClip clip, final int channel, final int step) {
// Handle note duplicate function
if (this.isButtonCombination(ButtonID.DUPLICATE)) {
if (this.getStep(clip, step).getState() == StepState.START)
this.copyStep = step;
else if (this.copyStep >= 0) {
for (int row = 0; row < 128; row++) {
final IStepInfo stepInfo = clip.getStep(channel, this.copyStep, row);
if (stepInfo != null && stepInfo.getVelocity() > 0)
clip.setStep(channel, step, row, stepInfo);
}
}
return true;
}
if (this.isButtonCombination(ButtonID.MUTE)) {
for (int note = 0; note < 128; note++) {
final IStepInfo stepInfo = clip.getStep(channel, step, note);
final StepState isSet = stepInfo.getState();
if (isSet == StepState.START)
this.getClip().updateMuteState(channel, step, note, !stepInfo.isMuted());
}
return true;
}
// Change length of a note or create a new one with a length
for (int s = step - 1; s >= 0; s--) {
final int x = s % this.numColumns;
final int y = this.numRows - 1 - s / this.numColumns;
final int pad = y * this.numColumns + x;
final IHwButton button = this.surface.getButton(ButtonID.get(ButtonID.PAD1, pad));
if (button.isLongPressed()) {
button.setConsumed();
final int length = step - s + 1;
final double duration = length * Resolution.getValueAt(this.getResolutionIndex());
// Create new note(s)
if (this.getStep(clip, s).getState() != StepState.START) {
for (int row = 0; row < 128; row++) {
final Integer k = Integer.valueOf(row);
if (this.noteMemory.containsKey(k)) {
final Integer vel = this.noteMemory.get(k);
clip.setStep(channel, s, row, this.configuration.isAccentActive() ? this.configuration.getFixedAccentValue() : vel.intValue(), duration);
}
}
return true;
}
// Change length of existing notes
for (int row = 0; row < 128; row++) {
final IStepInfo stepInfo = clip.getStep(channel, s, row);
if (stepInfo != null && stepInfo.getState() == StepState.START)
clip.updateStepDuration(channel, s, row, duration);
}
return true;
}
}
return false;
}
use of de.mossgrabers.framework.daw.IStepInfo in project DrivenByMoss by git-moss.
the class AbstractPolySequencerView method getStep.
/**
* Check if any note is set at the current step.
*
* @param clip The clip which contains the notes
* @param col The column/step to check
* @return The aggregated about the step aggregated from all notes at that step
*/
protected IStepInfo getStep(final INoteClip clip, final int col) {
final DefaultStepInfo result = new DefaultStepInfo();
boolean isMuted = true;
final int editMidiChannel = this.configuration.getMidiEditChannel();
for (int row = 0; row < 128; row++) {
final IStepInfo stepInfo = clip.getStep(editMidiChannel, col, row);
final StepState r = stepInfo.getState();
if (r == StepState.START)
result.setState(StepState.START);
else if (r == StepState.CONTINUE && result.getState() != StepState.START)
result.setState(StepState.CONTINUE);
if ((r == StepState.START || r == StepState.CONTINUE) && !stepInfo.isMuted())
isMuted = false;
}
result.setMuted(isMuted);
return result;
}
use of de.mossgrabers.framework.daw.IStepInfo in project DrivenByMoss by git-moss.
the class AbstractPolySequencerView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final IPadGrid padGrid = this.surface.getPadGrid();
final boolean isKeyboardEnabled = this.model.canSelectedTrackHoldNotes();
if (!isKeyboardEnabled) {
padGrid.turnOff();
return;
}
final INoteClip clip = this.getClip();
final boolean isActive = this.isActive();
final int step = clip.getCurrentStep();
// Paint the sequencer steps
final int hiStep = this.isInXRange(step) ? step % this.sequencerSteps : -1;
final List<GridStep> editNotes = this.getEditNotes();
for (int col = 0; col < this.sequencerSteps; col++) {
final IStepInfo stepInfo = this.getStep(clip, col);
final boolean hilite = col == hiStep;
final int x = col % this.numColumns;
final int y = col / this.numColumns;
padGrid.lightEx(x, y, isActive ? this.getStepColor(stepInfo, hilite, col, editNotes) : AbstractSequencerView.COLOR_NO_CONTENT);
}
// Paint the play part
final boolean isRecording = this.model.hasRecordingState();
final ITrack cursorTrack = this.model.getCursorTrack();
final int startNote = this.scales.getStartNote();
for (int i = startNote; i < startNote + this.sequencerSteps; i++) padGrid.light(i, this.getGridColor(isKeyboardEnabled, isRecording, cursorTrack, i));
}
use of de.mossgrabers.framework.daw.IStepInfo in project DrivenByMoss by git-moss.
the class AbstractDrumLaneView method handleNoteAreaButtonCombinations.
/**
* Handle button combinations on the note area of the sequencer.
*
* @param clip The sequenced MIDI clip
* @param channel The MIDI channel of the note
* @param row The row in the current page in the clip
* @param note The note in the current page of the pad in the clip
* @param step The step in the current page in the clip
* @param velocity The velocity
* @param accentVelocity The velocity or accent value
* @return True if handled
*/
protected boolean handleNoteAreaButtonCombinations(final INoteClip clip, final int channel, final int step, final int row, final int note, final int velocity, final int accentVelocity) {
// Handle note duplicate function
if (this.isButtonCombination(ButtonID.DUPLICATE)) {
if (velocity == 0) {
final IStepInfo noteStep = clip.getStep(channel, step, note);
if (noteStep.getState() == StepState.START)
this.copyNote = noteStep;
else if (this.copyNote != null)
clip.setStep(channel, step, note, this.copyNote);
}
return true;
}
if (this.isButtonCombination(ButtonID.MUTE)) {
if (velocity == 0) {
final IStepInfo stepInfo = clip.getStep(channel, step, note);
final StepState isSet = stepInfo.getState();
if (isSet == StepState.START)
this.getClip().updateMuteState(channel, step, note, !stepInfo.isMuted());
}
return true;
}
// Change length of a note or create a new one with a length
final int laneOffset = (this.allRows - row - 1) / this.lanes * this.numColumns;
final int offset = row * this.numColumns;
for (int s = 0; s < step; s++) {
final IHwButton button = this.surface.getButton(ButtonID.get(ButtonID.PAD1, offset + s));
if (button.isLongPressed()) {
final int start = s + laneOffset;
button.setConsumed();
final int length = step - start + 1;
final double duration = length * Resolution.getValueAt(this.getResolutionIndex());
final StepState state = note < 0 ? StepState.OFF : clip.getStep(channel, start, note).getState();
if (state == StepState.START)
clip.updateStepDuration(channel, start, note, duration);
else
clip.setStep(channel, start, note, accentVelocity, duration);
return true;
}
}
return false;
}
Aggregations