Clean up stdout noise

This commit is contained in:
2024-04-07 13:04:16 +01:00
parent c64b17467d
commit 3e84798d88
20 changed files with 46 additions and 134 deletions

View File

@@ -760,7 +760,7 @@ public abstract class AbstractTheme extends MetalTheme {
b = Integer.parseInt(colorProp.substring(p2 + 1));
return new ColorUIResource(r, g, b);
} catch (Exception ex) {
System.out.println("Exception while parsing color: " + colorProp);
System.err.println("Exception while parsing color: " + colorProp);
}
}
return color;
@@ -771,7 +771,7 @@ public abstract class AbstractTheme extends MetalTheme {
try {
val = Integer.parseInt(intProp);
} catch (Exception ex) {
System.out.println("Exception while parsing color: " + intProp);
System.err.println("Exception while parsing color: " + intProp);
}
return val;
}

View File

@@ -45,7 +45,7 @@ public class LazyImageIcon implements Icon {
try {
icon = new ImageIcon(LazyImageIcon.class.getResource(name));
} catch (Throwable t) {
System.out.println("ERROR: loading image " + name + " failed!");
System.err.println("ERROR: loading image " + name + " failed!");
}
}
return icon;

View File

@@ -48,7 +48,7 @@ public class LazyMenuArrowImageIcon implements Icon {
try {
leftToRightIcon = new ImageIcon(LazyMenuArrowImageIcon.class.getResource(leftToRightName));
} catch (Throwable t) {
System.out.println("ERROR: loading image " + leftToRightName + " failed!");
System.err.println("ERROR: loading image " + leftToRightName + " failed!");
}
}
return leftToRightIcon;
@@ -59,7 +59,7 @@ public class LazyMenuArrowImageIcon implements Icon {
try {
rightToLeftIcon = new ImageIcon(LazyMenuArrowImageIcon.class.getResource(rightToLefttName));
} catch (Throwable t) {
System.out.println("ERROR: loading image " + rightToLefttName + " failed!");
System.err.println("ERROR: loading image " + rightToLefttName + " failed!");
}
}
return rightToLeftIcon;

View File

@@ -63,11 +63,6 @@ public class AGC implements Effect {
gain = 1d;
}
public void dump() {
Debug.trace();
System.out.println(toString());
}
public ArrayList<Effect> getChildEffects() {
Debug.trace();
return null;

View File

@@ -46,11 +46,6 @@ public class Amplifier implements Effect {
return getName();
}
public void dump() {
Debug.trace();
System.out.println(toString());
}
public void init(double sf) {
Debug.trace();
}

View File

@@ -1104,10 +1104,10 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
newbook.setComment(info.getComment().trim());
newbook.setACX(info.getACX().trim());
Chapter caud = new Chapter("audition", "Audition");
Chapter copen = new Chapter("open", "Opening Credits");
Chapter cclose = new Chapter("close", "Closing Credits");
Chapter cone = new Chapter(UUID.randomUUID().toString(), "Chapter 1");
Chapter caud = new Chapter(newbook, "audition", "Audition");
Chapter copen = new Chapter(newbook, "open", "Opening Credits");
Chapter cclose = new Chapter(newbook, "close", "Closing Credits");
Chapter cone = new Chapter(newbook, UUID.randomUUID().toString(), "Chapter 1");
newbook.add(caud);
newbook.add(copen);
@@ -1345,7 +1345,8 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
JMenuObject o = (JMenuObject)e.getSource();
Sentence s = (Sentence)o.getObject();
Chapter c = (Chapter)s.getParent();
Sentence newSentence = new Sentence();
Book b = c.getBook();
Sentence newSentence = new Sentence(b);
int where = bookTreeModel.getIndexOfChild(c, s);
bookTreeModel.insertNodeInto(newSentence, c, where);
bookTreeModel.reload(newSentence);
@@ -1358,7 +1359,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
JMenuObject o = (JMenuObject)e.getSource();
Sentence s = (Sentence)o.getObject();
Chapter c = (Chapter)s.getParent();
Sentence newSentence = new Sentence();
Sentence newSentence = new Sentence(c.getBook());
int where = bookTreeModel.getIndexOfChild(c, s);
bookTreeModel.insertNodeInto(newSentence, c, where + 1);
bookTreeModel.reload(newSentence);
@@ -2001,8 +2002,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
lastSentence.setPostGapType("continuation");
}
Sentence s = new Sentence();
s.setParentBook(getBook());
Sentence s = new Sentence(getBook());
bookTreeModel.insertNodeInto(s, c, c.getChildCount());
bookTree.expandPath(new TreePath(c.getPath()));
@@ -2053,8 +2053,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
lastSentence.setPostGapType("paragraph");
}
Sentence s = new Sentence();
s.setParentBook(getBook());
Sentence s = new Sentence(getBook());
bookTreeModel.insertNodeInto(s, c, c.getChildCount());
bookTree.expandPath(new TreePath(c.getPath()));
@@ -2104,8 +2103,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
lastSentence.setPostGapType("section");
}
Sentence s = new Sentence();
s.setParentBook(getBook());
Sentence s = new Sentence(getBook());
bookTreeModel.insertNodeInto(s, c, c.getChildCount());
bookTree.expandPath(new TreePath(c.getPath()));
@@ -2155,8 +2153,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
lastSentence.setPostGapType("sentence");
}
Sentence s = new Sentence();
s.setParentBook(getBook());
Sentence s = new Sentence(getBook());
bookTreeModel.insertNodeInto(s, c, c.getChildCount());
bookTree.expandPath(new TreePath(c.getPath()));
@@ -2284,14 +2281,14 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
}
public Chapter convertChapter(String name, String id, Properties data) {
Chapter c = new Chapter(id, data.getProperty("chapter." + name + ".name"));
Chapter c = new Chapter(getBook(), id, data.getProperty("chapter." + name + ".name"));
for (int i = 0; i < 100000000; i++) {
String sid = data.getProperty(String.format("chapter." + name + ".sentence.%08d.id", i));
String text = data.getProperty(String.format("chapter." + name + ".sentence.%08d.text", i));
int gap = Utils.s2i(data.getProperty(String.format("chapter." + name + ".sentence.%08d.post-gap", i)));
if (sid == null) break;
Sentence s = new Sentence(sid, text);
Sentence s = new Sentence(c.getBook(), sid, text);
s.setPostGap(gap);
s.setStartOffset(Utils.s2i(data.getProperty(String.format("chapter." + name + ".sentence.%08d.start-offset", i))));
s.setEndOffset(Utils.s2i(data.getProperty(String.format("chapter. " + name + ".sentence.%08d.end-offset", i))));
@@ -2435,15 +2432,12 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
sampleWaveform.setPlayMarker(pos / format.getFrameSize());
int l = data.length - pos;
if (l > blockSize) l = blockSize;
System.out.println(play.write(data, pos, l));
}
System.out.println("Closing...");
play.drain();
play.stop();
play.close();
play = null;
System.out.println("Closed");
playing = null;
} catch (Exception e) {
e.printStackTrace();
@@ -2691,10 +2685,8 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
public void stopPlaying() {
Debug.trace();
if (play != null) {
System.out.println("Forcing close");
play.close();
play = null;
System.out.println("Closed!!!");
}
playing = null;
}
@@ -2785,8 +2777,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
Chapter fc = (Chapter)from.getFirstChild();
Chapter tc = findChapter(to, fc.getId(), fc.getName());
if (tc == null) {
tc = new Chapter(fc.getId(), fc.getName());
tc.setParentBook(to);
tc = new Chapter(to, fc.getId(), fc.getName());
to.add(tc);
}
moveSentences(fc, tc);
@@ -3434,7 +3425,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
public void findOrphans(Book book) {
Chapter orphans = book.getChapterById("orphans");
if (orphans == null) {
orphans = new Chapter("orphans", "Orphan Files");
orphans = new Chapter(book, "orphans", "Orphan Files");
orphans.setParentBook(book);
book.add(orphans);
}
@@ -3449,7 +3440,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
String id = filename.substring(0, filename.length() - 4);
Debug.d("Testing orphanicity of", id);
if (!sentenceIdExists(book, id)) {
Sentence newSentence = new Sentence(id, id);
Sentence newSentence = new Sentence(book, id, id);
newSentence.setParentBook(book);
orphans.add(newSentence);
}
@@ -3644,7 +3635,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
Book book = c.getBook();
AudioFormat targetFormat = book.getAudioFormat();
Sentence newSentence = new Sentence();
Sentence newSentence = new Sentence(book);
newSentence.setText(f.getName());
newSentence.setParentBook(book);
c.add(newSentence);

View File

@@ -259,8 +259,4 @@ public class Biquad implements Effect {
return getName();
}
public void dump() {
Debug.trace();
System.out.println(toString());
}
}

View File

@@ -64,7 +64,7 @@ public class Book extends BookTreeNode {
location = new File(Options.get("path.storage"), sanitize(name));
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name); // This should be in the load routine!!!!
setIcon(Icons.book);
roomNoise = new Sentence("room-noise", "Room Noise");
roomNoise = new Sentence(this, "room-noise", "Room Noise");
roomNoise.setParentBook(this);
loadEffects();
}
@@ -118,14 +118,14 @@ public class Book extends BookTreeNode {
setIcon(Icons.book);
}
roomNoise = new Sentence("room-noise", "Room Noise");
roomNoise = new Sentence(this, "room-noise", "Room Noise");
roomNoise.setParentBook(this);
Element chapters = getNode(root, "chapters");
NodeList chapterList = chapters.getElementsByTagName("chapter");
for (int i = 0; i < chapterList.getLength(); i++) {
Element chapterElement = (Element)chapterList.item(i);
Chapter newChapter = new Chapter(chapterElement);
Chapter newChapter = new Chapter(this, chapterElement);
newChapter.setParentBook(this);
add(newChapter);
}
@@ -160,12 +160,12 @@ public class Book extends BookTreeNode {
NodeList chapterList = chapters.getElementsByTagName("chapter");
roomNoise = new Sentence("room-noise", "Room Noise");
roomNoise = new Sentence(this, "room-noise", "Room Noise");
roomNoise.setParentBook(this);
for (int i = 0; i < chapterList.getLength(); i++) {
Element chapterElement = (Element)chapterList.item(i);
Chapter newChapter = new Chapter(chapterElement, model);
Chapter newChapter = new Chapter(this, chapterElement, model);
model.insertNodeInto(newChapter, this, getChildCount());
}
}
@@ -259,7 +259,7 @@ public class Book extends BookTreeNode {
public Chapter addChapter() {
Debug.trace();
String uuid = UUID.randomUUID().toString();
Chapter c = new Chapter(uuid, uuid);
Chapter c = new Chapter(this, uuid, uuid);
add(c);
c.setParentBook(this);
return c;
@@ -268,7 +268,7 @@ public class Book extends BookTreeNode {
public Chapter addChapter(String name) {
Debug.trace();
String uuid = UUID.randomUUID().toString();
Chapter c = new Chapter(uuid, name);
Chapter c = new Chapter(this, uuid, name);
add(c);
c.setParentBook(this);
return c;
@@ -276,7 +276,7 @@ public class Book extends BookTreeNode {
public Chapter addChapter(String id, String name) {
Debug.trace();
Chapter c = new Chapter(id, name);
Chapter c = new Chapter(this, id, name);
add(c);
c.setParentBook(this);
return c;

View File

@@ -34,10 +34,6 @@ public class Chain implements Effect {
return "Chain to " + target;
}
public void dump() {
System.out.println(toString());
}
public void init(double sf) {
if (target != null) {
Effect t = AudiobookRecorder.window.getBook().effects.get(target);

View File

@@ -54,15 +54,17 @@ public class Chapter extends BookTreeNode {
String notes;
Book parentBook = null;
public Chapter(String i, String chaptername) {
public Chapter(Book p, String i, String chaptername) {
super(chaptername);
parentBook = p;
Debug.trace();
id = i;
name = chaptername;
}
public Chapter(Element root, DefaultTreeModel model) {
public Chapter(Book p, Element root, DefaultTreeModel model) {
Debug.trace();
parentBook = p;
name = Book.getTextNode(root, "name");
id = root.getAttribute("id");
@@ -73,13 +75,14 @@ public class Chapter extends BookTreeNode {
for (int i = 0; i < sentences.getLength(); i++) {
Element sentenceElement = (Element)sentences.item(i);
Sentence newSentence = new Sentence(sentenceElement);
Sentence newSentence = new Sentence(parentBook, sentenceElement);
model.insertNodeInto(newSentence, this, getChildCount());
}
}
public Chapter(Element root) {
public Chapter(Book p, Element root) {
Debug.trace();
parentBook = p;
name = Book.getTextNode(root, "name");
id = root.getAttribute("id");
@@ -90,7 +93,7 @@ public class Chapter extends BookTreeNode {
for (int i = 0; i < sentences.getLength(); i++) {
Element sentenceElement = (Element)sentences.item(i);
Sentence newSentence = new Sentence(sentenceElement);
Sentence newSentence = new Sentence(parentBook, sentenceElement);
add(newSentence);
}
}

View File

@@ -40,10 +40,6 @@ public class Clipping implements Effect {
return getName();
}
public void dump() {
System.out.println(toString());
}
public void init(double sf) {
}
}

View File

@@ -72,13 +72,6 @@ public class DelayLine implements Effect {
return getName();
}
public void dump() {
System.out.println(toString());
for (DelayLineStore s : delayLines) {
s.dump();
}
}
public void init(double sf) {
for (DelayLineStore s : delayLines) {
s.init(sf);

View File

@@ -68,11 +68,4 @@ public class DelayLineStore {
e.init(sf);
}
}
public void dump() {
System.out.println(" Samples: " + numSamples + ", gain: " + gain);
for (Effect e : effects) {
e.dump();
}
}
}

View File

@@ -6,7 +6,6 @@ public interface Effect {
public void process(double[][] samples);
public String getName();
public ArrayList<Effect> getChildEffects();
public void dump();
public void init(double sr);
public String toString();
}

View File

@@ -58,13 +58,6 @@ public class EffectGroup implements Effect {
return name;
}
public void dump() {
System.out.println(toString() + " >> ");
for (Effect e : effects) {
e.dump();
}
}
public void init(double sf) {
for (Effect e : effects) {
e.init(sf);

View File

@@ -7,7 +7,7 @@ public class FFT {
double ld = Math.log(n) / Math.log(2.0);
if (((int) ld) - ld != 0) {
System.out.println("The number of elements is not a power of 2.");
System.err.println("The number of elements is not a power of 2.");
return null;
}

View File

@@ -83,10 +83,6 @@ public class LFO implements Effect {
public ArrayList<Effect> getChildEffects() { return null; }
public void dump() {
System.out.println(getName());
}
public void init(double sr) {
sampleRate = sr;

View File

@@ -54,19 +54,8 @@ public class Options extends JDialog {
JComboBox<KVPair> playbackBlockSize;
JTextField storageFolder;
JTextField archiveFolder;
JSpinner preChapterGap;
JSpinner postChapterGap;
JSpinner postSentenceGap;
JSpinner shortSentenceGap;
JSpinner postParagraphGap;
JSpinner postSectionGap;
JSpinner rmsLow;
JSpinner rmsHigh;
JCheckBox autoNormalize;
JTextField ffmpegLocation;
JComboBox<KVPair> bitRate;
JComboBox<KVPair> channels;
JComboBox<KVPair> exportRate;
JCheckBox enableParsing;
JSpinner cacheSize;
@@ -363,8 +352,6 @@ public class Options extends JDialog {
trimMethod = addDropdown(optionsPanel, "Auto-trim method:", getTrimMethods(), get("audio.recording.trim"), "None: don't auto-trim. FFT: Compare the FFT profile of blocks to the room noise profile and trim silent blocks, Peak: Look for the start and end rise and fall points");
fftThreshold = addSpinner(optionsPanel, "FFT threshold:", 0, 100, 1, getInteger("audio.recording.trim.fft"), "", "This specifies the difference (in hundredths) between the power of FFT buckets in a sample block compared to the overall power of the same FFT bucket in the room noise. Raising this number makes the FFT trimming less sensitive.");
fftBlockSize = addDropdown(optionsPanel, "FFT Block size:", getFFTBlockSizes(), get("audio.recording.trim.blocksize"), "How large an FFT block should be when processing. Larger values increase sensitivity but at the epxense of resolution.");
rmsLow = addSpinner(optionsPanel, "Target RMS (low):", -100, 0, 1, getInteger("audio.recording.rms.low"), "", "When normalizing this is the lowest target average RMS to aim for");
rmsHigh = addSpinner(optionsPanel, "Target RMS (high):", -100, 0, 1, getInteger("audio.recording.rms.high"), "", "When normalizing this is the highest target average RMS to aim for");
autoNormalize = addCheckBox(optionsPanel, "Enable automatic normalization", getBoolean("process.normalize"), "This will automatically normalize each phrase after recording");
addSeparator(optionsPanel);
@@ -591,16 +578,7 @@ public class Options extends JDialog {
defaultPrefs.put("audio.recording.trim.blocksize", "4096");
defaultPrefs.put("audio.playback.blocksize", "4096");
defaultPrefs.put("catenation.pre-chapter", "1000");
defaultPrefs.put("catenation.post-chapter", "1500");
defaultPrefs.put("catenation.post-sentence", "1000");
defaultPrefs.put("catenation.short-sentence", "100");
defaultPrefs.put("catenation.post-paragraph", "2000");
defaultPrefs.put("catenation.post-section", "3000");
defaultPrefs.put("audio.recording.trim.fft", "10");
defaultPrefs.put("audio.recording.rms.low", "-22");
defaultPrefs.put("audio.recording.rms.high", "-20");
defaultPrefs.put("process.normalize", "true");
defaultPrefs.put("path.storage", (new File(System.getProperty("user.home"), "Recordings")).toString());
@@ -723,15 +701,6 @@ public class Options extends JDialog {
set("path.storage", storageFolder.getText());
set("path.archive", archiveFolder.getText());
set("path.ffmpeg", ffmpegLocation.getText());
set("catenation.pre-chapter", preChapterGap.getValue());
set("catenation.post-chapter", postChapterGap.getValue());
set("catenation.post-sentence", postSentenceGap.getValue());
set("catenation.short-sentence", shortSentenceGap.getValue());
set("catenation.post-paragraph", postParagraphGap.getValue());
set("catenation.post-section", postSectionGap.getValue());
if (bitRate.getSelectedItem() != null) set("audio.export.bitrate", ((KVPair)bitRate.getSelectedItem()).key);
if (channels.getSelectedItem() != null) set("audio.export.channels", ((KVPair)channels.getSelectedItem()).key);
if (exportRate.getSelectedItem() != null) set("audio.export.samplerate", ((KVPair)exportRate.getSelectedItem()).key);
set("narrator.name", narratorName.getText());
set("narrator.initials", narratorInitials.getText());
set("process.sphinx", enableParsing.isSelected());
@@ -740,8 +709,6 @@ public class Options extends JDialog {
set("editor.external", externalEditor.getText());
set("cache.size", cacheSize.getValue());
set("audio.recording.trim.fft", fftThreshold.getValue());
set("audio.recording.rms.low", rmsLow.getValue());
set("audio.recording.rms.high", rmsHigh.getValue());
set("process.normalize", autoNormalize.isSelected());
if (fftBlockSize.getSelectedItem() != null) set("audio.recording.trim.blocksize", ((KVPair)fftBlockSize.getSelectedItem()).key);
if (playbackBlockSize.getSelectedItem() != null) set("audio.playback.blocksize", ((KVPair)playbackBlockSize.getSelectedItem()).key);

View File

@@ -43,10 +43,6 @@ public class Pan implements Effect {
return getName();
}
public void dump() {
System.out.println(toString());
}
public void init(double sf) {
}
}

View File

@@ -192,25 +192,28 @@ public class Sentence extends BookTreeNode implements Cacheable {
}
}
public Sentence() {
public Sentence(Book p) {
super("");
Debug.trace();
parentBook = p;
id = UUID.randomUUID().toString();
text = id;
setUserObject(text);
}
public Sentence(String i, String t) {
public Sentence(Book p, String i, String t) {
super("");
parentBook = p;
Debug.trace();
id = i;
text = t;
setUserObject(text);
}
public Sentence(Element root) {
public Sentence(Book p, Element root) {
super("");
Debug.trace();
parentBook = p;
id = root.getAttribute("id");
text = Book.getTextNode(root, "text");
notes = Book.getTextNode(root, "notes");
@@ -896,7 +899,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
public Sentence cloneSentence() throws IOException {
Debug.trace();
Sentence sentence = new Sentence();
Sentence sentence = new Sentence(getBook());
sentence.setParentBook(getBook());
sentence.setPostGap(getPostGap());
if (!id.equals(text)) {