use of de.mossgrabers.framework.daw.ITrackBank in project DrivenByMoss by git-moss.
the class TrackView method onGridNote.
/**
* {@inheritDoc}
*/
@Override
public void onGridNote(final int note, final int velocity) {
if (velocity == 0)
return;
final IChannelBank tb = this.model.getCurrentTrackBank();
int track;
ITrack selectedTrack;
ITrack sel;
int index;
int newSel;
switch(note - 36) {
// Toggle Activate
case 0:
selectedTrack = tb.getSelectedTrack();
if (selectedTrack != null)
selectedTrack.toggleIsActivated();
break;
// Track left
case 1:
sel = tb.getSelectedTrack();
index = sel == null ? 0 : sel.getIndex() - 1;
if (index == -1 || this.surface.isShiftPressed()) {
if (!tb.canScrollTracksUp())
return;
tb.scrollTracksPageUp();
newSel = index == -1 || sel == null ? 7 : sel.getIndex();
this.surface.scheduleTask(() -> this.selectTrack(newSel), 75);
return;
}
this.selectTrack(index);
break;
// Track right
case 2:
sel = tb.getSelectedTrack();
index = sel == null ? 0 : sel.getIndex() + 1;
if (index == 8 || this.surface.isShiftPressed()) {
if (!tb.canScrollTracksDown())
return;
tb.scrollTracksPageDown();
newSel = index == 8 || sel == null ? 0 : sel.getIndex();
this.surface.scheduleTask(() -> this.selectTrack(newSel), 75);
return;
}
this.selectTrack(index);
break;
// Move down
case 3:
if (tb instanceof ITrackBank)
((ITrackBank) tb).selectChildren();
break;
// Move up
case 4:
if (tb instanceof ITrackBank)
((ITrackBank) tb).selectParent();
break;
// Unused
case 5:
break;
// Track Page down
case 6:
this.scrollTracksLeft();
break;
// Track Page up
case 7:
this.scrollTracksRight();
break;
default:
track = note - 36 - 8;
this.selectTrack(track);
break;
}
}
use of de.mossgrabers.framework.daw.ITrackBank in project DrivenByMoss by git-moss.
the class SessionView method onSession.
/**
* The session button was pressed.
*
* @param event The button event
*/
public void onSession(final ButtonEvent event) {
switch(event) {
case LONG:
this.isTemporary = true;
break;
case UP:
if (!this.isTemporary)
return;
this.isTemporary = false;
final ViewManager viewManager = this.surface.getViewManager();
final ITrackBank tb = this.model.getTrackBank();
final ITrack selectedTrack = tb.getSelectedTrack();
if (selectedTrack == null)
return;
final Integer viewId = viewManager.getPreferredView(selectedTrack.getPosition());
viewManager.setActiveView(viewId == null ? Views.VIEW_PLAY : viewId);
break;
default:
// Intentionally empty
return;
}
}
use of de.mossgrabers.framework.daw.ITrackBank in project DrivenByMoss by git-moss.
the class MCUControllerSetup method createModel.
/**
* {@inheritDoc}
*/
@Override
protected void createModel() {
this.model = this.factory.createModel(this.colorManager, this.valueChanger, this.scales, 8 * this.numMCUDevices, 8, 8, 8, 8, true, 8 * this.numMCUDevices, -1, -1, -1);
final ITrackBank trackBank = this.model.getTrackBank();
trackBank.setIndication(true);
trackBank.addTrackSelectionObserver(this::handleTrackChange);
this.model.getMasterTrack().addTrackSelectionObserver((index, isSelected) -> {
final ModeManager modeManager = this.getSurface().getModeManager();
if (isSelected)
modeManager.setActiveMode(Modes.MODE_MASTER);
else
modeManager.restoreMode();
});
}
use of de.mossgrabers.framework.daw.ITrackBank in project DrivenByMoss by git-moss.
the class OSCParser method parseTrackCommands.
private void parseTrackCommands(final LinkedList<String> oscParts, final Object value, final int numValue) {
if (oscParts.isEmpty()) {
this.host.errorln("Missing Track command.");
return;
}
final IChannelBank tb = this.model.getCurrentTrackBank();
final String command = oscParts.removeFirst();
switch(command) {
case PART_INDICATE:
{
if (oscParts.isEmpty()) {
this.host.errorln("Missing Indicate subcommand.");
return;
}
final boolean isTrue = numValue > 0;
final String subCommand = oscParts.removeFirst();
switch(subCommand) {
case PART_VOLUME:
for (int i = 0; i < tb.getNumTracks(); i++) tb.getTrack(i).setVolumeIndication(isTrue);
break;
case "pan":
for (int i = 0; i < tb.getNumTracks(); i++) tb.getTrack(i).setPanIndication(isTrue);
break;
case "send":
if (tb instanceof ITrackBank) {
final int sendIndex = Integer.parseInt(oscParts.get(0));
for (int i = 0; i < tb.getNumTracks(); i++) tb.getTrack(i).getSend(sendIndex - 1).setIndication(isTrue);
}
break;
default:
this.host.errorln("Unknown Indicate subcommand: " + subCommand);
break;
}
break;
}
case "bank":
if (oscParts.isEmpty()) {
this.host.errorln("Missing Track Bank subcommand.");
return;
}
final String subCommand = oscParts.removeFirst();
switch(subCommand) {
case "page":
if (oscParts.isEmpty()) {
this.host.errorln("Missing Track Bank Page subcommand.");
return;
}
if ("+".equals(oscParts.removeFirst())) {
if (!tb.canScrollTracksDown())
return;
tb.scrollTracksPageDown();
this.host.scheduleTask(() -> tb.getTrack(0).selectAndMakeVisible(), 75);
} else // "-"
{
if (!tb.canScrollTracksUp())
return;
tb.scrollTracksPageUp();
this.host.scheduleTask(() -> tb.getTrack(7).selectAndMakeVisible(), 75);
}
break;
case "+":
tb.scrollTracksDown();
break;
case "-":
tb.scrollTracksUp();
break;
default:
this.host.errorln("Unknown Track Bank subcommand: " + subCommand);
break;
}
break;
case "+":
{
final ITrack sel = tb.getSelectedTrack();
final int index = sel == null ? 0 : sel.getIndex() + 1;
if (index == tb.getNumTracks()) {
if (!tb.canScrollTracksDown())
return;
tb.scrollTracksPageDown();
this.host.scheduleTask(() -> tb.getTrack(0).selectAndMakeVisible(), 75);
return;
}
tb.getTrack(index).selectAndMakeVisible();
break;
}
case "-":
{
final ITrack sel = tb.getSelectedTrack();
final int index = sel == null ? 0 : sel.getIndex() - 1;
if (index == -1) {
if (!tb.canScrollTracksUp())
return;
tb.scrollTracksPageUp();
this.host.scheduleTask(() -> tb.getTrack(7).selectAndMakeVisible(), 75);
return;
}
tb.getTrack(index).selectAndMakeVisible();
break;
}
case "add":
if (oscParts.isEmpty()) {
this.host.errorln("Missing Add subcommand.");
return;
}
final String subCommand2 = oscParts.removeFirst();
final IApplication application = this.model.getApplication();
switch(subCommand2) {
case "audio":
application.addAudioTrack();
break;
case "effect":
application.addEffectTrack();
break;
case "instrument":
application.addInstrumentTrack();
break;
default:
this.host.errorln("Unknown Add subcommand: " + subCommand2);
break;
}
break;
case "stop":
this.model.getCurrentTrackBank().stop();
break;
case "vu":
this.configuration.setVUMetersEnabled(numValue > 0);
break;
case "toggleBank":
{
this.model.toggleCurrentTrackBank();
final IChannelBank tbNew = this.model.getCurrentTrackBank();
// Make sure a track is selected
final IChannelBank tbOther = this.model.isEffectTrackBankActive() ? this.model.getTrackBank() : this.model.getEffectTrackBank();
final ITrack selectedTrack = tbNew.getSelectedTrack();
if (selectedTrack == null)
tbNew.getTrack(0).selectAndMakeVisible();
// Move the indication to the other bank
for (int i = 0; i < tbNew.getNumTracks(); i++) {
final ITrack otherTrack = tbOther.getTrack(i);
otherTrack.setVolumeIndication(false);
otherTrack.setPanIndication(false);
final ITrack track = tbNew.getTrack(i);
track.setVolumeIndication(true);
track.setPanIndication(true);
}
break;
}
case "parent":
{
if (tb instanceof ITrackBank)
((ITrackBank) tb).selectParent();
break;
}
case "selected":
final ITrack selectedTrack = tb.getSelectedTrack();
if (selectedTrack != null)
this.parseTrackValue(selectedTrack, oscParts, value);
break;
default:
this.host.println("Unknown Track Command: " + command);
break;
}
}
use of de.mossgrabers.framework.daw.ITrackBank in project DrivenByMoss by git-moss.
the class OSCParser method parseTrackValue.
private void parseTrackValue(final ITrack track, final LinkedList<String> parts, final Object value) {
final double numValue = value instanceof Number ? ((Number) value).doubleValue() : -1;
final int intValue = value instanceof Number ? ((Number) value).intValue() : -1;
if (parts.isEmpty()) {
this.host.errorln("Missing Track command.");
return;
}
final String command = parts.removeFirst();
switch(command) {
case "activated":
track.setIsActivated(intValue > 0);
break;
case "crossfadeMode":
if (numValue == 1)
track.setCrossfadeMode(parts.removeFirst());
break;
case "selected":
if (intValue > 0)
track.selectAndMakeVisible();
break;
case PART_VOLUME:
if (parts.isEmpty())
track.setVolume(numValue);
else if (PART_INDICATE.equals(parts.get(0)))
track.setVolumeIndication(numValue > 0);
else if (PART_RESET.equals(parts.get(0)))
track.resetVolume();
else if (PART_TOUCH.equals(parts.get(0)))
track.touchVolume(numValue > 0);
break;
case "pan":
if (parts.isEmpty())
track.setPan(numValue);
else if (PART_INDICATE.equals(parts.get(0)))
track.setPanIndication(numValue > 0);
else if (PART_RESET.equals(parts.get(0)))
track.resetPan();
else if (PART_TOUCH.equals(parts.get(0)))
track.touchPan(numValue > 0);
break;
case "mute":
if (numValue < 0)
track.toggleMute();
else
track.setMute(numValue > 0);
break;
case "solo":
if (numValue < 0)
track.toggleSolo();
else
track.setSolo(numValue > 0);
break;
case "recarm":
if (numValue < 0)
track.toggleRecArm();
else
track.setRecArm(numValue > 0);
break;
case "monitor":
if (numValue < 0)
track.toggleMonitor();
else
track.setMonitor(numValue > 0);
break;
case "autoMonitor":
if (numValue < 0)
track.toggleAutoMonitor();
else
track.setAutoMonitor(numValue > 0);
break;
case "send":
final int sendNo = Integer.parseInt(parts.removeFirst());
this.parseSendValue(track, sendNo - 1, parts, value);
break;
case "clip":
if (parts.isEmpty()) {
this.host.errorln("Missing Clip subcommand.");
return;
}
final String cmd = parts.removeFirst();
try {
final int clipNo = Integer.parseInt(cmd);
if (parts.isEmpty()) {
this.host.errorln("Missing Clip subcommand.");
return;
}
final String clipCommand = parts.removeFirst();
final ISlot slot = track.getSlot(clipNo - 1);
switch(clipCommand) {
case "select":
slot.select();
break;
case "launch":
slot.launch();
break;
case "record":
slot.record();
break;
case "color":
final Matcher matcher = RGB_COLOR_PATTERN.matcher(value.toString());
if (!matcher.matches())
return;
final int count = matcher.groupCount();
if (count != 7)
return;
slot.setColor(Double.parseDouble(matcher.group(2)) / 255.0, Double.parseDouble(matcher.group(4)) / 255.0, Double.parseDouble(matcher.group(6)) / 255.0);
break;
default:
this.host.println("Unknown Clip subcommand: " + clipCommand);
break;
}
} catch (final NumberFormatException ex) {
switch(cmd) {
case "stop":
track.stop();
break;
case "returntoarrangement":
track.returnToArrangement();
break;
default:
this.host.println("Unknown Clip command: " + cmd);
break;
}
}
break;
case "enter":
final IChannelBank tb = this.model.getCurrentTrackBank();
if (tb instanceof ITrackBank) {
track.select();
((ITrackBank) tb).selectChildren();
}
break;
case "color":
final Matcher matcher = RGB_COLOR_PATTERN.matcher(value.toString());
if (!matcher.matches())
return;
final int count = matcher.groupCount();
if (count == 7)
track.setColor(Double.parseDouble(matcher.group(2)) / 255.0, Double.parseDouble(matcher.group(4)) / 255.0, Double.parseDouble(matcher.group(6)) / 255.0);
break;
default:
this.host.println("Unknown Track Parameter: " + command);
break;
}
}
Aggregations