Cure tree flashing on playback
This commit is contained in:
@@ -2034,6 +2034,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
bookTree.addTreeSelectionListener(new TreeSelectionListener() {
|
bookTree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||||
public void valueChanged(TreeSelectionEvent e) {
|
public void valueChanged(TreeSelectionEvent e) {
|
||||||
DefaultMutableTreeNode n = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
DefaultMutableTreeNode n = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||||
|
|
||||||
if (n instanceof BookTreeNode) {
|
if (n instanceof BookTreeNode) {
|
||||||
BookTreeNode btn = (BookTreeNode)n;
|
BookTreeNode btn = (BookTreeNode)n;
|
||||||
btn.onSelect();
|
btn.onSelect();
|
||||||
@@ -2531,11 +2532,17 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
|
|
||||||
int numKids = chapter.getChildCount();
|
int numKids = chapter.getChildCount();
|
||||||
int kidCount = 0;
|
int kidCount = 0;
|
||||||
|
double lastGain = -1;
|
||||||
|
double variance = Options.getInteger("audio.recording.variance") / 100d;
|
||||||
for (Enumeration s = chapter.children(); s.hasMoreElements();) {
|
for (Enumeration s = chapter.children(); s.hasMoreElements();) {
|
||||||
kidCount++;
|
kidCount++;
|
||||||
dialog.setProgress(kidCount * 2000 / numKids);
|
dialog.setProgress(kidCount * 2000 / numKids);
|
||||||
Sentence snt = (Sentence)s.nextElement();
|
Sentence snt = (Sentence)s.nextElement();
|
||||||
snt.normalize();
|
if (lastGain == -1) {
|
||||||
|
lastGain = snt.normalize();
|
||||||
|
} else {
|
||||||
|
lastGain = snt.normalize(lastGain - variance, lastGain + variance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.closeDialog();
|
dialog.closeDialog();
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class Options extends JDialog {
|
|||||||
JSpinner shortSentenceGap;
|
JSpinner shortSentenceGap;
|
||||||
JSpinner postParagraphGap;
|
JSpinner postParagraphGap;
|
||||||
JSpinner postSectionGap;
|
JSpinner postSectionGap;
|
||||||
|
JSpinner maxGainVariance;
|
||||||
JTextField ffmpegLocation;
|
JTextField ffmpegLocation;
|
||||||
JComboBox<KVPair> bitRate;
|
JComboBox<KVPair> bitRate;
|
||||||
JComboBox<KVPair> channels;
|
JComboBox<KVPair> channels;
|
||||||
@@ -301,6 +302,7 @@ public class Options extends JDialog {
|
|||||||
trimMethod = addDropdown(optionsPanel, "Auto-trim method:", getTrimMethods(), get("audio.recording.trim"));
|
trimMethod = addDropdown(optionsPanel, "Auto-trim method:", getTrimMethods(), get("audio.recording.trim"));
|
||||||
fftThreshold = addSpinner(optionsPanel, "FFT threshold:", 0, 100, 1, getInteger("audio.recording.trim.fft"), "");
|
fftThreshold = addSpinner(optionsPanel, "FFT threshold:", 0, 100, 1, getInteger("audio.recording.trim.fft"), "");
|
||||||
fftBlockSize = addDropdown(optionsPanel, "FFT Block size:", getFFTBlockSizes(), get("audio.recording.trim.blocksize"));
|
fftBlockSize = addDropdown(optionsPanel, "FFT Block size:", getFFTBlockSizes(), get("audio.recording.trim.blocksize"));
|
||||||
|
maxGainVariance = addSpinner(optionsPanel, "Maximum gain variance:", 0, 100, 1, getInteger("audio.recording.variance"), "");
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
@@ -582,6 +584,7 @@ public class Options extends JDialog {
|
|||||||
defaultPrefs.put("catenation.post-section", "3000");
|
defaultPrefs.put("catenation.post-section", "3000");
|
||||||
|
|
||||||
defaultPrefs.put("audio.recording.trim.fft", "10");
|
defaultPrefs.put("audio.recording.trim.fft", "10");
|
||||||
|
defaultPrefs.put("audio.recording.variance", "10");
|
||||||
|
|
||||||
defaultPrefs.put("path.storage", (new File(System.getProperty("user.home"), "Recordings")).toString());
|
defaultPrefs.put("path.storage", (new File(System.getProperty("user.home"), "Recordings")).toString());
|
||||||
defaultPrefs.put("path.archive", (new File(new File(System.getProperty("user.home"), "Recordings"),"archive")).toString());
|
defaultPrefs.put("path.archive", (new File(new File(System.getProperty("user.home"), "Recordings"),"archive")).toString());
|
||||||
@@ -718,6 +721,7 @@ public class Options extends JDialog {
|
|||||||
set("editor.external", externalEditor.getText());
|
set("editor.external", externalEditor.getText());
|
||||||
set("cache.size", cacheSize.getValue());
|
set("cache.size", cacheSize.getValue());
|
||||||
set("audio.recording.trim.fft", fftThreshold.getValue());
|
set("audio.recording.trim.fft", fftThreshold.getValue());
|
||||||
|
set("audio.recording.variance", maxGainVariance.getValue());
|
||||||
set("audio.recording.trim.blocksize", ((KVPair)fftBlockSize.getSelectedItem()).key);
|
set("audio.recording.trim.blocksize", ((KVPair)fftBlockSize.getSelectedItem()).key);
|
||||||
set("audio.playback.blocksize", ((KVPair)playbackBlockSize.getSelectedItem()).key);
|
set("audio.playback.blocksize", ((KVPair)playbackBlockSize.getSelectedItem()).key);
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
intens = null;
|
intens = null;
|
||||||
samples = null;
|
samples = null;
|
||||||
processed = true;
|
processed = true;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void autoTrimSamplePeak() {
|
public void autoTrimSamplePeak() {
|
||||||
@@ -407,7 +407,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
if (endOffset >= samples.length) endOffset = samples.length-1;
|
if (endOffset >= samples.length) endOffset = samples.length-1;
|
||||||
updateCrossings(useRaw);
|
updateCrossings(useRaw);
|
||||||
processed = true;
|
processed = true;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -417,7 +417,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
public void setText(String t) {
|
public void setText(String t) {
|
||||||
overrideText = null;
|
overrideText = null;
|
||||||
text = t;
|
text = t;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
@@ -465,7 +465,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
if (o instanceof String) {
|
if (o instanceof String) {
|
||||||
String so = (String)o;
|
String so = (String)o;
|
||||||
text = so;
|
text = so;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,7 +525,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
if (startOffset != o) {
|
if (startOffset != o) {
|
||||||
startOffset = o;
|
startOffset = o;
|
||||||
crossStartOffset = -1;
|
crossStartOffset = -1;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,7 +541,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
if (endOffset != o) {
|
if (endOffset != o) {
|
||||||
endOffset = o;
|
endOffset = o;
|
||||||
crossEndOffset = -1;
|
crossEndOffset = -1;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,7 +570,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
public void doRecognition(StreamSpeechRecognizer recognizer) {
|
public void doRecognition(StreamSpeechRecognizer recognizer) {
|
||||||
try {
|
try {
|
||||||
setText("[recognising...]");
|
setText("[recognising...]");
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
|
|
||||||
byte[] inData = getPCMData();
|
byte[] inData = getPCMData();
|
||||||
|
|
||||||
@@ -585,7 +585,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
recognizer.stopRecognition();
|
recognizer.stopRecognition();
|
||||||
|
|
||||||
setText(res);
|
setText(res);
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -621,8 +621,9 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLocked(boolean l) {
|
public void setLocked(boolean l) {
|
||||||
|
if (locked == l) return;
|
||||||
locked = l;
|
locked = l;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocked() {
|
public boolean isLocked() {
|
||||||
@@ -724,8 +725,9 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAttentionFlag(boolean f) {
|
public void setAttentionFlag(boolean f) {
|
||||||
|
if (attention == f) return;
|
||||||
attention = f;
|
attention = f;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAttentionFlag() {
|
public boolean getAttentionFlag() {
|
||||||
@@ -787,12 +789,24 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
return gain;
|
return gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void normalize() {
|
public double normalize(double low, double high) {
|
||||||
if (locked) return;
|
if (locked) return gain;
|
||||||
|
double max = getPeakValue(true, false);
|
||||||
|
double d = 0.708 / max;
|
||||||
|
if (d > 1d) d = 1d;
|
||||||
|
if (d < low) d = low;
|
||||||
|
if (d > high) d = high;
|
||||||
|
setGain(d);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double normalize() {
|
||||||
|
if (locked) return gain;
|
||||||
double max = getPeakValue(true, false);
|
double max = getPeakValue(true, false);
|
||||||
double d = 0.708 / max;
|
double d = 0.708 / max;
|
||||||
if (d > 1d) d = 1d;
|
if (d > 1d) d = 1d;
|
||||||
setGain(d);
|
setGain(d);
|
||||||
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExternalEditor implements Runnable {
|
class ExternalEditor implements Runnable {
|
||||||
@@ -1321,11 +1335,14 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setEffectChain(String key) {
|
public void setEffectChain(String key) {
|
||||||
|
if ((effectChain != null) && (effectChain.equals(key))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ((effectChain != null) && (!effectChain.equals(key))) {
|
if ((effectChain != null) && (!effectChain.equals(key))) {
|
||||||
CacheManager.removeFromCache(this);
|
CacheManager.removeFromCache(this);
|
||||||
}
|
}
|
||||||
effectChain = key;
|
effectChain = key;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEffectChain() {
|
public String getEffectChain() {
|
||||||
@@ -1352,7 +1369,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
postGapType = t;
|
postGapType = t;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetPostGap() {
|
public void resetPostGap() {
|
||||||
@@ -1431,7 +1448,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
|
|
||||||
public void setProcessed(boolean p) {
|
public void setProcessed(boolean p) {
|
||||||
processed = p;
|
processed = p;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotes(String n) {
|
public void setNotes(String n) {
|
||||||
@@ -1446,4 +1463,9 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
AudiobookRecorder.window.setSentenceNotes(notes);
|
AudiobookRecorder.window.setSentenceNotes(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reloadTree() {
|
||||||
|
if (id.equals("room-noise")) return;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user