Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2064184093 | |||
| 2e6ea5eecc | |||
| 0dde64e5fc | |||
| 28a3326a35 | |||
| df6b893171 | |||
| ead577521d | |||
|
|
cc1c76bd47 | ||
| b74f1aedb4 | |||
| 67d1e787ee | |||
| 11ca88ee38 | |||
|
|
ae4e3db0d7 | ||
|
|
4314790271 | ||
| 9c58276119 | |||
| 16380a9752 | |||
| b523d80c25 |
2
dist/linux/stub
vendored
2
dist/linux/stub
vendored
@@ -5,6 +5,6 @@ java=java
|
|||||||
if test -n "$JAVA_HOME"; then
|
if test -n "$JAVA_HOME"; then
|
||||||
java="$JAVA_HOME/bin/java"
|
java="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
java_args=-Xmx1g
|
java_args=-Xmx8g
|
||||||
exec "$java" $java_args -jar $MYSELF "$@"
|
exec "$java" $java_args -jar $MYSELF "$@"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -138,12 +138,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.thoughtworks.xstream</groupId>
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
<artifactId>xstream</artifactId>
|
<artifactId>xstream</artifactId>
|
||||||
<version>1.4.10-java7</version>
|
<version>1.4.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.ant</groupId>
|
<groupId>org.apache.ant</groupId>
|
||||||
<artifactId>ant</artifactId>
|
<artifactId>ant</artifactId>
|
||||||
<version>1.8.2</version>
|
<version>1.9.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@@ -509,4 +509,4 @@
|
|||||||
|
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
version=0.4.3
|
version=0.4.4
|
||||||
|
|||||||
@@ -204,6 +204,8 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
public Queue<Runnable>processQueue = null;
|
public Queue<Runnable>processQueue = null;
|
||||||
public QueueMonitor queueMonitor = null;
|
public QueueMonitor queueMonitor = null;
|
||||||
|
|
||||||
|
boolean effectsUpdating = false; // crude lock
|
||||||
|
|
||||||
void buildToolbar(Container ob) {
|
void buildToolbar(Container ob) {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
toolBar = new MainToolBar(this);
|
toolBar = new MainToolBar(this);
|
||||||
@@ -637,10 +639,12 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
Debug.d(e);
|
Debug.d(e);
|
||||||
|
if (effectsUpdating) return;
|
||||||
if (selectedSentence != null) {
|
if (selectedSentence != null) {
|
||||||
int i = effectChain.getSelectedIndex();
|
int i = effectChain.getSelectedIndex();
|
||||||
KVPair<String, String> p = effectChain.getItemAt(i);
|
KVPair<String, String> p = effectChain.getItemAt(i);
|
||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
|
System.err.println("I want to select effect " + p.getKey());
|
||||||
selectedSentence.setEffectChain(p.getKey());
|
selectedSentence.setEffectChain(p.getKey());
|
||||||
updateWaveform(true);
|
updateWaveform(true);
|
||||||
}
|
}
|
||||||
@@ -823,8 +827,6 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
locked.setSelected(s.isLocked());
|
locked.setSelected(s.isLocked());
|
||||||
attention.setSelected(s.getAttentionFlag());
|
attention.setSelected(s.getAttentionFlag());
|
||||||
|
|
||||||
setEffectChain(s.getEffectChain());
|
|
||||||
|
|
||||||
postSentenceGap.setEnabled(!s.isLocked());
|
postSentenceGap.setEnabled(!s.isLocked());
|
||||||
gainPercent.setEnabled(!s.isLocked());
|
gainPercent.setEnabled(!s.isLocked());
|
||||||
reprocessAudioFFT.setEnabled(!s.isLocked());
|
reprocessAudioFFT.setEnabled(!s.isLocked());
|
||||||
@@ -1689,12 +1691,17 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
JMenuObject o = (JMenuObject)e.getSource();
|
JMenuObject o = (JMenuObject)e.getSource();
|
||||||
Chapter chap = (Chapter)o.getObject();
|
Chapter chap = (Chapter)o.getObject();
|
||||||
|
|
||||||
ProgressDialog ed = new ProgressDialog("Normalizing " + chap.getName());
|
for (Enumeration s = c.children(); s.hasMoreElements();) {
|
||||||
|
Sentence snt = (Sentence)s.nextElement();
|
||||||
NormalizeThread t = new NormalizeThread(chap, ed);
|
if (!snt.isLocked()) {
|
||||||
Thread nt = new Thread(t);
|
queueJob(new SentenceJob(snt) {
|
||||||
nt.start();
|
public void run() {
|
||||||
ed.setVisible(true);
|
sentence.normalize();
|
||||||
|
sentence.autoAddPeakGainPoints();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2346,7 +2353,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
book.save();
|
book.save();
|
||||||
|
|
||||||
// Add the book to the tree
|
// Add the book to the tree
|
||||||
loadXMLBookStructure(new File(book.getLocation(), "audiobook.abx"));
|
loadXMLBookStructure(book.getLocation("audiobook.abx"));
|
||||||
updateOpenBookList();
|
updateOpenBookList();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@@ -2444,41 +2451,6 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
playingThread.start();
|
playingThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
class NormalizeThread implements Runnable {
|
|
||||||
ProgressDialog dialog;
|
|
||||||
Chapter chapter;
|
|
||||||
|
|
||||||
public NormalizeThread(Chapter c, ProgressDialog e) {
|
|
||||||
super();
|
|
||||||
Debug.trace();
|
|
||||||
dialog = e;
|
|
||||||
chapter = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void run() {
|
|
||||||
Debug.trace();
|
|
||||||
|
|
||||||
int numKids = chapter.getChildCount();
|
|
||||||
int kidCount = 0;
|
|
||||||
double lastGain = -1;
|
|
||||||
double variance = Options.getInteger("audio.recording.variance") / 100d;
|
|
||||||
for (Enumeration s = chapter.children(); s.hasMoreElements();) {
|
|
||||||
kidCount++;
|
|
||||||
dialog.setProgress(kidCount * 2000 / numKids);
|
|
||||||
Sentence snt = (Sentence)s.nextElement();
|
|
||||||
if (lastGain == -1) {
|
|
||||||
lastGain = snt.normalize();
|
|
||||||
} else {
|
|
||||||
lastGain = snt.normalize(lastGain - variance, lastGain + variance);
|
|
||||||
}
|
|
||||||
snt.autoAddPeakGainPoints();
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.closeDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ExportThread implements Runnable {
|
class ExportThread implements Runnable {
|
||||||
ProgressDialog exportDialog;
|
ProgressDialog exportDialog;
|
||||||
Chapter chapter;
|
Chapter chapter;
|
||||||
@@ -2842,6 +2814,11 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
try {
|
try {
|
||||||
|
pd.setMessage("Purging backups...");
|
||||||
|
book.purgeBackups();
|
||||||
|
|
||||||
|
pd.setMessage("Archiving book...");
|
||||||
|
|
||||||
String name = book.getName();
|
String name = book.getName();
|
||||||
File storageDir = new File(Options.get("path.storage"));
|
File storageDir = new File(Options.get("path.storage"));
|
||||||
File bookDir = book.getLocation();
|
File bookDir = book.getLocation();
|
||||||
@@ -2928,6 +2905,8 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
zos.flush();
|
zos.flush();
|
||||||
zos.close();
|
zos.close();
|
||||||
|
|
||||||
|
pd.setMessage("Cleaning up...");
|
||||||
|
|
||||||
while (fileList.size() > 0) {
|
while (fileList.size() > 0) {
|
||||||
File f = fileList.remove(fileList.size() - 1);
|
File f = fileList.remove(fileList.size() - 1);
|
||||||
f.delete();
|
f.delete();
|
||||||
@@ -2941,7 +2920,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
|
|
||||||
public void archiveBook(Book book) {
|
public void archiveBook(Book book) {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
int r = JOptionPane.showConfirmDialog(this, "This will stash the current book away\nin the archives folder in a compressed\nform. The existing book files will be deleted\nand the book closed.\n\nAre you sure you want to do this?", "Archive Book", JOptionPane.OK_CANCEL_OPTION);
|
int r = JOptionPane.showConfirmDialog(this, "This will stash the current book away\nin the archives folder in a compressed\nform. All backups will be purged, the existing book files will be deleted\nand the book closed.\n\nAre you sure you want to do this?", "Archive Book", JOptionPane.OK_CANCEL_OPTION);
|
||||||
|
|
||||||
if (r == JOptionPane.OK_OPTION) {
|
if (r == JOptionPane.OK_OPTION) {
|
||||||
|
|
||||||
@@ -2952,17 +2931,23 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
Thread t = new Thread(runnable);
|
Thread t = new Thread(runnable);
|
||||||
t.start();
|
t.start();
|
||||||
pd.setVisible(true);
|
pd.setVisible(true);
|
||||||
closeBook(book);
|
closeBook(book, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeBook(Book b) {
|
public void closeBook(Book b) {
|
||||||
|
closeBook(b, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeBook(Book b, boolean save) {
|
||||||
if (selectedBook == b) {
|
if (selectedBook == b) {
|
||||||
setSelectedBook(null);
|
setSelectedBook(null);
|
||||||
setSelectedSentence(null);
|
setSelectedSentence(null);
|
||||||
setSelectedChapter(null);
|
setSelectedChapter(null);
|
||||||
}
|
}
|
||||||
saveBook(b);
|
if (save) {
|
||||||
|
saveBook(b);
|
||||||
|
}
|
||||||
bookTreeModel.removeNodeFromParent(b);
|
bookTreeModel.removeNodeFromParent(b);
|
||||||
updateOpenBookList();
|
updateOpenBookList();
|
||||||
}
|
}
|
||||||
@@ -3126,8 +3111,8 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
|
|
||||||
public void updateEffectChains(TreeMap<String, EffectGroup> effs) {
|
public void updateEffectChains(TreeMap<String, EffectGroup> effs) {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
int sel = effectChain.getSelectedIndex();
|
effectsUpdating = true;
|
||||||
KVPair<String, String> ent = effectChain.getItemAt(sel);
|
System.err.println("Updating effect chains");
|
||||||
while (effectChain.getItemCount() > 0) {
|
while (effectChain.getItemCount() > 0) {
|
||||||
effectChain.removeItemAt(0);
|
effectChain.removeItemAt(0);
|
||||||
}
|
}
|
||||||
@@ -3139,15 +3124,40 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
KVPair<String, String> p = new KVPair<String, String>(k, e.toString());
|
KVPair<String, String> p = new KVPair<String, String>(k, e.toString());
|
||||||
effectChain.addItem(p);
|
effectChain.addItem(p);
|
||||||
}
|
}
|
||||||
if (ent != null) {
|
if (selectedSentence != null) {
|
||||||
setEffectChain(ent.getKey());
|
String key = selectedSentence.getEffectChain();
|
||||||
// } else {
|
for (int i = 0; i < effectChain.getItemCount(); i++) {
|
||||||
// setEffectChain(getBook().getDefaultEffect());
|
KVPair<String, String> p = effectChain.getItemAt(i);
|
||||||
|
if (p.getKey().equals(key)) {
|
||||||
|
effectChain.setSelectedIndex(i);
|
||||||
|
effectsUpdating = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
effectsUpdating = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showSelectedEffectChain(String key) {
|
||||||
|
Debug.trace();
|
||||||
|
effectsUpdating = true;
|
||||||
|
System.err.println("Looking for effect " + key + "...");
|
||||||
|
for (int i = 0; i < effectChain.getItemCount(); i++) {
|
||||||
|
KVPair<String, String> p = effectChain.getItemAt(i);
|
||||||
|
System.err.println(" Testing " + p.getKey() + "...");
|
||||||
|
if (p.getKey().equals(key)) {
|
||||||
|
System.err.println(" Found it.");
|
||||||
|
effectChain.setSelectedIndex(i);
|
||||||
|
effectsUpdating = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
effectsUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEffectChain(String key) {
|
public void setEffectChain(String key) {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
|
System.err.println("Setting effect " + key);
|
||||||
for (int i = 0; i < effectChain.getItemCount(); i++) {
|
for (int i = 0; i < effectChain.getItemCount(); i++) {
|
||||||
KVPair<String, String> p = effectChain.getItemAt(i);
|
KVPair<String, String> p = effectChain.getItemAt(i);
|
||||||
if (p.getKey().equals(key)) {
|
if (p.getKey().equals(key)) {
|
||||||
@@ -3270,8 +3280,8 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newSentence.writeAudioData(startSamples);
|
newSentence.writeAudioData(startSamples);
|
||||||
newSentence.setPostGapType("continuation");
|
newSentence.setPostGapType("sentence");
|
||||||
newSentence.setPostGap(Options.getInteger("catenation.short-sentence"));
|
newSentence.setPostGap(Options.getInteger("catenation.post-sentence"));
|
||||||
|
|
||||||
selectedSentence.writeAudioData(endSamples);
|
selectedSentence.writeAudioData(endSamples);
|
||||||
selectedSentence.autoTrimSample();
|
selectedSentence.autoTrimSample();
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ public class Book extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
AudiobookRecorder.window.setBookNotes(notes);
|
AudiobookRecorder.window.setBookNotes(notes);
|
||||||
AudiobookRecorder.window.noiseFloorLabel.setNoiseFloor(getNoiseFloorDB());
|
AudiobookRecorder.window.noiseFloorLabel.setNoiseFloor(getNoiseFloorDB());
|
||||||
// AudiobookRecorder.window.updateEffectChains(effects);
|
AudiobookRecorder.window.updateEffectChains(effects);
|
||||||
TreeNode p = getParent();
|
TreeNode p = getParent();
|
||||||
if (p instanceof BookTreeNode) {
|
if (p instanceof BookTreeNode) {
|
||||||
BookTreeNode btn = (BookTreeNode)p;
|
BookTreeNode btn = (BookTreeNode)p;
|
||||||
@@ -502,6 +502,11 @@ public class Book extends BookTreeNode {
|
|||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getLocation(String dir) {
|
||||||
|
Debug.trace();
|
||||||
|
return new File(location, dir);
|
||||||
|
}
|
||||||
|
|
||||||
public void setLocation(File l) {
|
public void setLocation(File l) {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
location = l;
|
location = l;
|
||||||
@@ -589,9 +594,7 @@ public class Book extends BookTreeNode {
|
|||||||
Debug.trace();
|
Debug.trace();
|
||||||
effects = new TreeMap<String,EffectGroup>();
|
effects = new TreeMap<String,EffectGroup>();
|
||||||
loadEffectsFromFolder(new File(Options.get("path.storage"), "System"));
|
loadEffectsFromFolder(new File(Options.get("path.storage"), "System"));
|
||||||
if (location != null) {
|
loadEffectsFromFolder(getLocation());
|
||||||
loadEffectsFromFolder(location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadEffectsFromFolder(File dir) {
|
public void loadEffectsFromFolder(File dir) {
|
||||||
|
|||||||
@@ -8,15 +8,18 @@ public class CacheManager {
|
|||||||
static int cacheSize = 10;
|
static int cacheSize = 10;
|
||||||
|
|
||||||
public static void addToCache(Cacheable c) {
|
public static void addToCache(Cacheable c) {
|
||||||
|
Debug.trace();
|
||||||
while (cache.size() >= cacheSize) {
|
while (cache.size() >= cacheSize) {
|
||||||
Cacheable ob = cache.remove(0);
|
Cacheable ob = cache.remove(0);
|
||||||
if (ob.lockedInCache()) {
|
if (ob != null) {
|
||||||
cache.add(ob);
|
if (ob.lockedInCache()) {
|
||||||
} else {
|
cache.add(ob);
|
||||||
if (ob instanceof Sentence) {
|
} else {
|
||||||
Sentence s = (Sentence)ob;
|
if (ob instanceof Sentence) {
|
||||||
|
Sentence s = (Sentence)ob;
|
||||||
|
}
|
||||||
|
ob.clearCache();
|
||||||
}
|
}
|
||||||
ob.clearCache();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,6 +31,7 @@ public class CacheManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void removeFromCache(Cacheable c) {
|
public static void removeFromCache(Cacheable c) {
|
||||||
|
Debug.trace();
|
||||||
if (c instanceof Sentence) {
|
if (c instanceof Sentence) {
|
||||||
Sentence s = (Sentence)c;
|
Sentence s = (Sentence)c;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,12 +172,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
|
|
||||||
Book book = getBook();
|
Book book = getBook();
|
||||||
|
|
||||||
File bookRoot = new File(Options.get("path.storage"), book.getName());
|
File export = book.getLocation("export");
|
||||||
if (!bookRoot.exists()) {
|
|
||||||
bookRoot.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
File export = new File(bookRoot, "export");
|
|
||||||
if (!export.exists()) {
|
if (!export.exists()) {
|
||||||
export.mkdirs();
|
export.mkdirs();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,6 +235,11 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
peak = Utils.s2d(Book.getTextNode(root, "peak", "-1.000"));
|
peak = Utils.s2d(Book.getTextNode(root, "peak", "-1.000"));
|
||||||
isDetected = Utils.s2b(Book.getTextNode(root, "detected"));
|
isDetected = Utils.s2b(Book.getTextNode(root, "detected"));
|
||||||
|
|
||||||
|
if (sampleSize == 0) {
|
||||||
|
loadFile();
|
||||||
|
autoTrimSample();
|
||||||
|
}
|
||||||
|
|
||||||
gainPoints = new TreeMap<Integer, Double>();
|
gainPoints = new TreeMap<Integer, Double>();
|
||||||
Element gp = Book.getNode(root, "gainpoints");
|
Element gp = Book.getNode(root, "gainpoints");
|
||||||
if (gp != null) {
|
if (gp != null) {
|
||||||
@@ -580,7 +585,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
Debug.d("Get file for", id);
|
Debug.d("Get file for", id);
|
||||||
Book book = getBook();
|
Book book = getBook();
|
||||||
if (book == null) return null;
|
if (book == null) return null;
|
||||||
File b = new File(book.getLocation(), "files");
|
File b = book.getLocation("files");
|
||||||
if (!b.exists()) {
|
if (!b.exists()) {
|
||||||
b.mkdirs();
|
b.mkdirs();
|
||||||
}
|
}
|
||||||
@@ -589,7 +594,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
|
|
||||||
public File getTempFile() {
|
public File getTempFile() {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
File b = new File(getBook().getLocation(), "files");
|
File b = getBook().getLocation("files");
|
||||||
if (!b.exists()) {
|
if (!b.exists()) {
|
||||||
b.mkdirs();
|
b.mkdirs();
|
||||||
}
|
}
|
||||||
@@ -803,7 +808,9 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
|
|
||||||
public boolean lockedInCache() {
|
public boolean lockedInCache() {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
return id.equals("room-noise");
|
if (id.equals("room-noise")) return true;
|
||||||
|
if (isProcessing()) return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findNearestZeroCrossing(int pos, int range) {
|
public int findNearestZeroCrossing(int pos, int range) {
|
||||||
@@ -976,12 +983,22 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
int targetLow = Options.getInteger("audio.recording.rms.low");
|
int targetLow = Options.getInteger("audio.recording.rms.low");
|
||||||
int targetHigh = Options.getInteger("audio.recording.rms.high");
|
int targetHigh = Options.getInteger("audio.recording.rms.high");
|
||||||
|
|
||||||
|
long ts = System.currentTimeMillis();
|
||||||
while ((int)getRMS() < targetLow) {
|
while ((int)getRMS() < targetLow) {
|
||||||
|
if (System.currentTimeMillis() - ts > 10000) {
|
||||||
|
System.err.println("Aborted gain boost: took too long");
|
||||||
|
return gain;
|
||||||
|
}
|
||||||
setGain(gain + 0.1);
|
setGain(gain + 0.1);
|
||||||
if (gain >= 10.0d) break;
|
if (gain >= 10.0d) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ts = System.currentTimeMillis();
|
||||||
while ((int)getRMS() > targetHigh) {
|
while ((int)getRMS() > targetHigh) {
|
||||||
|
if (System.currentTimeMillis() - ts > 10000) {
|
||||||
|
System.err.println("Aborted gain cut: took too long");
|
||||||
|
return gain;
|
||||||
|
}
|
||||||
setGain(gain - 0.1);
|
setGain(gain - 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1466,11 +1483,11 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
|
|
||||||
synchronized public double[][] getProcessedAudioData(boolean effectsEnabled, boolean applyGain) {
|
synchronized public double[][] getProcessedAudioData(boolean effectsEnabled, boolean applyGain) {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
Book book = getBook();
|
|
||||||
loadFile();
|
|
||||||
if (processedAudio != null) {
|
if (processedAudio != null) {
|
||||||
return processedAudio;
|
return processedAudio;
|
||||||
}
|
}
|
||||||
|
Book book = getBook();
|
||||||
|
loadFile();
|
||||||
|
|
||||||
if (audioData == null) return null;
|
if (audioData == null) return null;
|
||||||
processedAudio = new double[2][audioData[LEFT].length];
|
processedAudio = new double[2][audioData[LEFT].length];
|
||||||
@@ -1497,7 +1514,12 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
eff = book.effects.get(effectChain);
|
eff = book.effects.get(effectChain);
|
||||||
if (eff != null) {
|
if (eff != null) {
|
||||||
eff.init(getAudioFormat().getFrameRate());
|
eff.init(getAudioFormat().getFrameRate());
|
||||||
eff.process(processedAudio);
|
// There is a chance another thread could cripple the audio data cache
|
||||||
|
// so we'll just ignore any errors here.
|
||||||
|
try {
|
||||||
|
eff.process(processedAudio);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1741,6 +1763,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
Debug.trace();
|
Debug.trace();
|
||||||
AudiobookRecorder.setSelectedSentence(this);
|
AudiobookRecorder.setSelectedSentence(this);
|
||||||
AudiobookRecorder.window.setSentenceNotes(notes);
|
AudiobookRecorder.window.setSentenceNotes(notes);
|
||||||
|
AudiobookRecorder.window.showSelectedEffectChain(getEffectChain());
|
||||||
TreeNode p = getParent();
|
TreeNode p = getParent();
|
||||||
if (p instanceof BookTreeNode) {
|
if (p instanceof BookTreeNode) {
|
||||||
BookTreeNode btn = (BookTreeNode)p;
|
BookTreeNode btn = (BookTreeNode)p;
|
||||||
@@ -1880,6 +1903,10 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void adjustGainPoint(Integer loc, Double adj) {
|
public void adjustGainPoint(Integer loc, Double adj) {
|
||||||
|
adjustGainPoint(loc, adj, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adjustGainPoint(Integer loc, Double adj, boolean reload) {
|
||||||
if (gainPoints == null) {
|
if (gainPoints == null) {
|
||||||
gainPoints = new TreeMap<Integer, Double>();
|
gainPoints = new TreeMap<Integer, Double>();
|
||||||
return;
|
return;
|
||||||
@@ -1888,7 +1915,9 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
if (gp == null) return;
|
if (gp == null) return;
|
||||||
gp += adj;
|
gp += adj;
|
||||||
gainPoints.put(loc, gp);
|
gainPoints.put(loc, gp);
|
||||||
refreshAllData();
|
if (reload) {
|
||||||
|
refreshAllData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double[] calculateGains() {
|
public double[] calculateGains() {
|
||||||
@@ -1913,7 +1942,10 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
double ystep = diff / (double)range;
|
double ystep = diff / (double)range;
|
||||||
for (int x = 0; x < range; x++) {
|
for (int x = 0; x < range; x++) {
|
||||||
y += ystep;
|
y += ystep;
|
||||||
gains[x1 + x] = y;
|
try {
|
||||||
|
gains[x1 + x] = y;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
}
|
}
|
||||||
@@ -2001,6 +2033,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
public double[] getWaveProfile() {
|
public double[] getWaveProfile() {
|
||||||
if (waveProfile != null) return waveProfile;
|
if (waveProfile != null) return waveProfile;
|
||||||
double[][] samples = getProcessedAudioData();
|
double[][] samples = getProcessedAudioData();
|
||||||
|
if (samples[LEFT].length == 0) return null;
|
||||||
waveProfile = new double[samples[LEFT].length];
|
waveProfile = new double[samples[LEFT].length];
|
||||||
|
|
||||||
double rt = 0;
|
double rt = 0;
|
||||||
@@ -2029,6 +2062,11 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
double peak = 0;
|
double peak = 0;
|
||||||
|
|
||||||
|
if (samples == null) {
|
||||||
|
System.err.println("Um.... no samples...?");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < samples[LEFT].length; i++) {
|
for (int i = 0; i < samples[LEFT].length; i++) {
|
||||||
if (Math.abs(samples[LEFT][i]) > peak) {
|
if (Math.abs(samples[LEFT][i]) > peak) {
|
||||||
@@ -2065,13 +2103,52 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int findNearestGainPoint(int pos) {
|
||||||
|
int closest = Integer.MAX_VALUE;
|
||||||
|
int cpos = -1;
|
||||||
|
|
||||||
|
if (gainPoints == null) return -1;
|
||||||
|
|
||||||
|
for (Integer loc : gainPoints.keySet()) {
|
||||||
|
int diff = pos - loc;
|
||||||
|
if (diff < 0) diff = 0 - diff;
|
||||||
|
if (diff < closest) {
|
||||||
|
closest = diff;
|
||||||
|
cpos = loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cpos;
|
||||||
|
}
|
||||||
|
|
||||||
public void autoAddPeakGainPoints() {
|
public void autoAddPeakGainPoints() {
|
||||||
|
long ts = System.currentTimeMillis();
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
if (System.currentTimeMillis() - ts > 10000) {
|
||||||
|
System.err.println("Terminated: running too long!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
processedAudio = null;
|
||||||
double[][] samples = getProcessedAudioData();
|
double[][] samples = getProcessedAudioData();
|
||||||
int pos = findBiggestPeak();
|
int pos = findBiggestPeak();
|
||||||
|
if (pos == -1) return;
|
||||||
|
|
||||||
System.err.println("Biggest peak: " + pos);
|
System.err.println("Biggest peak: " + pos);
|
||||||
|
|
||||||
|
int closest = findNearestGainPoint(pos);
|
||||||
|
if (closest >= 0) {
|
||||||
|
int diff = closest - pos;
|
||||||
|
if (diff < 0) diff = 0 - diff;
|
||||||
|
if (diff < 10) {
|
||||||
|
System.err.println("Readjusting location: " + closest + " - diff = " + diff);
|
||||||
|
pos = closest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((Math.abs(samples[LEFT][pos]) < 0.708) && (Math.abs(samples[RIGHT][pos]) < 0.708)) {
|
if ((Math.abs(samples[LEFT][pos]) < 0.708) && (Math.abs(samples[RIGHT][pos]) < 0.708)) {
|
||||||
System.err.println("Not a peak!");
|
System.err.println("No more peaks");
|
||||||
|
refreshAllData();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2090,8 +2167,21 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
|||||||
addGainPoint(pos, 1d);
|
addGainPoint(pos, 1d);
|
||||||
addGainPoint(end, 1d);
|
addGainPoint(end, 1d);
|
||||||
|
|
||||||
while (isClipping(start, end)) {
|
double val = 1d;
|
||||||
adjustGainPoint(pos, -0.05);
|
|
||||||
|
while (isClipping(pos - 10, pos + 10)) {
|
||||||
|
adjustGainPoint(pos, -0.05, false);
|
||||||
|
val -= 0.05d;
|
||||||
|
if (val < 0.1d) {
|
||||||
|
System.err.println("Aborting: gain too low");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
processedAudio = null; // Force a refresh
|
||||||
|
}
|
||||||
|
System.err.println("Result: " + gainPoints.get(pos));
|
||||||
|
try {
|
||||||
|
Thread.sleep(1);
|
||||||
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user