Compare commits

...

8 Commits

Author SHA1 Message Date
ebe777bdc5 Released 0.3.2 2020-01-12 23:43:08 +00:00
3b5cacb8ad Added import / open manuscript file 2020-01-12 22:46:15 +00:00
db7d297dbc Improve controls spacing 2020-01-12 15:23:16 +00:00
2f9abf7629 Fix split location problem 2020-01-12 15:01:22 +00:00
b6063d2fed Fix tree redraw on split resize 2020-01-12 13:15:52 +00:00
e1f566f0c8 Released 0.3.1 2020-01-12 12:23:14 +00:00
9fa892a6fd Added missing IDs in xml files 2020-01-12 12:22:58 +00:00
1572e163ef Added notes panel 2020-01-12 10:38:16 +00:00
8 changed files with 210 additions and 28 deletions

View File

@@ -1 +1 @@
version=0.3.0
version=0.3.2

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -36,6 +36,9 @@ import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
public class AudiobookRecorder extends JFrame {
// Settings - tweakable
@@ -75,6 +78,7 @@ public class AudiobookRecorder extends JFrame {
JMenuItem toolsMerge;
JMenuItem toolsArchive;
JMenuItem toolsCoverArt;
JMenuItem toolsManuscript;
JMenuItem toolsOptions;
JMenuItem helpAbout;
@@ -100,6 +104,9 @@ public class AudiobookRecorder extends JFrame {
JPanel sampleControl;
public Waveform sampleWaveform;
JScrollBar sampleScroll;
JSplitPane mainSplit;
JTextArea notesArea;
JScrollPane notesScroll;
JSpinner postSentenceGap;
JSpinner gainPercent;
@@ -286,6 +293,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.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -296,6 +310,7 @@ public class AudiobookRecorder extends JFrame {
toolsMenu.add(toolsMerge);
toolsMenu.add(toolsArchive);
toolsMenu.add(toolsCoverArt);
toolsMenu.add(toolsManuscript);
toolsMenu.addSeparator();
toolsMenu.add(toolsOptions);
@@ -557,11 +572,11 @@ public class AudiobookRecorder extends JFrame {
controlsTop.add(attention);
controlsTop.add(Box.createHorizontalGlue());
controlsTop.add(new JLabel("Post gap:"));
controlsTop.add(new JLabel(" Post gap:"));
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(new JLabel("%"));
@@ -621,29 +636,14 @@ public class AudiobookRecorder extends JFrame {
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() {
public void actionPerformed(ActionEvent e) {
if (!getLock()) return;
if (getFocusOwner() == notesArea) {
freeLock();
return;
}
if (bookTree.isEditing()) {
freeLock();
return;
@@ -659,6 +659,10 @@ 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 (bookTree.isEditing()) {
freeLock();
return;
@@ -674,6 +678,10 @@ 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 (bookTree.isEditing()) {
freeLock();
return;
@@ -689,6 +697,10 @@ 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 (bookTree.isEditing()) {
freeLock();
return;
@@ -704,6 +716,10 @@ 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 (bookTree.isEditing()) {
freeLock();
return;
@@ -718,6 +734,9 @@ public class AudiobookRecorder extends JFrame {
});
centralPanel.getActionMap().put("stopRecord", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (getFocusOwner() == notesArea) {
return;
}
if (bookTree.isEditing()) return;
stopLock();
stopRecording();
@@ -726,6 +745,9 @@ public class AudiobookRecorder extends JFrame {
});
centralPanel.getActionMap().put("deleteLast", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (getFocusOwner() == notesArea) {
return;
}
if (bookTree.isEditing()) return;
deleteLastRecording();
}
@@ -733,6 +755,9 @@ public class AudiobookRecorder extends JFrame {
centralPanel.getActionMap().put("startStopPlayback", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (getFocusOwner() == notesArea) {
return;
}
if (bookTree.isEditing()) return;
if (playing == null) {
playSelectedSentence();
@@ -744,6 +769,9 @@ public class AudiobookRecorder extends JFrame {
centralPanel.getActionMap().put("startPlaybackFrom", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (getFocusOwner() == notesArea) {
return;
}
if (bookTree.isEditing()) return;
if (playing == null) {
playFromSelectedSentence();
@@ -752,16 +780,47 @@ public class AudiobookRecorder extends JFrame {
});
mainScroll = new JScrollPane();
centralPanel.add(mainScroll, BorderLayout.CENTER);
notesArea = new JTextArea();
notesArea.setFont(new Font("Monospaced", Font.PLAIN, 10));
notesScroll = new JScrollPane();
notesScroll.setViewportView(notesArea);
mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainScroll, notesScroll);
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");
setIconImage(Icons.appIcon.getImage());
bindKeys(centralPanel);
mainSplit.setResizeWeight(0.8d);
pack();
setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
mainSplit.setDividerLocation(0.8d);
}
});
String lastBook = Options.get("path.last-book");
if (lastBook != null && !lastBook.equals("")) {
@@ -792,6 +851,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[]) {
try {
config.load(AudiobookRecorder.class.getResourceAsStream("config.txt"));
@@ -951,7 +1054,6 @@ public class AudiobookRecorder extends JFrame {
@SuppressWarnings("unchecked")
void treePopup(MouseEvent e) {
int selRow = bookTree.getRowForLocation(e.getX(), e.getY());
TreePath selPath = bookTree.getPathForLocation(e.getX(), e.getY());
if (selRow != -1) {
@@ -3585,4 +3687,41 @@ public class AudiobookRecorder extends JFrame {
System.err.println("Effects Enabled: " + b);
}
public void setNotes(String text) {
notesArea.setText(text);
}
public String getNotes() {
return notesArea.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);
}
}
}
}

View File

@@ -31,6 +31,7 @@ public class Book extends DefaultMutableTreeNode {
String genre;
String comment;
String ACX;
String manuscript;
String defaultEffect = "none";
@@ -63,6 +64,9 @@ public class Book extends DefaultMutableTreeNode {
genre = getTextNode(root, "genre");
comment = getTextNode(root, "comment");
ACX = getTextNode(root, "acx");
manuscript = getTextNode(root, "manuscript");
AudiobookRecorder.window.setNotes(getTextNode(root, "notes"));
Element settings = getNode(root, "settings");
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) {
File oldDir = new File(Options.get("path.storage"), name);
File oldDir = getBookPath();
File newDir = new File(Options.get("path.storage"), newName);
if (newDir.exists()) {
@@ -296,6 +304,9 @@ public class Book extends DefaultMutableTreeNode {
root.appendChild(makeTextNode(doc, "comment", comment));
root.appendChild(makeTextNode(doc, "genre", genre));
root.appendChild(makeTextNode(doc, "acx", ACX));
root.appendChild(makeTextNode(doc, "manuscript", manuscript));
root.appendChild(makeTextNode(doc, "notes", AudiobookRecorder.window.getNotes()));
Element settingsNode = doc.createElement("settings");
root.appendChild(settingsNode);
@@ -329,7 +340,7 @@ public class Book extends DefaultMutableTreeNode {
public static Element makeTextNode(Document doc, String name, String text) {
Element node = doc.createElement(name);
Text tnode = doc.createTextNode(text);
Text tnode = doc.createTextNode(text == null ? "" : text);
node.appendChild(tnode);
return node;
}
@@ -363,4 +374,24 @@ public class Book extends DefaultMutableTreeNode {
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;
}
}

View File

@@ -26,7 +26,7 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
}
if (s.isLocked()) {
ret.setForeground(new Color(0x00, 0x80, 0xFF));
ret.setForeground(new Color(0x30, 0xb0, 0xFF));
icn.add(Overlays.locked, OverlayIcon.BOTTOM_LEFT);
}

View File

@@ -46,6 +46,7 @@ public class Chapter extends DefaultMutableTreeNode {
public Chapter(Element root, DefaultTreeModel model) {
name = Book.getTextNode(root, "name");
id = root.getAttribute("id");
preGap = Utils.s2i(Book.getTextNode(root, "pre-gap"));
postGap = Utils.s2i(Book.getTextNode(root, "post-gap"));

View File

@@ -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 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 manuscript = new ImageIcon(Icons.class.getResource("icons/manuscript.png"));
}

View File

@@ -17,6 +17,7 @@ public class MainToolBar extends JToolBar {
JButtonSpacePlay playtoSentence;
JButtonSpacePlay stopPlaying;
JButtonSpacePlay eq;
JButtonSpacePlay openManuscript;
JToggleButtonSpacePlay mic;
JComboBox<String> playbackSpeed;
@@ -171,6 +172,15 @@ public class MainToolBar extends JToolBar {
playbackSpeed.setSelectedIndex(1);
add(playbackSpeed);
addSeparator();
openManuscript = new JButtonSpacePlay(Icons.manuscript, "Open Manuscript", new ActionListener() {
public void actionPerformed(ActionEvent e) {
root.openManuscript();
}
});
add(openManuscript);
setFloatable(false);
}