Added peak dB display in tree
This commit is contained in:
@@ -2418,7 +2418,8 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
||||
|
||||
public double getNoiseFloor() {
|
||||
if (roomNoise == null) return 0;
|
||||
double[][] samples = roomNoise.getDoubleAudioData();
|
||||
return roomNoise.getPeak();
|
||||
/* double[][] samples = roomNoise.getDoubleAudioData();
|
||||
if (samples == null) {
|
||||
return 0;
|
||||
}
|
||||
@@ -2431,16 +2432,20 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
||||
|
||||
ms *= 10d;
|
||||
ms /= 7d;
|
||||
return ms;
|
||||
return ms;*/
|
||||
}
|
||||
|
||||
public int getNoiseFloorDB() {
|
||||
if (roomNoise == null) return 0;
|
||||
return roomNoise.getPeakDB();
|
||||
/*
|
||||
double r = getNoiseFloor();
|
||||
if (r == 0) return 0;
|
||||
double l10 = Math.log10(r);
|
||||
double db = 20d * l10;
|
||||
|
||||
return (int)db;
|
||||
*/
|
||||
}
|
||||
|
||||
public void recordRoomNoise() {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
ctx.gridwidth = 2;
|
||||
p.add(ret, ctx);
|
||||
} else {
|
||||
ctx.weightx = 0.1d;
|
||||
ctx.weightx = 1.0d;
|
||||
ctx.gridwidth = 1;
|
||||
p.add(ret, ctx);
|
||||
Effect e = AudiobookRecorder.window.effects.get(effectChain);
|
||||
@@ -101,9 +101,20 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
p.add(eff);
|
||||
}
|
||||
|
||||
ctx.gridwidth = 1;
|
||||
ctx.weightx = 0.0d;
|
||||
ctx.gridx = 2;
|
||||
ctx.anchor = GridBagConstraints.LINE_END;
|
||||
int peak = s.getPeakDB();
|
||||
JLabel peakLabel = new JLabel(peak + "dB ");
|
||||
if (peak > 0) {
|
||||
peakLabel.setForeground(new Color(0xCC, 0x00, 0x00));
|
||||
}
|
||||
p.add(peakLabel, ctx);
|
||||
|
||||
ctx.weightx = 0.0d;
|
||||
ctx.gridx = 3;
|
||||
ctx.anchor = GridBagConstraints.LINE_END;
|
||||
p.add(time, ctx);
|
||||
|
||||
p.setOpaque(false);
|
||||
|
||||
@@ -54,6 +54,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
String postGapType = "none";
|
||||
|
||||
int sampleSize = -1;
|
||||
double peak = -1;
|
||||
|
||||
boolean locked;
|
||||
|
||||
@@ -196,6 +197,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
sampleSize = Utils.s2i(Book.getTextNode(root, "samples"));
|
||||
processed = Utils.s2b(Book.getTextNode(root, "processed"));
|
||||
runtime = Utils.s2d(Book.getTextNode(root, "time", "-1.000"));
|
||||
peak = Utils.s2d(Book.getTextNode(root, "peak", "-1.000"));
|
||||
|
||||
if ((crossStartOffset == -1) || (crossEndOffset == -1)) {
|
||||
System.err.println("Updating " + id);
|
||||
@@ -259,6 +261,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
endOffset = sampleSize - 1;
|
||||
crossEndOffset = sampleSize - 1;
|
||||
processed = false;
|
||||
peak = -1d;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,6 +812,8 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
int gainint = (int)(gain * 100d);
|
||||
if (gint != gainint) {
|
||||
CacheManager.removeFromCache(this);
|
||||
peak = -1;
|
||||
reloadTree();
|
||||
}
|
||||
gain = g;
|
||||
}
|
||||
@@ -1470,6 +1475,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "processed", isProcessed()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "notes", getNotes()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "time", getLength()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "peak", getPeak()));
|
||||
return sentenceNode;
|
||||
}
|
||||
|
||||
@@ -1500,4 +1506,34 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public double getPeak() {
|
||||
if (peak > -1) return peak;
|
||||
double[][] samples = getDoubleAudioData();
|
||||
if (samples == null) {
|
||||
peak = -1;
|
||||
return 0;
|
||||
}
|
||||
double ms = 0;
|
||||
for (int i = 0; i < samples.length; i++) {
|
||||
if (Math.abs((samples[i][Sentence.LEFT] + samples[i][Sentence.RIGHT]) / 2d) > ms) {
|
||||
ms = Math.abs((samples[i][Sentence.LEFT] + samples[i][Sentence.RIGHT]) / 2d);
|
||||
}
|
||||
}
|
||||
|
||||
ms *= 10d;
|
||||
ms /= 7d;
|
||||
peak = ms;
|
||||
return ms;
|
||||
}
|
||||
|
||||
public int getPeakDB() {
|
||||
double r = getPeak();
|
||||
if (r == 0) return 0;
|
||||
double l10 = Math.log10(r);
|
||||
double db = 20d * l10;
|
||||
|
||||
return (int)db;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user