adjustments for pc

This commit is contained in:
Felix Klenner 2021-03-14 16:28:45 +01:00
parent 27948a134b
commit 139b4245ea
5 changed files with 16 additions and 13 deletions

View file

@ -16,7 +16,7 @@ public class EffectManager {
private boolean sweep = false; 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 int activeId = 4;
private final TrayIcon trayIcon; private final TrayIcon trayIcon;

View file

@ -20,6 +20,7 @@ public abstract class AudioEffect implements LEDEffect {
Mixer.Info[] mixers = AudioSystem.getMixerInfo(); Mixer.Info[] mixers = AudioSystem.getMixerInfo();
List<Line.Info> availableTargetLines = new ArrayList<>(); List<Line.Info> availableTargetLines = new ArrayList<>();
Mixer mixer = null;
for (Mixer.Info mixerInfo : mixers) { for (Mixer.Info mixerInfo : mixers) {
Mixer m = AudioSystem.getMixer(mixerInfo); Mixer m = AudioSystem.getMixer(mixerInfo);
@ -29,8 +30,9 @@ public abstract class AudioEffect implements LEDEffect {
for (Line.Info li : lines) { for (Line.Info li : lines) {
try { try {
if (li instanceof DataLine.Info && mixerInfo.toString().contains("default")) { if (li instanceof DataLine.Info && mixerInfo.toString().contains("mix")) {
m.open(); m.open();
mixer = m;
System.out.println("(" + availableTargetLines.size() + ") Found target line: " + li + " " + mixerInfo + "(" + li.getClass() + ")"); System.out.println("(" + availableTargetLines.size() + ") Found target line: " + li + " " + mixerInfo + "(" + li.getClass() + ")");
availableTargetLines.add(li); availableTargetLines.add(li);
m.close(); m.close();
@ -48,7 +50,7 @@ public abstract class AudioEffect implements LEDEffect {
for (int i = 0; i < formats.length; i++) { for (int i = 0; i < formats.length; i++) {
System.out.println("(" + i + ")" + formats[i]); System.out.println("(" + i + ")" + formats[i]);
} }
AudioFormat format = formats[64]; AudioFormat format = formats[formats.length > 10 ? 64 : 2];
System.out.println("SELECTED: " + format); System.out.println("SELECTED: " + format);
@ -59,7 +61,8 @@ public abstract class AudioEffect implements LEDEffect {
//verbesserung: https://stackoverflow.com/a/51240462 //verbesserung: https://stackoverflow.com/a/51240462
try { try {
TargetDataLine targetLine = (TargetDataLine) AudioSystem.getLine(info); //TargetDataLine targetLine = (TargetDataLine) AudioSystem.getLine(info);
TargetDataLine targetLine = (TargetDataLine) mixer.getLine(info);
targetLine.open(); targetLine.open();
targetLine.start(); targetLine.start();
audioStream = new AudioInputStream(targetLine); audioStream = new AudioInputStream(targetLine);

View file

@ -22,16 +22,16 @@ public class AudioVolumeEffect extends AudioFFTEffect {
timeDeltaSum += timeDelta; timeDeltaSum += timeDelta;
if (!getData().isEmpty()) { if (!getData().isEmpty()) {
/*float avg = 0; float avg = 0;
float max = 0; float max = 0;
for (double v : getData().get(0)) { for (double v : getData().get(0).magnitudes) {
avg += Math.abs(v); avg += Math.abs(v);
if (v > max) { if (v > max) {
max = (float) v; max = (float) v;
} }
} }
avg /= cachedMagnitudes.get(0).length;*/ avg /= getData().get(0).magnitudes.length;
System.out.println(getData().get(0).level); System.out.println(avg);
volHistory.add((int) (getData().get(0).level * 100)); volHistory.add((int) (getData().get(0).level * 100));
getData().clear(); getData().clear();
} }

View file

@ -9,7 +9,7 @@ import java.util.Date;
import static de.zuim.ledcontrol.LEDControl.HEIGHT; import static de.zuim.ledcontrol.LEDControl.HEIGHT;
public class ClockEffect implements LEDEffect { 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; private double posOffset = 3;
@Override @Override
@ -22,13 +22,13 @@ public class ClockEffect implements LEDEffect {
public void fontSwitcher() { public void fontSwitcher() {
if (++iteration % 100 == 0) { if (++iteration % 100 == 0) {
Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); 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()); System.out.println(allFonts[iteration / 100].getFontName());
} }
} }
public void render(long timeDelta, Graphics g) { public void render(long timeDelta, Graphics g) {
fontSwitcher(); //fontSwitcher();
Date date = new Date(); Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("H:mm"); SimpleDateFormat formatter = new SimpleDateFormat("H:mm");

View file

@ -29,11 +29,11 @@ public class NetworkSpeedEffect implements LEDEffect {
if (network == null) { if (network == null) {
SystemInfo si = new SystemInfo(); SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware(); 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; long lastDownBytes = 0, lastUpBytes = 0;
private final List<Measurement> history = new ArrayList<>(); private final List<Measurement> history = new ArrayList<>();