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 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;

View file

@ -20,6 +20,7 @@ public abstract class AudioEffect implements LEDEffect {
Mixer.Info[] mixers = AudioSystem.getMixerInfo();
List<Line.Info> 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);

View file

@ -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();
}

View file

@ -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");

View file

@ -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<Measurement> history = new ArrayList<>();