diff --git a/src/main/java/de/zuim/ledcontrol/EffectManager.java b/src/main/java/de/zuim/ledcontrol/EffectManager.java index 3bb60b3..9043ee4 100644 --- a/src/main/java/de/zuim/ledcontrol/EffectManager.java +++ b/src/main/java/de/zuim/ledcontrol/EffectManager.java @@ -16,7 +16,7 @@ public class EffectManager { private boolean sweep = false; - private final LEDEffect[] effects = new LEDEffect[]{new ClockEffect(), new AudioVolumeEffect(), new NetworkSpeedEffect(), new SineEffect(), new AudioFFTEffect(), new ColorSweepEffect()}; + private final LEDEffect[] effects = new LEDEffect[]{new ClockEffect(), new NetworkSpeedEffect(), new SineEffect(), new AudioFFTEffect(), new ColorSweepEffect()}; private int activeId = 4; private final TrayIcon trayIcon; diff --git a/src/main/java/de/zuim/ledcontrol/effects/AudioEffect.java b/src/main/java/de/zuim/ledcontrol/effects/AudioEffect.java index f4d9663..c072373 100644 --- a/src/main/java/de/zuim/ledcontrol/effects/AudioEffect.java +++ b/src/main/java/de/zuim/ledcontrol/effects/AudioEffect.java @@ -20,6 +20,7 @@ public abstract class AudioEffect implements LEDEffect { Mixer.Info[] mixers = AudioSystem.getMixerInfo(); List availableTargetLines = new ArrayList<>(); + Mixer mixer = null; for (Mixer.Info mixerInfo : mixers) { Mixer m = AudioSystem.getMixer(mixerInfo); @@ -29,8 +30,9 @@ public abstract class AudioEffect implements LEDEffect { for (Line.Info li : lines) { try { - if (li instanceof DataLine.Info && mixerInfo.toString().contains("default")) { + if (li instanceof DataLine.Info && mixerInfo.toString().contains("mix")) { m.open(); + mixer = m; System.out.println("(" + availableTargetLines.size() + ") Found target line: " + li + " " + mixerInfo + "(" + li.getClass() + ")"); availableTargetLines.add(li); m.close(); @@ -48,7 +50,7 @@ public abstract class AudioEffect implements LEDEffect { for (int i = 0; i < formats.length; i++) { System.out.println("(" + i + ")" + formats[i]); } - AudioFormat format = formats[64]; + AudioFormat format = formats[formats.length > 10 ? 64 : 2]; System.out.println("SELECTED: " + format); @@ -59,7 +61,8 @@ public abstract class AudioEffect implements LEDEffect { //verbesserung: https://stackoverflow.com/a/51240462 try { - TargetDataLine targetLine = (TargetDataLine) AudioSystem.getLine(info); + //TargetDataLine targetLine = (TargetDataLine) AudioSystem.getLine(info); + TargetDataLine targetLine = (TargetDataLine) mixer.getLine(info); targetLine.open(); targetLine.start(); audioStream = new AudioInputStream(targetLine); diff --git a/src/main/java/de/zuim/ledcontrol/effects/AudioVolumeEffect.java b/src/main/java/de/zuim/ledcontrol/effects/AudioVolumeEffect.java index 37686ef..50a3964 100644 --- a/src/main/java/de/zuim/ledcontrol/effects/AudioVolumeEffect.java +++ b/src/main/java/de/zuim/ledcontrol/effects/AudioVolumeEffect.java @@ -22,16 +22,16 @@ public class AudioVolumeEffect extends AudioFFTEffect { timeDeltaSum += timeDelta; if (!getData().isEmpty()) { - /*float avg = 0; + float avg = 0; float max = 0; - for (double v : getData().get(0)) { + for (double v : getData().get(0).magnitudes) { avg += Math.abs(v); if (v > max) { max = (float) v; } } - avg /= cachedMagnitudes.get(0).length;*/ - System.out.println(getData().get(0).level); + avg /= getData().get(0).magnitudes.length; + System.out.println(avg); volHistory.add((int) (getData().get(0).level * 100)); getData().clear(); } diff --git a/src/main/java/de/zuim/ledcontrol/effects/ClockEffect.java b/src/main/java/de/zuim/ledcontrol/effects/ClockEffect.java index b93ee8e..14fee4e 100644 --- a/src/main/java/de/zuim/ledcontrol/effects/ClockEffect.java +++ b/src/main/java/de/zuim/ledcontrol/effects/ClockEffect.java @@ -9,7 +9,7 @@ import java.util.Date; import static de.zuim.ledcontrol.LEDControl.HEIGHT; public class ClockEffect implements LEDEffect { - private Font font = new Font("crosextra-carlito", Font.BOLD, 10 * getScale()); + private Font font = new Font("Calibri", Font.BOLD, 12 * getScale()); private double posOffset = 3; @Override @@ -22,13 +22,13 @@ public class ClockEffect implements LEDEffect { public void fontSwitcher() { if (++iteration % 100 == 0) { Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); - font = new Font(allFonts[iteration / 100].getFontName(), Font.PLAIN, 10 * getScale()); + font = new Font(allFonts[iteration / 100].getFontName(), Font.PLAIN, 12 * getScale()); System.out.println(allFonts[iteration / 100].getFontName()); } } public void render(long timeDelta, Graphics g) { - fontSwitcher(); + //fontSwitcher(); Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("H:mm"); diff --git a/src/main/java/de/zuim/ledcontrol/effects/NetworkSpeedEffect.java b/src/main/java/de/zuim/ledcontrol/effects/NetworkSpeedEffect.java index c57cf4f..5429f05 100644 --- a/src/main/java/de/zuim/ledcontrol/effects/NetworkSpeedEffect.java +++ b/src/main/java/de/zuim/ledcontrol/effects/NetworkSpeedEffect.java @@ -29,11 +29,11 @@ public class NetworkSpeedEffect implements LEDEffect { if (network == null) { SystemInfo si = new SystemInfo(); HardwareAbstractionLayer hal = si.getHardware(); - network = hal.getNetworkIFs().get(2); + network = hal.getNetworkIFs().get(0); } } - private final Font font = new Font("crosextra-carlito", Font.BOLD, 7 * getScale()); + private final Font font = new Font("Calibri", Font.BOLD, 8 * getScale()); long lastDownBytes = 0, lastUpBytes = 0; private final List history = new ArrayList<>();