Skip to content

Commit 17ccead

Browse files
committed
feat: update java to 24 and fix windows issues
1 parent 339791a commit 17ccead

7 files changed

Lines changed: 23 additions & 30 deletions

File tree

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1414

15-
<maven.compiler.source>21</maven.compiler.source>
16-
<maven.compiler.target>21</maven.compiler.target>
15+
<maven.compiler.source>24</maven.compiler.source>
16+
<maven.compiler.target>24</maven.compiler.target>
1717

18-
<javafx-controls.version>21.0.4</javafx-controls.version>
18+
<javafx-controls.version>24.0.2</javafx-controls.version>
1919

2020
<TarsosDSP.version>2.5</TarsosDSP.version>
2121
<slf4j-api.version>2.0.16</slf4j-api.version>

src/main/java/com/lazydash/audio/visualizer/Main.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public void start(Stage primaryStage) throws Exception {
7979

8080
@Override
8181
public void stop() throws Exception {
82-
AppConfig.windowHeight = stage.getHeight();
83-
AppConfig.windowWidth = stage.getWidth();
82+
AppConfig.windowHeight = (int) Math.round(stage.getHeight());
83+
AppConfig.windowWidth = (int) Math.round(stage.getWidth());
8484
AppConfig.windowX = stage.getX();
8585
AppConfig.windowY = stage.getY();
8686
configFilePersistence.persist(AppConfig.class, CONFIG_VISUALIZER_APPLICATION_PROPERTIES);
@@ -146,11 +146,11 @@ private Stage createStage(Parent root) throws IOException {
146146
});
147147

148148
stage.heightProperty().addListener((observable, oldValue, newValue) -> {
149-
AppConfig.windowHeight = newValue.doubleValue();
149+
AppConfig.windowHeight = newValue.intValue();
150150
});
151151

152152
stage.widthProperty().addListener((observable, oldValue, newValue) -> {
153-
AppConfig.windowWidth = newValue.doubleValue();
153+
AppConfig.windowWidth = newValue.intValue();
154154
});
155155

156156
// set opacity

src/main/java/com/lazydash/audio/visualizer/core/audio/FFTAudioProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.lazydash.audio.visualizer.system.config.AppConfig;
1111
import org.hipparchus.analysis.UnivariateFunction;
1212
import org.hipparchus.analysis.interpolation.AkimaSplineInterpolator;
13+
import org.hipparchus.analysis.interpolation.LinearInterpolator;
1314
import org.hipparchus.analysis.interpolation.UnivariateInterpolator;
1415
import org.slf4j.Logger;
1516
import org.slf4j.LoggerFactory;

src/main/java/com/lazydash/audio/visualizer/core/audio/TarsosAudioEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void start() {
3434

3535
int buffer = (int) (audioWindowSize * (sampleRate / 1000.0d));
3636

37-
TargetDataLine line = getLine(audioFormat, buffer);
37+
TargetDataLine line = getLine(audioFormat, buffer * 2);
3838
run(line, audioFormat, buffer, 0);
3939

4040
} catch (LineUnavailableException e) {

src/main/java/com/lazydash/audio/visualizer/system/config/AppConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class AppConfig {
2222
public static int minBarHeight = 2;
2323
public static int barGap = 1;
2424

25-
public static double maxBarHeight = 352;
25+
public static int maxBarHeight = 352;
2626
public static int hzLabelHeight = 20;
2727

2828
// spectral color
@@ -43,8 +43,8 @@ public class AppConfig {
4343

4444
// window
4545
public static boolean windowDecorations = true;
46-
public static double windowWidth = 1700;
47-
public static double windowHeight = 400;
46+
public static int windowWidth = 1700;
47+
public static int windowHeight = 400;
4848
public static double windowX = -1;
4949
public static double windowY = -1;
5050
public static boolean enableHoverOpacity = false;

src/main/java/com/lazydash/audio/visualizer/ui/code/spectral/SpectralView.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
import javafx.geometry.Insets;
77
import javafx.geometry.Pos;
88
import javafx.geometry.VPos;
9+
import javafx.scene.effect.BlendMode;
910
import javafx.scene.layout.*;
10-
import javafx.scene.paint.Color;
11-
import javafx.scene.paint.CycleMethod;
12-
import javafx.scene.paint.LinearGradient;
13-
import javafx.scene.paint.Stop;
11+
import javafx.scene.paint.*;
1412
import javafx.scene.text.Font;
1513

1614
import java.util.ArrayList;
1715
import java.util.List;
1816

19-
public class SpectralView extends GridPane {
17+
public class SpectralView extends HBox {
2018
private final List<FrequencyView> frequencyViewList = new ArrayList<>();
2119
private final Color backgroundColor = Color.TRANSPARENT;
2220
private final Background background = new Background(new BackgroundFill(backgroundColor, CornerRadii.EMPTY, Insets.EMPTY));
@@ -46,10 +44,6 @@ public void configure() {
4644
CornerRadii.EMPTY, new BorderWidths(1), Insets.EMPTY)));
4745
}
4846

49-
RowConstraints rowConstraintsAmplitudes = new RowConstraints();
50-
rowConstraintsAmplitudes.setVgrow(Priority.NEVER);
51-
this.getRowConstraints().add(rowConstraintsAmplitudes);
52-
5347
this.heightProperty().addListener((observable, oldValue, newValue) -> {
5448
AppConfig.maxBarHeight = newValue.intValue() - AppConfig.hzLabelHeight;
5549
});
@@ -79,9 +73,9 @@ public void updateState(List<FrequencyBar> frequencyBarList) {
7973
}
8074

8175
private void updateBars(List<FrequencyBar> frequencyBarList) {
82-
this.setHgap(AppConfig.barGap);
76+
this.setSpacing(AppConfig.barGap);
8377

84-
double rectangleWidth = (this.getWidth() / (frequencyViewList.size() + 1) - AppConfig.barGap);
78+
double rectangleWidth = (this.getWidth() / (frequencyViewList.size()) - (AppConfig.barGap * 2));
8579

8680
for (int i = 0; i < frequencyViewList.size(); i++) {
8781
FrequencyView frequencyView = frequencyViewList.get(i);
@@ -102,6 +96,7 @@ private void updateBars(List<FrequencyBar> frequencyBarList) {
10296
frequencyView.getShadow().setWidth(rectangleWidth);
10397
} else {
10498
frequencyView.getShadow().setHeight(0);
99+
frequencyView.getShadow().setWidth(rectangleWidth);
105100
}
106101

107102
frequencyView.getRectangle().setFill(frequencyBar.getColor());
@@ -125,17 +120,14 @@ private void createBars(List<FrequencyBar> frequencyBarList) {
125120

126121
VBox amplitudeVBox = new VBox();
127122
amplitudeVBox.setAlignment(Pos.BOTTOM_CENTER);
123+
amplitudeVBox.setSpacing(-2);
128124
amplitudeVBox.getChildren().add(frequencyView.getShadow());
129125
amplitudeVBox.getChildren().add(frequencyView.getRectangle());
130-
this.add(amplitudeVBox, i, 0);
126+
amplitudeVBox.getChildren().add(frequencyView.getHzLabel());
131127

132-
VBox hzVBox = new VBox();
133-
hzVBox.setAlignment(Pos.BOTTOM_CENTER);
134-
hzVBox.getChildren().add(frequencyView.getHzLabel());
135-
this.add(hzVBox, i, 1);
128+
this.getChildren().add(amplitudeVBox);
136129

137-
GridPane.setValignment(frequencyView.getRectangle(), VPos.BOTTOM);
138-
GridPane.setHalignment(frequencyView.getHzLabel(), HPos.CENTER);
130+
HBox.setMargin(this, Insets.EMPTY);
139131
}
140132
}
141133
}

src/main/resources/ui/fxml/settings/settings.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
fx:controller="com.lazydash.audio.visualizer.ui.fxml.settings.SettingsController">
99

1010
<left>
11-
<VBox id="side-bar">
11+
<VBox id="side-bar" minWidth="200">
1212
<VBox fx:id="sideBarSettings">
1313

1414
</VBox>

0 commit comments

Comments
 (0)