Commit 8913f189 authored by petter's avatar petter

Warn at low volume level

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@137 0463f305-d864-43cb-8a47-61cf597d4139
parent e467e9e2
......@@ -32,6 +32,7 @@ import java.awt.geom.Rectangle2D;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
......@@ -133,4 +134,9 @@ public class AudioMonitorPanel extends JPanel {
}
}
public void warnMuted() {
JOptionPane.showMessageDialog(null, "The volume level is suspiciously low.\nPlease check, whether the microphone is muted or the batteries are low", "Volume level alert", JOptionPane.WARNING_MESSAGE);
}
}
......@@ -42,6 +42,7 @@ public class TargetDataLineMonitor implements TargetDataLine {
private TargetDataLine targetDataLine;
private float meanSampleValue = 0;
private AudioMonitorPanel volumeLevelComponent;
private int mutecounter=0;
public int read(byte[] buffer, int offset, int len) {
int i = targetDataLine.read(buffer, offset, len);
......@@ -60,6 +61,12 @@ public class TargetDataLineMonitor implements TargetDataLine {
if (volumeLevelComponent != null)
volumeLevelComponent.setPeakPercentage(meanSampleValue * 2);
if (meanSampleValue<0.00000001) mutecounter++;
if (mutecounter>250){
mutecounter=0;
volumeLevelComponent.warnMuted();
}
return i;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment