Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4896ee7a65 | |||
| ce3eb7165a | |||
| 4de00b8fac | |||
| ebe777bdc5 | |||
| 3b5cacb8ad | |||
| db7d297dbc | |||
| 2f9abf7629 | |||
| b6063d2fed | |||
| e1f566f0c8 | |||
| 9fa892a6fd | |||
| 1572e163ef |
@@ -1 +1 @@
|
|||||||
version=0.3.0
|
version=0.3.3
|
||||||
|
|||||||
BIN
resources/uk/co/majenko/audiobookrecorder/icons/manuscript.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/manuscript.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -3,6 +3,7 @@ package uk.co.majenko.audiobookrecorder;
|
|||||||
import javax.sound.sampled.*;
|
import javax.sound.sampled.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.*;
|
import javax.swing.event.*;
|
||||||
|
import javax.swing.text.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
@@ -32,11 +33,15 @@ import javax.xml.transform.Transformer;
|
|||||||
import javax.xml.transform.TransformerFactory;
|
import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import javax.xml.transform.OutputKeys;
|
||||||
import org.w3c.dom.Attr;
|
import org.w3c.dom.Attr;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
public class AudiobookRecorder extends JFrame {
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
|
||||||
|
public class AudiobookRecorder extends JFrame implements DocumentListener {
|
||||||
|
|
||||||
// Settings - tweakable
|
// Settings - tweakable
|
||||||
|
|
||||||
@@ -75,6 +80,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
JMenuItem toolsMerge;
|
JMenuItem toolsMerge;
|
||||||
JMenuItem toolsArchive;
|
JMenuItem toolsArchive;
|
||||||
JMenuItem toolsCoverArt;
|
JMenuItem toolsCoverArt;
|
||||||
|
JMenuItem toolsManuscript;
|
||||||
JMenuItem toolsOptions;
|
JMenuItem toolsOptions;
|
||||||
|
|
||||||
JMenuItem helpAbout;
|
JMenuItem helpAbout;
|
||||||
@@ -100,6 +106,18 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
JPanel sampleControl;
|
JPanel sampleControl;
|
||||||
public Waveform sampleWaveform;
|
public Waveform sampleWaveform;
|
||||||
JScrollBar sampleScroll;
|
JScrollBar sampleScroll;
|
||||||
|
JSplitPane mainSplit;
|
||||||
|
|
||||||
|
JTabbedPane notesTabs;
|
||||||
|
|
||||||
|
JTextArea bookNotesArea;
|
||||||
|
JScrollPane bookNotesScroll;
|
||||||
|
|
||||||
|
JTextArea chapterNotesArea;
|
||||||
|
JScrollPane chapterNotesScroll;
|
||||||
|
|
||||||
|
JTextArea sentenceNotesArea;
|
||||||
|
JScrollPane sentenceNotesScroll;
|
||||||
|
|
||||||
JSpinner postSentenceGap;
|
JSpinner postSentenceGap;
|
||||||
JSpinner gainPercent;
|
JSpinner gainPercent;
|
||||||
@@ -286,6 +304,13 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
toolsManuscript = new JMenuItem("Import Manuscript...");
|
||||||
|
toolsManuscript.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
loadManuscript();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
toolsOptions = new JMenuItem("Options");
|
toolsOptions = new JMenuItem("Options");
|
||||||
toolsOptions.addActionListener(new ActionListener() {
|
toolsOptions.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@@ -296,6 +321,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
toolsMenu.add(toolsMerge);
|
toolsMenu.add(toolsMerge);
|
||||||
toolsMenu.add(toolsArchive);
|
toolsMenu.add(toolsArchive);
|
||||||
toolsMenu.add(toolsCoverArt);
|
toolsMenu.add(toolsCoverArt);
|
||||||
|
toolsMenu.add(toolsManuscript);
|
||||||
toolsMenu.addSeparator();
|
toolsMenu.addSeparator();
|
||||||
toolsMenu.add(toolsOptions);
|
toolsMenu.add(toolsOptions);
|
||||||
|
|
||||||
@@ -557,11 +583,11 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
controlsTop.add(attention);
|
controlsTop.add(attention);
|
||||||
|
|
||||||
controlsTop.add(Box.createHorizontalGlue());
|
controlsTop.add(Box.createHorizontalGlue());
|
||||||
controlsTop.add(new JLabel("Post gap:"));
|
controlsTop.add(new JLabel(" Post gap:"));
|
||||||
controlsTop.add(postSentenceGap);
|
controlsTop.add(postSentenceGap);
|
||||||
controlsTop.add(new JLabel("ms"));
|
controlsTop.add(new JLabel("ms "));
|
||||||
|
|
||||||
controlsTop.add(new JLabel("Gain:"));
|
controlsTop.add(new JLabel(" Gain:"));
|
||||||
controlsTop.add(gainPercent);
|
controlsTop.add(gainPercent);
|
||||||
controlsTop.add(new JLabel("%"));
|
controlsTop.add(new JLabel("%"));
|
||||||
|
|
||||||
@@ -621,29 +647,13 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
buildToolbar(centralPanel);
|
buildToolbar(centralPanel);
|
||||||
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F"), "startRecordShort");
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released F"), "stopRecord");
|
|
||||||
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("R"), "startRecord");
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released R"), "stopRecord");
|
|
||||||
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("T"), "startRecordNewPara");
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released T"), "stopRecord");
|
|
||||||
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Y"), "startRecordNewSection");
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released Y"), "stopRecord");
|
|
||||||
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released D"), "deleteLast");
|
|
||||||
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("SPACE"), "startStopPlayback");
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.SHIFT_DOWN_MASK), "startPlaybackFrom");
|
|
||||||
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("E"), "startRerecord");
|
|
||||||
centralPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released E"), "stopRecord");
|
|
||||||
|
|
||||||
centralPanel.getActionMap().put("startRecord", new AbstractAction() {
|
centralPanel.getActionMap().put("startRecord", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (!getLock()) return;
|
if (!getLock()) return;
|
||||||
|
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||||
if (bookTree.isEditing()) {
|
if (bookTree.isEditing()) {
|
||||||
freeLock();
|
freeLock();
|
||||||
return;
|
return;
|
||||||
@@ -659,6 +669,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
centralPanel.getActionMap().put("startRecordShort", new AbstractAction() {
|
centralPanel.getActionMap().put("startRecordShort", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (!getLock()) return;
|
if (!getLock()) return;
|
||||||
|
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||||
if (bookTree.isEditing()) {
|
if (bookTree.isEditing()) {
|
||||||
freeLock();
|
freeLock();
|
||||||
return;
|
return;
|
||||||
@@ -674,6 +687,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
centralPanel.getActionMap().put("startRecordNewPara", new AbstractAction() {
|
centralPanel.getActionMap().put("startRecordNewPara", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (!getLock()) return;
|
if (!getLock()) return;
|
||||||
|
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||||
if (bookTree.isEditing()) {
|
if (bookTree.isEditing()) {
|
||||||
freeLock();
|
freeLock();
|
||||||
return;
|
return;
|
||||||
@@ -689,6 +705,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
centralPanel.getActionMap().put("startRecordNewSection", new AbstractAction() {
|
centralPanel.getActionMap().put("startRecordNewSection", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (!getLock()) return;
|
if (!getLock()) return;
|
||||||
|
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||||
if (bookTree.isEditing()) {
|
if (bookTree.isEditing()) {
|
||||||
freeLock();
|
freeLock();
|
||||||
return;
|
return;
|
||||||
@@ -704,6 +723,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
centralPanel.getActionMap().put("startRerecord", new AbstractAction() {
|
centralPanel.getActionMap().put("startRerecord", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (!getLock()) return;
|
if (!getLock()) return;
|
||||||
|
if (getFocusOwner() == bookNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { freeLock(); return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { freeLock(); return; }
|
||||||
if (bookTree.isEditing()) {
|
if (bookTree.isEditing()) {
|
||||||
freeLock();
|
freeLock();
|
||||||
return;
|
return;
|
||||||
@@ -718,6 +740,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
});
|
});
|
||||||
centralPanel.getActionMap().put("stopRecord", new AbstractAction() {
|
centralPanel.getActionMap().put("stopRecord", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (getFocusOwner() == bookNotesArea) { return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { return; }
|
||||||
if (bookTree.isEditing()) return;
|
if (bookTree.isEditing()) return;
|
||||||
stopLock();
|
stopLock();
|
||||||
stopRecording();
|
stopRecording();
|
||||||
@@ -726,6 +751,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
});
|
});
|
||||||
centralPanel.getActionMap().put("deleteLast", new AbstractAction() {
|
centralPanel.getActionMap().put("deleteLast", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (getFocusOwner() == bookNotesArea) { return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { return; }
|
||||||
if (bookTree.isEditing()) return;
|
if (bookTree.isEditing()) return;
|
||||||
deleteLastRecording();
|
deleteLastRecording();
|
||||||
}
|
}
|
||||||
@@ -733,6 +761,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
centralPanel.getActionMap().put("startStopPlayback", new AbstractAction() {
|
centralPanel.getActionMap().put("startStopPlayback", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (getFocusOwner() == bookNotesArea) { return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { return; }
|
||||||
if (bookTree.isEditing()) return;
|
if (bookTree.isEditing()) return;
|
||||||
if (playing == null) {
|
if (playing == null) {
|
||||||
playSelectedSentence();
|
playSelectedSentence();
|
||||||
@@ -744,6 +775,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
centralPanel.getActionMap().put("startPlaybackFrom", new AbstractAction() {
|
centralPanel.getActionMap().put("startPlaybackFrom", new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (getFocusOwner() == bookNotesArea) { return; }
|
||||||
|
if (getFocusOwner() == chapterNotesArea) { return; }
|
||||||
|
if (getFocusOwner() == sentenceNotesArea) { return; }
|
||||||
if (bookTree.isEditing()) return;
|
if (bookTree.isEditing()) return;
|
||||||
if (playing == null) {
|
if (playing == null) {
|
||||||
playFromSelectedSentence();
|
playFromSelectedSentence();
|
||||||
@@ -752,16 +786,65 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mainScroll = new JScrollPane();
|
mainScroll = new JScrollPane();
|
||||||
centralPanel.add(mainScroll, BorderLayout.CENTER);
|
|
||||||
|
bookNotesArea = new JTextArea();
|
||||||
|
bookNotesArea.setFont(new Font("Monospaced", Font.PLAIN, 10));
|
||||||
|
bookNotesScroll = new JScrollPane();
|
||||||
|
bookNotesScroll.setViewportView(bookNotesArea);
|
||||||
|
|
||||||
|
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() {
|
||||||
|
public void propertyChange(PropertyChangeEvent ev) {
|
||||||
|
if (ev.getPropertyName().equals("dividerLocation")) {
|
||||||
|
if ((bookTreeModel != null) && (book != null)) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
bookTreeModel.reload(book);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
setTitle("AudioBook Recorder");
|
setTitle("AudioBook Recorder");
|
||||||
|
|
||||||
setIconImage(Icons.appIcon.getImage());
|
setIconImage(Icons.appIcon.getImage());
|
||||||
|
|
||||||
|
bindKeys(centralPanel);
|
||||||
|
|
||||||
|
mainSplit.setResizeWeight(0.8d);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
mainSplit.setDividerLocation(0.8d);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
String lastBook = Options.get("path.last-book");
|
String lastBook = Options.get("path.last-book");
|
||||||
|
|
||||||
if (lastBook != null && !lastBook.equals("")) {
|
if (lastBook != null && !lastBook.equals("")) {
|
||||||
@@ -792,6 +875,50 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bindKeys(JComponent component) {
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F"), "startRecordShort");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released F"), "stopRecord");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("R"), "startRecord");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released R"), "stopRecord");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("T"), "startRecordNewPara");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released T"), "stopRecord");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Y"), "startRecordNewSection");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released Y"), "stopRecord");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released D"), "deleteLast");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("SPACE"), "startStopPlayback");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.SHIFT_DOWN_MASK), "startPlaybackFrom");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("E"), "startRerecord");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released E"), "stopRecord");
|
||||||
|
}
|
||||||
|
|
||||||
|
void unbindKeys(JComponent component) {
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F"), "ignore");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released F"), "ignore");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("R"), "ignore");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released R"), "ignore");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("T"), "ignore");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released T"), "ignore");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Y"), "ignore");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released Y"), "ignore");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released D"), "ignore");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("SPACE"), "ignore");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.SHIFT_DOWN_MASK), "ignore");
|
||||||
|
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("E"), "ignore");
|
||||||
|
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released E"), "ignore");
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
try {
|
try {
|
||||||
config.load(AudiobookRecorder.class.getResourceAsStream("config.txt"));
|
config.load(AudiobookRecorder.class.getResourceAsStream("config.txt"));
|
||||||
@@ -846,6 +973,8 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
// write the content into xml file
|
// write the content into xml file
|
||||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||||
Transformer transformer = transformerFactory.newTransformer();
|
Transformer transformer = transformerFactory.newTransformer();
|
||||||
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||||
DOMSource source = new DOMSource(doc);
|
DOMSource source = new DOMSource(doc);
|
||||||
StreamResult result = new StreamResult(xml);
|
StreamResult result = new StreamResult(xml);
|
||||||
transformer.transform(source, result);
|
transformer.transform(source, result);
|
||||||
@@ -951,7 +1080,6 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
void treePopup(MouseEvent e) {
|
void treePopup(MouseEvent e) {
|
||||||
|
|
||||||
int selRow = bookTree.getRowForLocation(e.getX(), e.getY());
|
int selRow = bookTree.getRowForLocation(e.getX(), e.getY());
|
||||||
TreePath selPath = bookTree.getPathForLocation(e.getX(), e.getY());
|
TreePath selPath = bookTree.getPathForLocation(e.getX(), e.getY());
|
||||||
if (selRow != -1) {
|
if (selRow != -1) {
|
||||||
@@ -1196,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() {
|
JMenuObject peak = new JMenuObject("Auto-trim all (Peak)", c, new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JMenuObject o = (JMenuObject)e.getSource();
|
JMenuObject o = (JMenuObject)e.getSource();
|
||||||
@@ -1203,7 +1359,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
ProgressDialog ed = new ProgressDialog("Auto-trimming " + chap.getName());
|
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);
|
Thread nt = new Thread(t);
|
||||||
nt.start();
|
nt.start();
|
||||||
ed.setVisible(true);
|
ed.setVisible(true);
|
||||||
@@ -1217,7 +1373,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
ProgressDialog ed = new ProgressDialog("Auto-trimming " + chap.getName());
|
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);
|
Thread nt = new Thread(t);
|
||||||
nt.start();
|
nt.start();
|
||||||
ed.setVisible(true);
|
ed.setVisible(true);
|
||||||
@@ -1410,6 +1566,8 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.add(mergeWith);
|
menu.add(mergeWith);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
menu.add(peaknew);
|
||||||
|
menu.add(fftnew);
|
||||||
menu.add(peak);
|
menu.add(peak);
|
||||||
menu.add(fft);
|
menu.add(fft);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
@@ -1832,6 +1990,8 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
// write the content into xml file
|
// write the content into xml file
|
||||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||||
Transformer transformer = transformerFactory.newTransformer();
|
Transformer transformer = transformerFactory.newTransformer();
|
||||||
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||||
DOMSource source = new DOMSource(doc);
|
DOMSource source = new DOMSource(doc);
|
||||||
StreamResult result = new StreamResult(xml);
|
StreamResult result = new StreamResult(xml);
|
||||||
transformer.transform(source, result);
|
transformer.transform(source, result);
|
||||||
@@ -1874,6 +2034,11 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
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) {
|
||||||
|
BookTreeNode btn = (BookTreeNode)n;
|
||||||
|
btn.onSelect();
|
||||||
|
}
|
||||||
|
|
||||||
if (n instanceof Sentence) {
|
if (n instanceof Sentence) {
|
||||||
Sentence s = (Sentence)n;
|
Sentence s = (Sentence)n;
|
||||||
selectedSentence = s;
|
selectedSentence = s;
|
||||||
@@ -2041,6 +2206,11 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
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) {
|
||||||
|
BookTreeNode btn = (BookTreeNode)n;
|
||||||
|
btn.onSelect();
|
||||||
|
}
|
||||||
|
|
||||||
if (n instanceof Sentence) {
|
if (n instanceof Sentence) {
|
||||||
Sentence s = (Sentence)n;
|
Sentence s = (Sentence)n;
|
||||||
selectedSentence = s;
|
selectedSentence = s;
|
||||||
@@ -2376,15 +2546,19 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
ProgressDialog dialog;
|
ProgressDialog dialog;
|
||||||
Chapter chapter;
|
Chapter chapter;
|
||||||
int type;
|
int type;
|
||||||
|
int scope;
|
||||||
|
|
||||||
public final static int FFT = 0;
|
public final static int FFT = 0;
|
||||||
public final static int Peak = 1;
|
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();
|
super();
|
||||||
dialog = e;
|
dialog = e;
|
||||||
chapter = c;
|
chapter = c;
|
||||||
type = t;
|
type = t;
|
||||||
|
scope = sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -2396,6 +2570,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
kidCount++;
|
kidCount++;
|
||||||
dialog.setProgress(kidCount * 2000 / numKids);
|
dialog.setProgress(kidCount * 2000 / numKids);
|
||||||
Sentence snt = (Sentence)s.nextElement();
|
Sentence snt = (Sentence)s.nextElement();
|
||||||
|
if (scope == NewOnly) {
|
||||||
|
if (snt.isProcessed()) continue;
|
||||||
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FFT:
|
case FFT:
|
||||||
snt.autoTrimSampleFFT();
|
snt.autoTrimSampleFFT();
|
||||||
@@ -3585,4 +3762,127 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
System.err.println("Effects Enabled: " + b);
|
System.err.println("Effects Enabled: " + b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBookNotes(String text) {
|
||||||
|
bookNotesArea.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
if (book == null) return;
|
||||||
|
File ms = book.getManuscript();
|
||||||
|
if (ms == null) return;
|
||||||
|
try {
|
||||||
|
Desktop.getDesktop().open(ms);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadManuscript() {
|
||||||
|
if (book == null) return;
|
||||||
|
|
||||||
|
JFileChooser jc = new JFileChooser();
|
||||||
|
FileNameExtensionFilter filter = new FileNameExtensionFilter("Document Files", "doc", "docx", "pdf", "odt");
|
||||||
|
jc.addChoosableFileFilter(filter);
|
||||||
|
jc.setFileFilter(filter);
|
||||||
|
jc.setDialogTitle("Select manuscript");
|
||||||
|
int r = jc.showOpenDialog(this);
|
||||||
|
|
||||||
|
if (r == JFileChooser.APPROVE_OPTION) {
|
||||||
|
File src = jc.getSelectedFile();
|
||||||
|
if (src.exists()) {
|
||||||
|
book.setManuscript(src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//* 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 *//
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
String genre;
|
String genre;
|
||||||
String comment;
|
String comment;
|
||||||
String ACX;
|
String ACX;
|
||||||
|
String manuscript;
|
||||||
|
|
||||||
String defaultEffect = "none";
|
String defaultEffect = "none";
|
||||||
|
|
||||||
@@ -63,6 +64,9 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
genre = getTextNode(root, "genre");
|
genre = getTextNode(root, "genre");
|
||||||
comment = getTextNode(root, "comment");
|
comment = getTextNode(root, "comment");
|
||||||
ACX = getTextNode(root, "acx");
|
ACX = getTextNode(root, "acx");
|
||||||
|
manuscript = getTextNode(root, "manuscript");
|
||||||
|
|
||||||
|
AudiobookRecorder.window.setBookNotes(getTextNode(root, "notes"));
|
||||||
|
|
||||||
Element settings = getNode(root, "settings");
|
Element settings = getNode(root, "settings");
|
||||||
Element audioSettings = getNode(settings, "audio");
|
Element audioSettings = getNode(settings, "audio");
|
||||||
@@ -181,8 +185,12 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getBookPath() {
|
||||||
|
return new File(Options.get("path.storage"), name);
|
||||||
|
}
|
||||||
|
|
||||||
public void renameBook(String newName) {
|
public void renameBook(String newName) {
|
||||||
File oldDir = new File(Options.get("path.storage"), name);
|
File oldDir = getBookPath();
|
||||||
File newDir = new File(Options.get("path.storage"), newName);
|
File newDir = new File(Options.get("path.storage"), newName);
|
||||||
|
|
||||||
if (newDir.exists()) {
|
if (newDir.exists()) {
|
||||||
@@ -296,6 +304,9 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
root.appendChild(makeTextNode(doc, "comment", comment));
|
root.appendChild(makeTextNode(doc, "comment", comment));
|
||||||
root.appendChild(makeTextNode(doc, "genre", genre));
|
root.appendChild(makeTextNode(doc, "genre", genre));
|
||||||
root.appendChild(makeTextNode(doc, "acx", ACX));
|
root.appendChild(makeTextNode(doc, "acx", ACX));
|
||||||
|
root.appendChild(makeTextNode(doc, "manuscript", manuscript));
|
||||||
|
|
||||||
|
root.appendChild(makeTextNode(doc, "notes", AudiobookRecorder.window.getBookNotes()));
|
||||||
|
|
||||||
Element settingsNode = doc.createElement("settings");
|
Element settingsNode = doc.createElement("settings");
|
||||||
root.appendChild(settingsNode);
|
root.appendChild(settingsNode);
|
||||||
@@ -329,7 +340,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
|
|
||||||
public static Element makeTextNode(Document doc, String name, String text) {
|
public static Element makeTextNode(Document doc, String name, String text) {
|
||||||
Element node = doc.createElement(name);
|
Element node = doc.createElement(name);
|
||||||
Text tnode = doc.createTextNode(text);
|
Text tnode = doc.createTextNode(text == null ? "" : text);
|
||||||
node.appendChild(tnode);
|
node.appendChild(tnode);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@@ -363,4 +374,24 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
defaultEffect = eff;
|
defaultEffect = eff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setManuscript(File f) {
|
||||||
|
manuscript = f.getName();
|
||||||
|
File dst = new File(getBookPath(), manuscript);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Files.copy(f.toPath(), dst.toPath());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getManuscript() {
|
||||||
|
if (manuscript == null) return null;
|
||||||
|
if (manuscript.equals("")) return null;
|
||||||
|
File f = new File(getBookPath(), manuscript);
|
||||||
|
if (f.exists()) {
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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,13 +20,17 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
ret.setText(s.getOverrideText());
|
ret.setText(s.getOverrideText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!s.isProcessed()) {
|
||||||
|
ret.setForeground(new Color(0x88, 0x88, 0x88));
|
||||||
|
}
|
||||||
|
|
||||||
if (s.getAttentionFlag()) {
|
if (s.getAttentionFlag()) {
|
||||||
ret.setForeground(new Color(0xFF, 0xFF, 0x00));
|
ret.setForeground(new Color(0xFF, 0xFF, 0x00));
|
||||||
icn.add(Overlays.attention, OverlayIcon.TOP_LEFT);
|
icn.add(Overlays.attention, OverlayIcon.TOP_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.isLocked()) {
|
if (s.isLocked()) {
|
||||||
ret.setForeground(new Color(0x00, 0x80, 0xFF));
|
ret.setForeground(new Color(0x30, 0xb0, 0xFF));
|
||||||
icn.add(Overlays.locked, OverlayIcon.BOTTOM_LEFT);
|
icn.add(Overlays.locked, OverlayIcon.BOTTOM_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.w3c.dom.Node;
|
|||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.w3c.dom.Text;
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
public class Chapter extends DefaultMutableTreeNode {
|
public class Chapter extends BookTreeNode {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
String id;
|
String id;
|
||||||
@@ -34,6 +34,8 @@ public class Chapter extends DefaultMutableTreeNode {
|
|||||||
int preGap;
|
int preGap;
|
||||||
int postGap;
|
int postGap;
|
||||||
|
|
||||||
|
String notes;
|
||||||
|
|
||||||
public Chapter(String i, String chaptername) {
|
public Chapter(String i, String chaptername) {
|
||||||
super(chaptername);
|
super(chaptername);
|
||||||
|
|
||||||
@@ -46,9 +48,12 @@ public class Chapter extends DefaultMutableTreeNode {
|
|||||||
public Chapter(Element root, DefaultTreeModel model) {
|
public Chapter(Element root, DefaultTreeModel model) {
|
||||||
|
|
||||||
name = Book.getTextNode(root, "name");
|
name = Book.getTextNode(root, "name");
|
||||||
|
id = root.getAttribute("id");
|
||||||
preGap = Utils.s2i(Book.getTextNode(root, "pre-gap"));
|
preGap = Utils.s2i(Book.getTextNode(root, "pre-gap"));
|
||||||
postGap = Utils.s2i(Book.getTextNode(root, "post-gap"));
|
postGap = Utils.s2i(Book.getTextNode(root, "post-gap"));
|
||||||
|
|
||||||
|
notes = Book.getTextNode(root, "notes");
|
||||||
|
|
||||||
Element sentencesNode = Book.getNode(root, "sentences");
|
Element sentencesNode = Book.getNode(root, "sentences");
|
||||||
NodeList sentences = sentencesNode.getElementsByTagName("sentence");
|
NodeList sentences = sentencesNode.getElementsByTagName("sentence");
|
||||||
|
|
||||||
@@ -283,6 +288,7 @@ public class Chapter extends DefaultMutableTreeNode {
|
|||||||
chapterNode.appendChild(Book.makeTextNode(doc, "name", name));
|
chapterNode.appendChild(Book.makeTextNode(doc, "name", name));
|
||||||
chapterNode.appendChild(Book.makeTextNode(doc, "pre-gap", preGap));
|
chapterNode.appendChild(Book.makeTextNode(doc, "pre-gap", preGap));
|
||||||
chapterNode.appendChild(Book.makeTextNode(doc, "post-gap", postGap));
|
chapterNode.appendChild(Book.makeTextNode(doc, "post-gap", postGap));
|
||||||
|
chapterNode.appendChild(Book.makeTextNode(doc, "notes", notes));
|
||||||
|
|
||||||
Element sentencesNode = doc.createElement("sentences");
|
Element sentencesNode = doc.createElement("sentences");
|
||||||
chapterNode.appendChild(sentencesNode);
|
chapterNode.appendChild(sentencesNode);
|
||||||
@@ -298,4 +304,16 @@ public class Chapter extends DefaultMutableTreeNode {
|
|||||||
return chapterNode;
|
return chapterNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String t) {
|
||||||
|
notes = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSelect() {
|
||||||
|
AudiobookRecorder.window.setChapterNotes(notes);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,4 +38,5 @@ public class Icons {
|
|||||||
static public final ImageIcon docut = new ImageIcon(Icons.class.getResource("icons/do-cut.png"));
|
static public final ImageIcon docut = new ImageIcon(Icons.class.getResource("icons/do-cut.png"));
|
||||||
static public final ImageIcon playto = new ImageIcon(Icons.class.getResource("icons/play-to.png"));
|
static public final ImageIcon playto = new ImageIcon(Icons.class.getResource("icons/play-to.png"));
|
||||||
static public final ImageIcon disable = new ImageIcon(Icons.class.getResource("icons/disable-effects.png"));
|
static public final ImageIcon disable = new ImageIcon(Icons.class.getResource("icons/disable-effects.png"));
|
||||||
|
static public final ImageIcon manuscript = new ImageIcon(Icons.class.getResource("icons/manuscript.png"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class MainToolBar extends JToolBar {
|
|||||||
JButtonSpacePlay playtoSentence;
|
JButtonSpacePlay playtoSentence;
|
||||||
JButtonSpacePlay stopPlaying;
|
JButtonSpacePlay stopPlaying;
|
||||||
JButtonSpacePlay eq;
|
JButtonSpacePlay eq;
|
||||||
|
JButtonSpacePlay openManuscript;
|
||||||
JToggleButtonSpacePlay mic;
|
JToggleButtonSpacePlay mic;
|
||||||
|
|
||||||
JComboBox<String> playbackSpeed;
|
JComboBox<String> playbackSpeed;
|
||||||
@@ -171,6 +172,15 @@ public class MainToolBar extends JToolBar {
|
|||||||
playbackSpeed.setSelectedIndex(1);
|
playbackSpeed.setSelectedIndex(1);
|
||||||
add(playbackSpeed);
|
add(playbackSpeed);
|
||||||
|
|
||||||
|
addSeparator();
|
||||||
|
openManuscript = new JButtonSpacePlay(Icons.manuscript, "Open Manuscript", new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
root.openManuscript();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(openManuscript);
|
||||||
|
|
||||||
|
|
||||||
setFloatable(false);
|
setFloatable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ import org.w3c.dom.Document;
|
|||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Text;
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
public class Sentence extends BookTreeNode implements Cacheable {
|
||||||
|
|
||||||
String text;
|
String text;
|
||||||
String id;
|
String id;
|
||||||
|
String notes;
|
||||||
int postGap;
|
int postGap;
|
||||||
int startOffset = 0;
|
int startOffset = 0;
|
||||||
int endOffset = 0;
|
int endOffset = 0;
|
||||||
@@ -60,6 +61,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
boolean inSample;
|
boolean inSample;
|
||||||
boolean attention = false;
|
boolean attention = false;
|
||||||
|
boolean processed = false;
|
||||||
|
|
||||||
String effectChain = null;
|
String effectChain = null;
|
||||||
|
|
||||||
@@ -86,20 +88,26 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
boolean effectEthereal = false;
|
boolean effectEthereal = false;
|
||||||
|
|
||||||
|
public void setSampleSize(int s) {
|
||||||
|
sampleSize = s;
|
||||||
|
}
|
||||||
|
|
||||||
static class RecordingThread implements Runnable {
|
static class RecordingThread implements Runnable {
|
||||||
|
|
||||||
boolean running = false;
|
boolean running = false;
|
||||||
boolean recording = false;
|
boolean recording = false;
|
||||||
|
Sentence sent = null;
|
||||||
|
|
||||||
File tempFile;
|
File tempFile;
|
||||||
File wavFile;
|
File wavFile;
|
||||||
|
|
||||||
AudioFormat format;
|
AudioFormat format;
|
||||||
|
|
||||||
public RecordingThread(File tf, File wf, AudioFormat af) {
|
public RecordingThread(File tf, File wf, AudioFormat af, Sentence s) {
|
||||||
tempFile = tf;
|
tempFile = tf;
|
||||||
wavFile = wf;
|
wavFile = wf;
|
||||||
format = af;
|
format = af;
|
||||||
|
sent = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -121,6 +129,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
fos.write(buf, 0, nr);
|
fos.write(buf, 0, nr);
|
||||||
fos.close();
|
fos.close();
|
||||||
|
|
||||||
|
sent.setSampleSize(len / format.getFrameSize());
|
||||||
|
|
||||||
FileInputStream fis = new FileInputStream(tempFile);
|
FileInputStream fis = new FileInputStream(tempFile);
|
||||||
AudioInputStream ais = new AudioInputStream(fis, format, len / format.getFrameSize());
|
AudioInputStream ais = new AudioInputStream(fis, format, len / format.getFrameSize());
|
||||||
fos = new FileOutputStream(wavFile);
|
fos = new FileOutputStream(wavFile);
|
||||||
@@ -170,6 +180,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
super("");
|
super("");
|
||||||
id = root.getAttribute("id");
|
id = root.getAttribute("id");
|
||||||
text = Book.getTextNode(root, "text");
|
text = Book.getTextNode(root, "text");
|
||||||
|
notes = Book.getTextNode(root, "notes");
|
||||||
setUserObject(text);
|
setUserObject(text);
|
||||||
setPostGap(Utils.s2i(Book.getTextNode(root, "post-gap")));
|
setPostGap(Utils.s2i(Book.getTextNode(root, "post-gap")));
|
||||||
setStartOffset(Utils.s2i(Book.getTextNode(root, "start-offset")));
|
setStartOffset(Utils.s2i(Book.getTextNode(root, "start-offset")));
|
||||||
@@ -180,6 +191,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
setEffectChain(Book.getTextNode(root, "effect"));
|
setEffectChain(Book.getTextNode(root, "effect"));
|
||||||
setPostGapType(Book.getTextNode(root, "gaptype"));
|
setPostGapType(Book.getTextNode(root, "gaptype"));
|
||||||
sampleSize = Utils.s2i(Book.getTextNode(root, "samples"));
|
sampleSize = Utils.s2i(Book.getTextNode(root, "samples"));
|
||||||
|
processed = Utils.s2b(Book.getTextNode(root, "processed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean startRecording() {
|
public boolean startRecording() {
|
||||||
@@ -190,7 +202,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
CacheManager.removeFromCache(this);
|
CacheManager.removeFromCache(this);
|
||||||
|
|
||||||
recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat());
|
recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat(), this);
|
||||||
|
|
||||||
Thread rc = new Thread(recordingThread);
|
Thread rc = new Thread(recordingThread);
|
||||||
rc.setDaemon(true);
|
rc.setDaemon(true);
|
||||||
@@ -230,6 +242,12 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
autoTrimSamplePeak(useRaw);
|
autoTrimSamplePeak(useRaw);
|
||||||
} else if (tm.equals("fft")) {
|
} else if (tm.equals("fft")) {
|
||||||
autoTrimSampleFFT(useRaw);
|
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);
|
updateCrossings(useRaw);
|
||||||
intens = null;
|
intens = null;
|
||||||
samples = null;
|
samples = null;
|
||||||
|
processed = true;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void autoTrimSamplePeak() {
|
public void autoTrimSamplePeak() {
|
||||||
@@ -387,6 +406,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
if (startOffset < 0) startOffset = 0;
|
if (startOffset < 0) startOffset = 0;
|
||||||
if (endOffset >= samples.length) endOffset = samples.length-1;
|
if (endOffset >= samples.length) endOffset = samples.length-1;
|
||||||
updateCrossings(useRaw);
|
updateCrossings(useRaw);
|
||||||
|
processed = true;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -396,6 +417,7 @@ public class Sentence extends DefaultMutableTreeNode 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
@@ -443,6 +465,7 @@ public class Sentence extends DefaultMutableTreeNode 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,6 +525,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
if (startOffset != o) {
|
if (startOffset != o) {
|
||||||
startOffset = o;
|
startOffset = o;
|
||||||
crossStartOffset = -1;
|
crossStartOffset = -1;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,6 +541,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
if (endOffset != o) {
|
if (endOffset != o) {
|
||||||
endOffset = o;
|
endOffset = o;
|
||||||
crossEndOffset = -1;
|
crossEndOffset = -1;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,6 +622,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
public void setLocked(boolean l) {
|
public void setLocked(boolean l) {
|
||||||
locked = l;
|
locked = l;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocked() {
|
public boolean isLocked() {
|
||||||
@@ -699,6 +725,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
public void setAttentionFlag(boolean f) {
|
public void setAttentionFlag(boolean f) {
|
||||||
attention = f;
|
attention = f;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAttentionFlag() {
|
public boolean getAttentionFlag() {
|
||||||
@@ -1298,6 +1325,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
CacheManager.removeFromCache(this);
|
CacheManager.removeFromCache(this);
|
||||||
}
|
}
|
||||||
effectChain = key;
|
effectChain = key;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEffectChain() {
|
public String getEffectChain() {
|
||||||
@@ -1324,6 +1352,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
postGapType = t;
|
postGapType = t;
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetPostGap() {
|
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, "effect", getEffectChain()));
|
||||||
sentenceNode.appendChild(Book.makeTextNode(doc, "gaptype", getPostGapType()));
|
sentenceNode.appendChild(Book.makeTextNode(doc, "gaptype", getPostGapType()));
|
||||||
sentenceNode.appendChild(Book.makeTextNode(doc, "samples", getSampleSize()));
|
sentenceNode.appendChild(Book.makeTextNode(doc, "samples", getSampleSize()));
|
||||||
|
sentenceNode.appendChild(Book.makeTextNode(doc, "processed", isProcessed()));
|
||||||
|
sentenceNode.appendChild(Book.makeTextNode(doc, "notes", getNotes()));
|
||||||
return sentenceNode;
|
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