diff --git a/PlayWall/assets/de/tobias/playpad/assets/modern_style.css b/PlayWall/assets/de/tobias/playpad/assets/modern_style.css index 84ae1898d566a5f64fa01c995e0619c2c561284f..e6696ef97cc54d85301cd95b4ee53c8d2789b095 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/modern_style.css +++ b/PlayWall/assets/de/tobias/playpad/assets/modern_style.css @@ -146,4 +146,4 @@ .progress-indicator .percentage { -fx-fill: white; -} +} \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java index e4ffc6b916771f52336f46f31cd9b537cf5720e4..9a5a47632426effecc763aba58b6ef7f8e56a301 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java @@ -36,6 +36,7 @@ import de.tobias.playpad.viewcontroller.option.IProfileSettingsViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; import de.tobias.utils.util.FileUtils; +import de.tobias.utils.util.OS; import de.tobias.utils.util.SystemUtils; import de.tobias.utils.util.Worker; import javafx.scene.image.Image; @@ -188,7 +189,7 @@ public class PlayPadImpl implements PlayPad { // TODO Auto-generated catch block e.printStackTrace(); } - + pluginManager.shutdown(); Worker.shutdown(); } @@ -213,11 +214,11 @@ public class PlayPadImpl implements PlayPad { public Project getCurrentProject() { return currentProject; } - + public void startup(ResourceBundle resourceBundle) { registerComponents(resourceBundle); } - + private void registerComponents(ResourceBundle resourceBundle) { // Midi DeviceRegistry.getFactoryInstance().registerDevice(PD12.NAME, PD12.class); @@ -235,8 +236,10 @@ public class PlayPadImpl implements PlayPad { registryCollection.getTriggerItems().loadComponentsFromFile("de/tobias/playpad/components/Trigger.xml"); registryCollection.getMainLayouts().loadComponentsFromFile("de/tobias/playpad/components/Layout.xml"); - registryCollection.getAudioHandlers().registerComponent(new NativeAudioMacHandlerConnect(), "Native"); - + if (OS.isMacOS()) { + registryCollection.getAudioHandlers().registerComponent(new NativeAudioMacHandlerConnect(), "Native"); + } + // Set Default registryCollection.getAudioHandlers().setDefaultID(JavaFXAudioHandler.TYPE); registryCollection.getDesigns().setDefaultID(ModernGlobalDesign.TYPE); diff --git a/PlayWallCore/src/de/tobias/playpad/pad/view/PeakMeter.java b/PlayWallCore/src/de/tobias/playpad/pad/view/PeakMeter.java index 4fba196093125dcbd068301b22ec5fcb866cc921..97a0e2fd89ccda495bf022840f5713c1cc427926 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/view/PeakMeter.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/view/PeakMeter.java @@ -4,39 +4,65 @@ import de.tobias.playpad.audio.Peakable; import de.tobias.playpad.audio.Peakable.Channel; import de.tobias.playpad.settings.PeakType; import javafx.beans.value.ChangeListener; -import javafx.scene.control.ProgressBar; +import javafx.css.PseudoClass; import javafx.scene.layout.VBox; public class PeakMeter extends VBox { - private ProgressBar progressbarLeft; - private ProgressBar progressbarRight; + private static final PseudoClass yellowClass = PseudoClass.getPseudoClass("yellow"); + private static final PseudoClass redClass = PseudoClass.getPseudoClass("red"); + + private PeakTrack progressbarLeft; + private PeakTrack progressbarRight; private ChangeListener<Number> leftListener; private ChangeListener<Number> rightListener; public PeakMeter(Peakable peakable, PeakType type) { - progressbarLeft = new ProgressBar(0); - progressbarRight = new ProgressBar(0); + progressbarLeft = new PeakTrack(this); + progressbarRight = new PeakTrack(this); leftListener = (a, b, c) -> { - double value = (c.doubleValue() + 60) * 1 / 60; + double dB = c.doubleValue(); + double value = (dB + 60) * 1 / 60; if (value < 0) value = 0; + + progressbarLeft.pseudoClassStateChanged(yellowClass, false); + progressbarLeft.pseudoClassStateChanged(redClass, false); + + if (dB > -7) { + progressbarLeft.pseudoClassStateChanged(yellowClass, true); + } + + if (dB > -3) { + progressbarLeft.pseudoClassStateChanged(redClass, true); + } + progressbarLeft.setProgress(value); }; rightListener = (a, b, c) -> { - double value = (c.doubleValue() + 60) * 1 / 60; + double dB = c.doubleValue(); + double value = (dB + 60) * 1 / 60; if (value < 0) value = 0; + + progressbarRight.pseudoClassStateChanged(yellowClass, false); + progressbarRight.pseudoClassStateChanged(redClass, false); + + if (dB > -7) { + progressbarRight.pseudoClassStateChanged(yellowClass, true); + } + + if (dB > -3) { + progressbarRight.pseudoClassStateChanged(redClass, true); + } + progressbarRight.setProgress(value); }; - progressbarLeft.getStyleClass().add("pad-playbar"); - progressbarRight.getStyleClass().add("pad-playbar"); - progressbarLeft.prefWidthProperty().bind(widthProperty()); progressbarRight.prefWidthProperty().bind(widthProperty()); diff --git a/PlayWallCore/src/de/tobias/playpad/pad/view/PeakTrack.java b/PlayWallCore/src/de/tobias/playpad/pad/view/PeakTrack.java new file mode 100644 index 0000000000000000000000000000000000000000..7c3686496d92b95c5ccf06e5ceee393527fe3ed0 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/pad/view/PeakTrack.java @@ -0,0 +1,53 @@ +package de.tobias.playpad.pad.view; + +import javafx.beans.property.DoubleProperty; +import javafx.beans.property.SimpleDoubleProperty; +import javafx.geometry.Insets; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.Border; +import javafx.scene.layout.BorderStroke; +import javafx.scene.layout.BorderStrokeStyle; +import javafx.scene.layout.BorderWidths; +import javafx.scene.layout.CornerRadii; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.paint.Color; + +public class PeakTrack extends HBox { + + private DoubleProperty progressProperty; + + public PeakTrack(Pane parent) { + progressProperty = new SimpleDoubleProperty(); + + setPrefHeight(10); + setSpacing(2); + } + + public void setProgress(double progress) { + progressProperty.set(progress); + + getChildren().clear(); + + if (progress != 0) { + for (double i = 0; i <= progress; i += 0.05) { + Pane label = new Pane(); + + label.minHeightProperty().bind(minHeightProperty()); + label.prefHeightProperty().bind(prefHeightProperty()); + + label.prefWidthProperty().bind(widthProperty().multiply(0.05).subtract(2)); + + label.setBorder(new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, new CornerRadii(5), new BorderWidths(0.5)))); + if (i < 0.75) + label.setBackground(new Background(new BackgroundFill(Color.GREEN, new CornerRadii(5), Insets.EMPTY))); + else if (i < 0.9) + label.setBackground(new Background(new BackgroundFill(Color.YELLOW, new CornerRadii(5), Insets.EMPTY))); + else + label.setBackground(new Background(new BackgroundFill(Color.RED, new CornerRadii(5), Insets.EMPTY))); + getChildren().add(label); + } + } + } +}