Skip to content

Commit

Permalink
Updating for Java 11
Browse files Browse the repository at this point in the history
Also continuing updates to take advantage of the newer
Java version we build against, fix typos in documentation, and
switch to explicit API annotations to indicate project entry
points.
  • Loading branch information
brunchboy committed May 28, 2024
1 parent 5b3d55c commit ec56b4c
Show file tree
Hide file tree
Showing 8 changed files with 343 additions and 290 deletions.
29 changes: 18 additions & 11 deletions src/main/java/org/deepsymmetry/beatlink/data/WaveformDetail.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.deepsymmetry.beatlink.data;

import org.apiguardian.api.API;
import org.deepsymmetry.beatlink.Util;
import org.deepsymmetry.beatlink.dbserver.BinaryField;
import org.deepsymmetry.beatlink.dbserver.Message;
Expand All @@ -18,6 +19,7 @@
*
* @author James Elliott
*/
@API(status = API.Status.STABLE)
public class WaveformDetail {

@SuppressWarnings({"unused"})
Expand All @@ -27,29 +29,29 @@ public class WaveformDetail {
* The number of bytes at the start of the waveform data which do not seem to be valid or used when it is served
* by the dbserver protocol. They are not present when the ANLZ.EXT file is loaded directly by Crate Digger.
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public static final int LEADING_DBSERVER_JUNK_BYTES = 19;

/**
* The number of bytes at the start of the color waveform data to be skipped when that was loaded using the
* nxs2 ANLZ tag request. We actually know what these mean, now that we know how to parse EXT files, but we
* can simply skip them anyway.
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public static final int LEADING_DBSERVER_COLOR_JUNK_BYTES = 28;

/**
* The unique identifier that was used to request this waveform detail.
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public final DataReference dataReference;

/**
* The message holding the detail as it was read over the network. This can be used to analyze fields
* that have not yet been reliably understood, and is also used for storing the cue list in a file.
* This will be {@code null} if the data was obtained from Crate Digger.
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public final Message rawMessage;

/**
Expand All @@ -61,7 +63,7 @@ public class WaveformDetail {
/**
* Indicates whether this is an NXS2-style color waveform, or a monochrome (blue) waveform.
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public final boolean isColor;

/**
Expand All @@ -70,6 +72,7 @@ public class WaveformDetail {
* @return the bytes from which the detail can be drawn, as described in the
* <a href="https://djl-analysis.deepsymmetry.org/djl-analysis/track_metadata.html#_detailed_waveforms">Packet Analysis document</a>.
*/
@API(status = API.Status.STABLE)
public ByteBuffer getData() {
detailBuffer.rewind();
return detailBuffer.slice();
Expand All @@ -80,6 +83,7 @@ public ByteBuffer getData() {
*
* @return the number of half-frames (pixel columns) that make up the track
*/
@API(status = API.Status.STABLE)
public int getFrameCount() {
final int bytes = getData().remaining();
if (isColor) {
Expand All @@ -95,6 +99,7 @@ public int getFrameCount() {
*
* @return the number of milliseconds it will take to play all half-frames that make up the track
*/
@API(status = API.Status.STABLE)
public long getTotalTime() {
return Util.halfFrameToTime(getFrameCount());
}
Expand All @@ -111,6 +116,7 @@ public long getTotalTime() {
*
* @return the component which will draw the annotated waveform preview
*/
@API(status = API.Status.STABLE)
public JComponent createViewComponent(TrackMetadata metadata, BeatGrid beatGrid) {
return new WaveformDetailComponent(this, metadata, beatGrid);
}
Expand All @@ -121,9 +127,9 @@ public JComponent createViewComponent(TrackMetadata metadata, BeatGrid beatGrid)
* @param reference the unique database reference that was used to request this waveform detail
* @param message the response that contains the preview
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public WaveformDetail(DataReference reference, Message message) {
isColor = message.knownType == Message.KnownType.ANLZ_TAG; // If we got one of these, its an NXS2 color wave.
isColor = message.knownType == Message.KnownType.ANLZ_TAG; // If we got one of these, it's an NXS2 color wave.
dataReference = reference;
rawMessage = message;
// Load the bytes we were sent, and skip over the proper number of leading junk bytes
Expand All @@ -138,7 +144,7 @@ public WaveformDetail(DataReference reference, Message message) {
* @param reference the unique database reference that was used to request this waveform preview
* @param anlzFile the parsed rekordbox track analysis file containing the waveform preview
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public WaveformDetail(DataReference reference, RekordboxAnlz anlzFile) {
dataReference = reference;
rawMessage = null;
Expand Down Expand Up @@ -172,6 +178,7 @@ public WaveformDetail(DataReference reference, RekordboxAnlz anlzFile) {
* @param data the waveform data as will be returned by {@link #getData()}
* @param isColor indicates whether the data represents a color waveform
*/
@API(status = API.Status.STABLE)
public WaveformDetail(DataReference reference, ByteBuffer data, boolean isColor) {
dataReference = reference;
rawMessage = null;
Expand All @@ -184,7 +191,7 @@ public WaveformDetail(DataReference reference, ByteBuffer data, boolean isColor)
/**
* The different colors the monochrome (blue) waveform can be based on its intensity.
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public static final Color[] COLOR_MAP = {
new Color(0, 104, 144),
new Color(0, 136, 176),
Expand Down Expand Up @@ -222,7 +229,7 @@ private int getColorWaveformBits(final ByteBuffer waveBytes, final int segment)
* @return a value from 0 to 31 representing the height of the waveform at that segment, which may be an average
* of a number of values starting there, determined by the scale
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public int segmentHeight(final int segment, final int scale) {
final ByteBuffer waveBytes = getData();
final int limit = getFrameCount();
Expand All @@ -247,7 +254,7 @@ public int segmentHeight(final int segment, final int scale) {
* @return the color of the waveform at that segment, which may be based on an average
* of a number of values starting there, determined by the scale
*/
@SuppressWarnings("WeakerAccess")
@API(status = API.Status.STABLE)
public Color segmentColor(final int segment, final int scale) {
final ByteBuffer waveBytes = getData();
final int limit = getFrameCount();
Expand Down
Loading

0 comments on commit ec56b4c

Please sign in to comment.