use of de.mossgrabers.framework.daw.IChannelBank in project DrivenByMoss by git-moss.
the class SessionView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final Integer controlMode = this.surface.getModeManager().getActiveModeId();
final boolean isOff = controlMode == null;
final boolean flip = this.surface.getConfiguration().isFlipSession();
this.rows = isOff || flip ? 8 : 7;
this.columns = isOff || !flip ? 8 : 7;
super.drawGrid();
if (isOff)
return;
final IChannelBank tb = this.model.getCurrentTrackBank();
final PadGrid pads = this.surface.getPadGrid();
final ModeManager modeManager = this.surface.getModeManager();
for (int x = 0; x < this.columns; x++) {
final ITrack track = tb.getTrack(x);
final boolean exists = track.doesExist();
if (modeManager.isActiveMode(Modes.MODE_REC_ARM))
pads.lightEx(x, 7, exists ? track.isRecArm() ? LaunchpadColors.LAUNCHPAD_COLOR_RED_HI : LaunchpadColors.LAUNCHPAD_COLOR_RED_LO : LaunchpadColors.LAUNCHPAD_COLOR_BLACK);
else if (modeManager.isActiveMode(Modes.MODE_TRACK_SELECT))
pads.lightEx(x, 7, exists ? track.isSelected() ? LaunchpadColors.LAUNCHPAD_COLOR_GREEN_HI : LaunchpadColors.LAUNCHPAD_COLOR_GREEN_LO : LaunchpadColors.LAUNCHPAD_COLOR_BLACK);
else if (modeManager.isActiveMode(Modes.MODE_MUTE))
pads.lightEx(x, 7, exists ? track.isMute() ? LaunchpadColors.LAUNCHPAD_COLOR_YELLOW_HI : LaunchpadColors.LAUNCHPAD_COLOR_YELLOW_LO : LaunchpadColors.LAUNCHPAD_COLOR_BLACK);
else if (modeManager.isActiveMode(Modes.MODE_SOLO))
pads.lightEx(x, 7, exists ? track.isSolo() ? LaunchpadColors.LAUNCHPAD_COLOR_BLUE_HI : LaunchpadColors.LAUNCHPAD_COLOR_BLUE_LO : LaunchpadColors.LAUNCHPAD_COLOR_BLACK);
else if (modeManager.isActiveMode(Modes.MODE_STOP_CLIP))
pads.lightEx(x, 7, exists ? LaunchpadColors.LAUNCHPAD_COLOR_ROSE : LaunchpadColors.LAUNCHPAD_COLOR_BLACK);
}
}
use of de.mossgrabers.framework.daw.IChannelBank in project DrivenByMoss by git-moss.
the class SessionView method onGridNoteBankSelection.
protected void onGridNoteBankSelection(final int note, final int velocity, final boolean isOffset) {
if (velocity == 0)
return;
final int n = isOffset ? note : note - 8;
final int index = n - 36;
final int x = index % this.columns;
final int y = this.rows - 1 - index / this.columns;
final IChannelBank tb = this.model.getCurrentTrackBank();
// Calculate page offsets
final int trackPosition = tb.getTrack(0).getPosition() / tb.getNumTracks();
final int scenePosition = tb.getScenePosition() / tb.getNumScenes();
final boolean flip = this.surface.getConfiguration().isFlipSession();
final int selX = flip ? scenePosition : trackPosition;
final int selY = flip ? trackPosition : scenePosition;
final int padsX = flip ? this.rows : this.columns;
final int padsY = flip ? this.columns : isOffset ? this.rows + 1 : this.rows;
final int offsetX = selX / padsX * padsX;
final int offsetY = selY / padsY * padsY;
tb.scrollToChannel(offsetX * tb.getNumTracks() + (flip ? y : x) * padsX);
tb.scrollToScene(offsetY * tb.getNumScenes() + (flip ? x : y) * padsY);
}
use of de.mossgrabers.framework.daw.IChannelBank 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.IChannelBank 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;
}
}
use of de.mossgrabers.framework.daw.IChannelBank in project DrivenByMoss by git-moss.
the class OSCWriter method flush.
/**
* Flush out all values.
*
* @param dump Forces a flush if true otherwise only changed values are flushed
*/
public void flush(final boolean dump) {
if (this.udpServer == null)
return;
//
// Transport
//
final ITransport trans = this.model.getTransport();
this.sendOSC("/play", trans.isPlaying(), dump);
this.sendOSC("/record", trans.isRecording(), dump);
this.sendOSC("/overdub", trans.isArrangerOverdub(), dump);
this.sendOSC("/overdub/launcher", trans.isLauncherOverdub(), dump);
this.sendOSC("/repeat", trans.isLoop(), dump);
this.sendOSC("/punchIn", trans.isPunchInEnabled(), dump);
this.sendOSC("/punchOut", trans.isPunchOutEnabled(), dump);
this.sendOSC("/click", trans.isMetronomeOn(), dump);
this.sendOSC("/click/ticks", trans.isMetronomeTicksOn(), dump);
this.sendOSC("/click/volume", trans.getMetronomeVolume(), dump);
this.sendOSC("/click/volumeStr", trans.getMetronomeVolumeStr(), dump);
this.sendOSC("/click/preroll", trans.isPrerollMetronomeEnabled(), dump);
this.sendOSC("/preroll", trans.getPrerollAsBars(), dump);
this.sendOSC("/tempo/raw", trans.getTempo(), dump);
this.sendOSC("/crossfade", trans.getCrossfade(), dump);
this.sendOSC("/autowrite", trans.isWritingArrangerAutomation(), dump);
this.sendOSC("/autowrite/launcher", trans.isWritingClipLauncherAutomation(), dump);
this.sendOSC("/automationWriteMode", trans.getAutomationWriteMode(), dump);
this.sendOSC("/time/str", trans.getPositionText(), dump);
this.sendOSC("/time/signature", trans.getNumerator() + " / " + trans.getDenominator(), dump);
this.sendOSC("/beat/str", trans.getBeatText(), dump);
//
// Frames
//
final IApplication app = this.model.getApplication();
this.sendOSC("/layout", app.getPanelLayout().toLowerCase(), dump);
final IArranger arrange = this.model.getArranger();
this.sendOSC("/arranger/cueMarkerVisibility", arrange.areCueMarkersVisible(), dump);
this.sendOSC("/arranger/playbackFollow", arrange.isPlaybackFollowEnabled(), dump);
this.sendOSC("/arranger/trackRowHeight", arrange.hasDoubleRowTrackHeight(), dump);
this.sendOSC("/arranger/clipLauncherSectionVisibility", arrange.isClipLauncherVisible(), dump);
this.sendOSC("/arranger/timeLineVisibility", arrange.isTimelineVisible(), dump);
this.sendOSC("/arranger/ioSectionVisibility", arrange.isIoSectionVisible(), dump);
this.sendOSC("/arranger/effectTracksVisibility", arrange.areEffectTracksVisible(), dump);
final IMixer mix = this.model.getMixer();
this.sendOSC("/mixer/clipLauncherSectionVisibility", mix.isClipLauncherSectionVisible(), dump);
this.sendOSC("/mixer/crossFadeSectionVisibility", mix.isCrossFadeSectionVisible(), dump);
this.sendOSC("/mixer/deviceSectionVisibility", mix.isDeviceSectionVisible(), dump);
this.sendOSC("/mixer/sendsSectionVisibility", mix.isSendSectionVisible(), dump);
this.sendOSC("/mixer/ioSectionVisibility", mix.isIoSectionVisible(), dump);
this.sendOSC("/mixer/meterSectionVisibility", mix.isMeterSectionVisible(), dump);
//
// Project
//
this.sendOSC("/project/name", this.model.getProject().getName(), dump);
this.sendOSC("/project/engine", app.isEngineActive(), dump);
//
// Master-/Track(-commands)
//
final IChannelBank trackBank = this.model.getCurrentTrackBank();
for (int i = 0; i < trackBank.getNumTracks(); i++) this.flushTrack("/track/" + (i + 1) + "/", trackBank.getTrack(i), dump);
this.flushTrack("/master/", this.model.getMasterTrack(), dump);
final ITrack selectedTrack = trackBank.getSelectedTrack();
this.flushTrack("/track/selected/", selectedTrack == null ? EMPTY_TRACK : selectedTrack, dump);
this.sendOSC("/track/toggleBank", this.model.isEffectTrackBankActive() ? 1 : 0, dump);
//
// Scenes
//
final ISceneBank sceneBank = this.model.getSceneBank();
for (int i = 0; i < sceneBank.getNumScenes(); i++) this.flushScene("/scene/" + (i + 1) + "/", sceneBank.getScene(i), dump);
//
// Device / Primary Device
//
final ICursorDevice cd = this.model.getCursorDevice();
this.flushDevice("/device/", cd, dump);
if (cd.hasDrumPads()) {
for (int i = 0; i < cd.getNumDrumPads(); i++) this.flushDeviceLayers("/device/drumpad/" + (i + 1) + "/", cd.getLayerOrDrumPad(i), dump);
}
for (int i = 0; i < cd.getNumLayers(); i++) this.flushDeviceLayers("/device/layer/" + (i + 1) + "/", cd.getLayerOrDrumPad(i), dump);
this.flushDevice("/primary/", this.model.getPrimaryDevice(), dump);
//
// Browser
//
this.flushBrowser("/browser/", this.model.getBrowser(), dump);
//
// Notes
//
this.flushNotes("/vkb_midi/note/", dump);
try {
int pos = 0;
this.udpServer.startBundle();
for (final OscMessageData message : this.messages) {
final String address = message.getAddress();
final Object[] values = message.getValues();
this.udpServer.sendMessage(address, values);
pos++;
if (pos > 1000) {
pos = 0;
this.udpServer.endBundle();
this.udpServer.startBundle();
}
}
this.udpServer.endBundle();
} catch (final IOException ex) {
this.model.getHost().error("Could not send UDP message.", ex);
}
this.messages.clear();
}
Aggregations