Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4896ee7a65 | |||
| ce3eb7165a | |||
| 4de00b8fac |
@@ -1 +1 @@
|
||||
version=0.3.2
|
||||
version=0.3.3
|
||||
|
||||
@@ -3,6 +3,7 @@ package uk.co.majenko.audiobookrecorder;
|
||||
import javax.sound.sampled.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.text.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.nio.file.*;
|
||||
@@ -32,6 +33,7 @@ import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -39,7 +41,7 @@ import org.w3c.dom.Element;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
public class AudiobookRecorder extends JFrame {
|
||||
public class AudiobookRecorder extends JFrame implements DocumentListener {
|
||||
|
||||
// Settings - tweakable
|
||||
|
||||
@@ -105,8 +107,17 @@ public class AudiobookRecorder extends JFrame {
|
||||
public Waveform sampleWaveform;
|
||||
JScrollBar sampleScroll;
|
||||
JSplitPane mainSplit;
|
||||
JTextArea notesArea;
|
||||
JScrollPane notesScroll;
|
||||
|
||||
JTabbedPane notesTabs;
|
||||
|
||||
JTextArea bookNotesArea;
|
||||
JScrollPane bookNotesScroll;
|
||||
|
||||
JTextArea chapterNotesArea;
|
||||
JScrollPane chapterNotesScroll;
|
||||
|
||||
JTextArea sentenceNotesArea;
|
||||
JScrollPane sentenceNotesScroll;
|
||||
|
||||
JSpinner postSentenceGap;
|
||||
JSpinner gainPercent;
|
||||
@@ -640,10 +651,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
centralPanel.getActionMap().put("startRecord", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!getLock()) return;
|
||||
if (getFocusOwner() == notesArea) {
|
||||
freeLock();
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||
if (bookTree.isEditing()) {
|
||||
freeLock();
|
||||
return;
|
||||
@@ -659,10 +669,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
centralPanel.getActionMap().put("startRecordShort", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!getLock()) return;
|
||||
if (getFocusOwner() == notesArea) {
|
||||
freeLock();
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||
if (bookTree.isEditing()) {
|
||||
freeLock();
|
||||
return;
|
||||
@@ -678,10 +687,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
centralPanel.getActionMap().put("startRecordNewPara", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!getLock()) return;
|
||||
if (getFocusOwner() == notesArea) {
|
||||
freeLock();
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||
if (bookTree.isEditing()) {
|
||||
freeLock();
|
||||
return;
|
||||
@@ -697,10 +705,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
centralPanel.getActionMap().put("startRecordNewSection", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!getLock()) return;
|
||||
if (getFocusOwner() == notesArea) {
|
||||
freeLock();
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||
if (bookTree.isEditing()) {
|
||||
freeLock();
|
||||
return;
|
||||
@@ -716,10 +723,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
centralPanel.getActionMap().put("startRerecord", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!getLock()) return;
|
||||
if (getFocusOwner() == notesArea) {
|
||||
freeLock();
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||
if (bookTree.isEditing()) {
|
||||
freeLock();
|
||||
return;
|
||||
@@ -734,9 +740,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
});
|
||||
centralPanel.getActionMap().put("stopRecord", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (getFocusOwner() == notesArea) {
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { return; }
|
||||
if (bookTree.isEditing()) return;
|
||||
stopLock();
|
||||
stopRecording();
|
||||
@@ -745,9 +751,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
});
|
||||
centralPanel.getActionMap().put("deleteLast", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (getFocusOwner() == notesArea) {
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { return; }
|
||||
if (bookTree.isEditing()) return;
|
||||
deleteLastRecording();
|
||||
}
|
||||
@@ -755,9 +761,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
centralPanel.getActionMap().put("startStopPlayback", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (getFocusOwner() == notesArea) {
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { return; }
|
||||
if (bookTree.isEditing()) return;
|
||||
if (playing == null) {
|
||||
playSelectedSentence();
|
||||
@@ -769,9 +775,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
centralPanel.getActionMap().put("startPlaybackFrom", new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (getFocusOwner() == notesArea) {
|
||||
return;
|
||||
}
|
||||
if (getFocusOwner() == bookNotesArea) { return; }
|
||||
if (getFocusOwner() == chapterNotesArea) { return; }
|
||||
if (getFocusOwner() == sentenceNotesArea) { return; }
|
||||
if (bookTree.isEditing()) return;
|
||||
if (playing == null) {
|
||||
playFromSelectedSentence();
|
||||
@@ -781,12 +787,30 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
mainScroll = new JScrollPane();
|
||||
|
||||
notesArea = new JTextArea();
|
||||
notesArea.setFont(new Font("Monospaced", Font.PLAIN, 10));
|
||||
notesScroll = new JScrollPane();
|
||||
notesScroll.setViewportView(notesArea);
|
||||
bookNotesArea = new JTextArea();
|
||||
bookNotesArea.setFont(new Font("Monospaced", Font.PLAIN, 10));
|
||||
bookNotesScroll = new JScrollPane();
|
||||
bookNotesScroll.setViewportView(bookNotesArea);
|
||||
|
||||
mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainScroll, notesScroll);
|
||||
chapterNotesArea = new JTextArea();
|
||||
chapterNotesArea.setFont(new Font("Monospaced", Font.PLAIN, 10));
|
||||
chapterNotesArea.getDocument().addDocumentListener(this);
|
||||
chapterNotesScroll = new JScrollPane();
|
||||
chapterNotesScroll.setViewportView(chapterNotesArea);
|
||||
|
||||
sentenceNotesArea = new JTextArea();
|
||||
sentenceNotesArea.setFont(new Font("Monospaced", Font.PLAIN, 10));
|
||||
sentenceNotesArea.getDocument().addDocumentListener(this);
|
||||
sentenceNotesScroll = new JScrollPane();
|
||||
sentenceNotesScroll.setViewportView(sentenceNotesArea);
|
||||
|
||||
notesTabs = new JTabbedPane();
|
||||
|
||||
notesTabs.add("Book", bookNotesScroll);
|
||||
notesTabs.add("Chapter", chapterNotesScroll);
|
||||
notesTabs.add("Phrase", sentenceNotesScroll);
|
||||
|
||||
mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainScroll, notesTabs);
|
||||
centralPanel.add(mainSplit, BorderLayout.CENTER);
|
||||
|
||||
mainSplit.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@@ -949,6 +973,8 @@ public class AudiobookRecorder extends JFrame {
|
||||
// write the content into xml file
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||
DOMSource source = new DOMSource(doc);
|
||||
StreamResult result = new StreamResult(xml);
|
||||
transformer.transform(source, result);
|
||||
@@ -1298,6 +1324,34 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
JMenuObject peaknew = new JMenuObject("Auto-trim new (Peak)", c, new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
Chapter chap = (Chapter)o.getObject();
|
||||
|
||||
ProgressDialog ed = new ProgressDialog("Auto-trimming " + chap.getName());
|
||||
|
||||
AutoTrimThread t = new AutoTrimThread(chap, ed, AutoTrimThread.Peak, AutoTrimThread.NewOnly);
|
||||
Thread nt = new Thread(t);
|
||||
nt.start();
|
||||
ed.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
JMenuObject fftnew = new JMenuObject("Auto-trim new (FFT)", c, new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
Chapter chap = (Chapter)o.getObject();
|
||||
|
||||
ProgressDialog ed = new ProgressDialog("Auto-trimming " + chap.getName());
|
||||
|
||||
AutoTrimThread t = new AutoTrimThread(chap, ed, AutoTrimThread.FFT, AutoTrimThread.NewOnly);
|
||||
Thread nt = new Thread(t);
|
||||
nt.start();
|
||||
ed.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
JMenuObject peak = new JMenuObject("Auto-trim all (Peak)", c, new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
@@ -1305,7 +1359,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
ProgressDialog ed = new ProgressDialog("Auto-trimming " + chap.getName());
|
||||
|
||||
AutoTrimThread t = new AutoTrimThread(chap, ed, AutoTrimThread.Peak);
|
||||
AutoTrimThread t = new AutoTrimThread(chap, ed, AutoTrimThread.Peak, AutoTrimThread.All);
|
||||
Thread nt = new Thread(t);
|
||||
nt.start();
|
||||
ed.setVisible(true);
|
||||
@@ -1319,7 +1373,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
ProgressDialog ed = new ProgressDialog("Auto-trimming " + chap.getName());
|
||||
|
||||
AutoTrimThread t = new AutoTrimThread(chap, ed, AutoTrimThread.FFT);
|
||||
AutoTrimThread t = new AutoTrimThread(chap, ed, AutoTrimThread.FFT, AutoTrimThread.All);
|
||||
Thread nt = new Thread(t);
|
||||
nt.start();
|
||||
ed.setVisible(true);
|
||||
@@ -1512,6 +1566,8 @@ public class AudiobookRecorder extends JFrame {
|
||||
menu.addSeparator();
|
||||
menu.add(mergeWith);
|
||||
menu.addSeparator();
|
||||
menu.add(peaknew);
|
||||
menu.add(fftnew);
|
||||
menu.add(peak);
|
||||
menu.add(fft);
|
||||
menu.addSeparator();
|
||||
@@ -1934,6 +1990,8 @@ public class AudiobookRecorder extends JFrame {
|
||||
// write the content into xml file
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||
DOMSource source = new DOMSource(doc);
|
||||
StreamResult result = new StreamResult(xml);
|
||||
transformer.transform(source, result);
|
||||
@@ -1976,6 +2034,11 @@ public class AudiobookRecorder extends JFrame {
|
||||
bookTree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
DefaultMutableTreeNode n = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (n instanceof BookTreeNode) {
|
||||
BookTreeNode btn = (BookTreeNode)n;
|
||||
btn.onSelect();
|
||||
}
|
||||
|
||||
if (n instanceof Sentence) {
|
||||
Sentence s = (Sentence)n;
|
||||
selectedSentence = s;
|
||||
@@ -2143,6 +2206,11 @@ public class AudiobookRecorder extends JFrame {
|
||||
bookTree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
DefaultMutableTreeNode n = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (n instanceof BookTreeNode) {
|
||||
BookTreeNode btn = (BookTreeNode)n;
|
||||
btn.onSelect();
|
||||
}
|
||||
|
||||
if (n instanceof Sentence) {
|
||||
Sentence s = (Sentence)n;
|
||||
selectedSentence = s;
|
||||
@@ -2478,15 +2546,19 @@ public class AudiobookRecorder extends JFrame {
|
||||
ProgressDialog dialog;
|
||||
Chapter chapter;
|
||||
int type;
|
||||
int scope;
|
||||
|
||||
public final static int FFT = 0;
|
||||
public final static int Peak = 1;
|
||||
public final static int NewOnly = 0;
|
||||
public final static int All = 1;
|
||||
|
||||
public AutoTrimThread(Chapter c, ProgressDialog e, int t) {
|
||||
public AutoTrimThread(Chapter c, ProgressDialog e, int t, int sc) {
|
||||
super();
|
||||
dialog = e;
|
||||
chapter = c;
|
||||
type = t;
|
||||
scope = sc;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -2498,6 +2570,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
kidCount++;
|
||||
dialog.setProgress(kidCount * 2000 / numKids);
|
||||
Sentence snt = (Sentence)s.nextElement();
|
||||
if (scope == NewOnly) {
|
||||
if (snt.isProcessed()) continue;
|
||||
}
|
||||
switch (type) {
|
||||
case FFT:
|
||||
snt.autoTrimSampleFFT();
|
||||
@@ -3687,12 +3762,28 @@ public class AudiobookRecorder extends JFrame {
|
||||
System.err.println("Effects Enabled: " + b);
|
||||
}
|
||||
|
||||
public void setNotes(String text) {
|
||||
notesArea.setText(text);
|
||||
public void setBookNotes(String text) {
|
||||
bookNotesArea.setText(text);
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notesArea.getText();
|
||||
public void setChapterNotes(String text) {
|
||||
chapterNotesArea.setText(text);
|
||||
}
|
||||
|
||||
public void setSentenceNotes(String text) {
|
||||
sentenceNotesArea.setText(text);
|
||||
}
|
||||
|
||||
public String getBookNotes() {
|
||||
return bookNotesArea.getText();
|
||||
}
|
||||
|
||||
public String getChapterNotes() {
|
||||
return chapterNotesArea.getText();
|
||||
}
|
||||
|
||||
public String getSentenceNotes() {
|
||||
return sentenceNotesArea.getText();
|
||||
}
|
||||
|
||||
public void openManuscript() {
|
||||
@@ -3724,4 +3815,74 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
//* DocumentListener
|
||||
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
javax.swing.text.Document doc = e.getDocument();
|
||||
if (doc == chapterNotesArea.getDocument()) {
|
||||
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (selectedNode instanceof Sentence) {
|
||||
selectedNode = (DefaultMutableTreeNode)selectedNode.getParent();
|
||||
}
|
||||
if (! (selectedNode instanceof Chapter)) {
|
||||
return;
|
||||
}
|
||||
Chapter c = (Chapter)selectedNode;
|
||||
c.setNotes(chapterNotesArea.getText());
|
||||
} else if (doc == sentenceNotesArea.getDocument()) {
|
||||
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (! (selectedNode instanceof Sentence)) {
|
||||
return;
|
||||
}
|
||||
Sentence s = (Sentence)selectedNode;
|
||||
s.setNotes(sentenceNotesArea.getText());
|
||||
}
|
||||
}
|
||||
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
javax.swing.text.Document doc = e.getDocument();
|
||||
if (doc == chapterNotesArea.getDocument()) {
|
||||
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (selectedNode instanceof Sentence) {
|
||||
selectedNode = (DefaultMutableTreeNode)selectedNode.getParent();
|
||||
}
|
||||
if (! (selectedNode instanceof Chapter)) {
|
||||
return;
|
||||
}
|
||||
Chapter c = (Chapter)selectedNode;
|
||||
c.setNotes(chapterNotesArea.getText());
|
||||
} else if (doc == sentenceNotesArea.getDocument()) {
|
||||
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (! (selectedNode instanceof Sentence)) {
|
||||
return;
|
||||
}
|
||||
Sentence s = (Sentence)selectedNode;
|
||||
s.setNotes(sentenceNotesArea.getText());
|
||||
}
|
||||
}
|
||||
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
javax.swing.text.Document doc = e.getDocument();
|
||||
if (doc == chapterNotesArea.getDocument()) {
|
||||
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (selectedNode instanceof Sentence) {
|
||||
selectedNode = (DefaultMutableTreeNode)selectedNode.getParent();
|
||||
}
|
||||
if (! (selectedNode instanceof Chapter)) {
|
||||
return;
|
||||
}
|
||||
Chapter c = (Chapter)selectedNode;
|
||||
c.setNotes(chapterNotesArea.getText());
|
||||
} else if (doc == sentenceNotesArea.getDocument()) {
|
||||
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (! (selectedNode instanceof Sentence)) {
|
||||
return;
|
||||
}
|
||||
Sentence s = (Sentence)selectedNode;
|
||||
s.setNotes(sentenceNotesArea.getText());
|
||||
}
|
||||
}
|
||||
|
||||
// DocumentListener *//
|
||||
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Book extends DefaultMutableTreeNode {
|
||||
ACX = getTextNode(root, "acx");
|
||||
manuscript = getTextNode(root, "manuscript");
|
||||
|
||||
AudiobookRecorder.window.setNotes(getTextNode(root, "notes"));
|
||||
AudiobookRecorder.window.setBookNotes(getTextNode(root, "notes"));
|
||||
|
||||
Element settings = getNode(root, "settings");
|
||||
Element audioSettings = getNode(settings, "audio");
|
||||
@@ -306,7 +306,7 @@ public class Book extends DefaultMutableTreeNode {
|
||||
root.appendChild(makeTextNode(doc, "acx", ACX));
|
||||
root.appendChild(makeTextNode(doc, "manuscript", manuscript));
|
||||
|
||||
root.appendChild(makeTextNode(doc, "notes", AudiobookRecorder.window.getNotes()));
|
||||
root.appendChild(makeTextNode(doc, "notes", AudiobookRecorder.window.getBookNotes()));
|
||||
|
||||
Element settingsNode = doc.createElement("settings");
|
||||
root.appendChild(settingsNode);
|
||||
|
||||
20
src/uk/co/majenko/audiobookrecorder/BookTreeNode.java
Normal file
20
src/uk/co/majenko/audiobookrecorder/BookTreeNode.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
public abstract class BookTreeNode extends DefaultMutableTreeNode {
|
||||
|
||||
public BookTreeNode(String t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public BookTreeNode() {
|
||||
super("");
|
||||
}
|
||||
|
||||
public abstract void setNotes(String t);
|
||||
public abstract String getNotes();
|
||||
|
||||
public abstract void onSelect();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
ret.setText(s.getOverrideText());
|
||||
}
|
||||
|
||||
if (!s.isProcessed()) {
|
||||
ret.setForeground(new Color(0x88, 0x88, 0x88));
|
||||
}
|
||||
|
||||
if (s.getAttentionFlag()) {
|
||||
ret.setForeground(new Color(0xFF, 0xFF, 0x00));
|
||||
icn.add(Overlays.attention, OverlayIcon.TOP_LEFT);
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class Chapter extends DefaultMutableTreeNode {
|
||||
public class Chapter extends BookTreeNode {
|
||||
|
||||
String name;
|
||||
String id;
|
||||
@@ -34,6 +34,8 @@ public class Chapter extends DefaultMutableTreeNode {
|
||||
int preGap;
|
||||
int postGap;
|
||||
|
||||
String notes;
|
||||
|
||||
public Chapter(String i, String chaptername) {
|
||||
super(chaptername);
|
||||
|
||||
@@ -49,6 +51,8 @@ public class Chapter extends DefaultMutableTreeNode {
|
||||
id = root.getAttribute("id");
|
||||
preGap = Utils.s2i(Book.getTextNode(root, "pre-gap"));
|
||||
postGap = Utils.s2i(Book.getTextNode(root, "post-gap"));
|
||||
|
||||
notes = Book.getTextNode(root, "notes");
|
||||
|
||||
Element sentencesNode = Book.getNode(root, "sentences");
|
||||
NodeList sentences = sentencesNode.getElementsByTagName("sentence");
|
||||
@@ -284,6 +288,7 @@ public class Chapter extends DefaultMutableTreeNode {
|
||||
chapterNode.appendChild(Book.makeTextNode(doc, "name", name));
|
||||
chapterNode.appendChild(Book.makeTextNode(doc, "pre-gap", preGap));
|
||||
chapterNode.appendChild(Book.makeTextNode(doc, "post-gap", postGap));
|
||||
chapterNode.appendChild(Book.makeTextNode(doc, "notes", notes));
|
||||
|
||||
Element sentencesNode = doc.createElement("sentences");
|
||||
chapterNode.appendChild(sentencesNode);
|
||||
@@ -299,4 +304,16 @@ public class Chapter extends DefaultMutableTreeNode {
|
||||
return chapterNode;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String t) {
|
||||
notes = t;
|
||||
}
|
||||
|
||||
public void onSelect() {
|
||||
AudiobookRecorder.window.setChapterNotes(notes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,10 +41,11 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
public class Sentence extends BookTreeNode implements Cacheable {
|
||||
|
||||
String text;
|
||||
String id;
|
||||
String notes;
|
||||
int postGap;
|
||||
int startOffset = 0;
|
||||
int endOffset = 0;
|
||||
@@ -60,6 +61,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
|
||||
boolean inSample;
|
||||
boolean attention = false;
|
||||
boolean processed = false;
|
||||
|
||||
String effectChain = null;
|
||||
|
||||
@@ -86,20 +88,26 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
|
||||
boolean effectEthereal = false;
|
||||
|
||||
public void setSampleSize(int s) {
|
||||
sampleSize = s;
|
||||
}
|
||||
|
||||
static class RecordingThread implements Runnable {
|
||||
|
||||
boolean running = false;
|
||||
boolean recording = false;
|
||||
Sentence sent = null;
|
||||
|
||||
File tempFile;
|
||||
File wavFile;
|
||||
|
||||
AudioFormat format;
|
||||
|
||||
public RecordingThread(File tf, File wf, AudioFormat af) {
|
||||
public RecordingThread(File tf, File wf, AudioFormat af, Sentence s) {
|
||||
tempFile = tf;
|
||||
wavFile = wf;
|
||||
format = af;
|
||||
sent = s;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
@@ -121,6 +129,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
fos.write(buf, 0, nr);
|
||||
fos.close();
|
||||
|
||||
sent.setSampleSize(len / format.getFrameSize());
|
||||
|
||||
FileInputStream fis = new FileInputStream(tempFile);
|
||||
AudioInputStream ais = new AudioInputStream(fis, format, len / format.getFrameSize());
|
||||
fos = new FileOutputStream(wavFile);
|
||||
@@ -170,6 +180,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
super("");
|
||||
id = root.getAttribute("id");
|
||||
text = Book.getTextNode(root, "text");
|
||||
notes = Book.getTextNode(root, "notes");
|
||||
setUserObject(text);
|
||||
setPostGap(Utils.s2i(Book.getTextNode(root, "post-gap")));
|
||||
setStartOffset(Utils.s2i(Book.getTextNode(root, "start-offset")));
|
||||
@@ -180,6 +191,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
setEffectChain(Book.getTextNode(root, "effect"));
|
||||
setPostGapType(Book.getTextNode(root, "gaptype"));
|
||||
sampleSize = Utils.s2i(Book.getTextNode(root, "samples"));
|
||||
processed = Utils.s2b(Book.getTextNode(root, "processed"));
|
||||
}
|
||||
|
||||
public boolean startRecording() {
|
||||
@@ -190,7 +202,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
|
||||
CacheManager.removeFromCache(this);
|
||||
|
||||
recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat());
|
||||
recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat(), this);
|
||||
|
||||
Thread rc = new Thread(recordingThread);
|
||||
rc.setDaemon(true);
|
||||
@@ -230,6 +242,12 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
autoTrimSamplePeak(useRaw);
|
||||
} else if (tm.equals("fft")) {
|
||||
autoTrimSampleFFT(useRaw);
|
||||
} else {
|
||||
startOffset = 0;
|
||||
crossStartOffset = 0;
|
||||
endOffset = sampleSize - 1;
|
||||
crossEndOffset = sampleSize - 1;
|
||||
processed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +349,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
updateCrossings(useRaw);
|
||||
intens = null;
|
||||
samples = null;
|
||||
|
||||
processed = true;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public void autoTrimSamplePeak() {
|
||||
@@ -387,6 +406,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
if (startOffset < 0) startOffset = 0;
|
||||
if (endOffset >= samples.length) endOffset = samples.length-1;
|
||||
updateCrossings(useRaw);
|
||||
processed = true;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
@@ -396,6 +417,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
public void setText(String t) {
|
||||
overrideText = null;
|
||||
text = t;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
@@ -443,6 +465,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
if (o instanceof String) {
|
||||
String so = (String)o;
|
||||
text = so;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,6 +525,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
if (startOffset != o) {
|
||||
startOffset = o;
|
||||
crossStartOffset = -1;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,6 +541,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
if (endOffset != o) {
|
||||
endOffset = o;
|
||||
crossEndOffset = -1;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,6 +622,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
|
||||
public void setLocked(boolean l) {
|
||||
locked = l;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
@@ -699,6 +725,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
|
||||
public void setAttentionFlag(boolean f) {
|
||||
attention = f;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public boolean getAttentionFlag() {
|
||||
@@ -1298,6 +1325,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
CacheManager.removeFromCache(this);
|
||||
}
|
||||
effectChain = key;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public String getEffectChain() {
|
||||
@@ -1324,6 +1352,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
}
|
||||
}
|
||||
postGapType = t;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public void resetPostGap() {
|
||||
@@ -1391,7 +1420,30 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "effect", getEffectChain()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "gaptype", getPostGapType()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "samples", getSampleSize()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "processed", isProcessed()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "notes", getNotes()));
|
||||
return sentenceNode;
|
||||
}
|
||||
|
||||
public boolean isProcessed() {
|
||||
return processed;
|
||||
}
|
||||
|
||||
public void setProcessed(boolean p) {
|
||||
processed = p;
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
}
|
||||
|
||||
public void setNotes(String n) {
|
||||
notes = n;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void onSelect() {
|
||||
AudiobookRecorder.window.setSentenceNotes(notes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user