Skip to content

Commit

Permalink
* New: Updated to JDK 21.
Browse files Browse the repository at this point in the history
* Fire
  * New: Added setting 'Color all track states (mute, solo, rec arm)' which allows to switch off the colors for the deactivated states in Mix mode.
  * New: Press Alt+Select knob to toggle the on/off state of the current device.
* Generic Flexi
  * New: Added setting for the length of a new clip.
* OXI One
  * Fixed: Extension did crash in 24.3 (regression).
  • Loading branch information
git-moss committed Sep 4, 2024
1 parent 94f6000 commit 3591f16
Show file tree
Hide file tree
Showing 18 changed files with 375 additions and 229 deletions.
Binary file modified DrivenByMoss-Manual.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
public class ChannelImpl extends AbstractDeviceChainImpl<Channel> implements IChannel
{
private static final int MAX_RESOLUTION = 16384;
private static final int CLIP_BORDER = 16241;

protected final IValueChanger valueChanger;

Expand Down Expand Up @@ -420,7 +421,15 @@ public void setColor (final ColorEx color)
@Override
public int getVu ()
{
return (this.vuLeft + this.vuRight) * this.valueChanger.getUpperBound () / MAX_RESOLUTION / 2;
return (int) Math.round ((this.vuLeft + this.vuRight) * this.valueChanger.getUpperBound () / (double) MAX_RESOLUTION / 2.0);
}


/** {@inheritDoc} */
@Override
public boolean getVuClipState ()
{
return this.getVuLeftClipState () || this.getVuRightClipState ();
}


Expand All @@ -432,6 +441,14 @@ public int getVuLeft ()
}


/** {@inheritDoc} */
@Override
public boolean getVuLeftClipState ()
{
return this.vuLeft >= CLIP_BORDER;
}


/** {@inheritDoc} */
@Override
public int getVuRight ()
Expand All @@ -440,6 +457,14 @@ public int getVuRight ()
}


/** {@inheritDoc} */
@Override
public boolean getVuRightClipState ()
{
return this.vuRight >= CLIP_BORDER;
}


/** {@inheritDoc} */
@Override
public int getVuPeakLeft ()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Written by Jürgen Moßgraber - mossgrabers.de
// (c) 2017-2024
// Licensed under LGPLv3 - http://www.gnu.org/licenses/lgpl-3.0.txt

package de.mossgrabers.controller.ableton.push.controller;

/**
* The color palette of the Push 2/3.
*
* @author Jürgen Moßgraber
*/
public class ColorPalette
{
private final PushControlSurface surface;
private final ColorPaletteEntry [] entries = new ColorPaletteEntry [128];
private Object updateLock = new Object ();
private boolean entriesHasUpdate = false;


/**
* Constructor.
*
* @param surface The surface
*/
public ColorPalette (final PushControlSurface surface)
{
this.surface = surface;

for (int i = 0; i < this.entries.length; i++)
this.entries[i] = new ColorPaletteEntry (i, PushColorManager.getPaletteColorRGB (i));
}


/**
* Checks all entries in the current pad color palette of the Push 2/3. Sends updates if
* necessary.
*/
public void updatePalette ()
{
synchronized (this.updateLock)
{
final int entryIndex = this.findNextEntry ();
// All done?
if (entryIndex < 0)
{
// Re-apply the color palette, if necessary
if (this.entriesHasUpdate)
this.surface.scheduleTask ( () -> this.surface.sendSysEx ("05"), 1000);
return;
}

switch (this.entries[entryIndex].getState ())
{
case READ:
this.sendColorEntryRequest (entryIndex);
break;

case READ_REQUESTED:
// 2nd attempt after 1 second...
if (System.currentTimeMillis () - this.entries[entryIndex].getSendTimestamp () > 1000L)
this.sendColorEntryRequest (entryIndex);
break;

case WRITE:
if (this.entries[entryIndex].incWriteRetries ())
this.surface.sendSysEx (this.entries[entryIndex].createUpdateMessage ());
else
this.surface.errorln ("Failed writing color palette entry #" + entryIndex + ".");
break;

default:
return;
}
}

this.surface.scheduleTask (this::updatePalette, 10);
}


/**
* Handle a color palette system exclusive message.
*
* @param data The message data
*/
public void handleColorPaletteMessage (final int [] data)
{
if (!ColorPaletteEntry.isValid (data))
return;

synchronized (this.updateLock)
{
final int index = data[7];

// Is an update of the color palette entry necessary?
if (!this.entries[index].requiresUpdate (data))
{
this.entries[index].setDone ();
return;
}

this.entriesHasUpdate = true;
this.entries[index].setWrite ();
}
}


/**
* Get the next palette entry which needs to be updated.
*
* @return The index of the entry or -1 if no further updates are required
*/
private int findNextEntry ()
{
for (int i = 0; i < this.entries.length; i++)
{
if (this.entries[i].getState () != ColorPaletteEntry.State.DONE)
return i;
}

return -1;
}


/**
* Send a request to the Push 2/3 to send the values of an entry of the current color palette.
*
* @param entryIndex The index of the entry 0-127
*/
private void sendColorEntryRequest (final int entryIndex)
{
if (!this.entries[entryIndex].incReadRetries ())
{
this.surface.errorln ("Failed reading color palette entry #" + entryIndex + ".");
return;
}

this.surface.sendSysEx (new int []
{
0x04,
entryIndex
});
}
}
Loading

0 comments on commit 3591f16

Please sign in to comment.