Compare commits
10 Commits
v0.0.2-fef
...
v0.0.3-a8b
| Author | SHA1 | Date | |
|---|---|---|---|
| a8b8def6ca | |||
| aa9d7993d6 | |||
| 6157eea4da | |||
| 8cc7614a68 | |||
| 4d928a9e26 | |||
| ff0dc30375 | |||
| fab564e0e4 | |||
| 27e72dc2d8 | |||
| 75a684d29f | |||
| b3f57c45af |
7
TODO.md
Normal file
7
TODO.md
Normal file
@@ -0,0 +1,7 @@
|
||||
ToDo
|
||||
====
|
||||
|
||||
* Merge chapters
|
||||
* Identify and export 5 minute retail sample
|
||||
* Identify and export 15 minute checkpoint
|
||||
* Archive (Zip and delete) audiobooks
|
||||
26
installers/linux.sh
Executable file
26
installers/linux.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
NAME=AudiobookRecorder
|
||||
|
||||
BIN=/usr/bin
|
||||
DESKTOP=/usr/share/applications
|
||||
SHARE=/usr/share
|
||||
ICON=/usr/share/icons
|
||||
|
||||
|
||||
mkdir -p "$BIN"
|
||||
mkdir -p "$SHARE/$NAME"
|
||||
|
||||
cp AudiobookRecorder.jar "$SHARE/$NAME/$NAME.jar"
|
||||
echo "#!/bin/bash" > "$BIN/$NAME"
|
||||
echo "java -jar \"$SHARE/$NAME/$NAME.jar\"" >> "$BIN/$NAME"
|
||||
chmod 755 "$BIN/$NAME"
|
||||
|
||||
echo "[Desktop Entry]" > "$DESKTOP/$NAME.desktop"
|
||||
echo "Version=1.0" >> "$DESKTOP/$NAME.desktop"
|
||||
echo "Name=$NAME" >> "$DESKTOP/$NAME.desktop"
|
||||
echo "Exec=$NAME" >> "$DESKTOP/$NAME.desktop"
|
||||
echo "Icon=$NAME" >> "$DESKTOP/$NAME.desktop"
|
||||
echo "Categories=Multimedia" >> "$DESKTOP/$NAME.desktop"
|
||||
|
||||
cp resources/uk/co/majenko/audiobookrecorder/icons/appIcon.png "$ICON/$NAME.png"
|
||||
@@ -597,6 +597,40 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
class JMenuObject2 extends JMenuItem {
|
||||
Object ob1;
|
||||
Object ob2;
|
||||
|
||||
public JMenuObject2(String p) {
|
||||
super(p);
|
||||
ob1 = null;
|
||||
ob2 = null;
|
||||
}
|
||||
|
||||
public JMenuObject2(String p, Object o1, Object o2) {
|
||||
super(p);
|
||||
ob1 = o1;
|
||||
ob2 = o2;
|
||||
}
|
||||
|
||||
public void setObject1(Object o) {
|
||||
ob1 = o;
|
||||
}
|
||||
|
||||
public void setObject2(Object o) {
|
||||
ob2 = o;
|
||||
}
|
||||
|
||||
public Object getObject1() {
|
||||
return ob1;
|
||||
}
|
||||
|
||||
public Object getObject2() {
|
||||
return ob2;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void treePopup(MouseEvent e) {
|
||||
|
||||
int selRow = bookTree.getRowForLocation(e.getX(), e.getY());
|
||||
@@ -612,6 +646,52 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
JMenuObject rec = new JMenuObject("Recognise text from audio", s);
|
||||
JMenu moveMenu = new JMenu("Move sentence to...");
|
||||
|
||||
for (Enumeration<Chapter> c = book.children(); c.hasMoreElements();) {
|
||||
Chapter chp = c.nextElement();
|
||||
JMenuObject2 m = new JMenuObject2(chp.getName(), s, chp);
|
||||
m.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject2 ob = (JMenuObject2)e.getSource();
|
||||
Sentence sentence = (Sentence)ob.getObject1();
|
||||
Chapter target = (Chapter)ob.getObject2();
|
||||
|
||||
bookTreeModel.removeNodeFromParent(sentence);
|
||||
bookTreeModel.insertNodeInto(sentence, target, target.getChildCount());
|
||||
}
|
||||
});
|
||||
moveMenu.add(m);
|
||||
}
|
||||
|
||||
JMenuObject moveUp = new JMenuObject("Move Up", s);
|
||||
JMenuObject moveDown = new JMenuObject("Move Down", s);
|
||||
|
||||
moveUp.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
Sentence sent = (Sentence)o.getObject();
|
||||
Chapter chap = (Chapter)sent.getParent();
|
||||
int pos = bookTreeModel.getIndexOfChild(chap, sent);
|
||||
if (pos > 0) pos--;
|
||||
bookTreeModel.removeNodeFromParent(sent);
|
||||
bookTreeModel.insertNodeInto(sent, chap, pos);
|
||||
}
|
||||
});
|
||||
|
||||
moveDown.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
Sentence sent = (Sentence)o.getObject();
|
||||
Chapter chap = (Chapter)sent.getParent();
|
||||
int pos = bookTreeModel.getIndexOfChild(chap, sent);
|
||||
if (pos < chap.getChildCount() - 1) pos++;
|
||||
bookTreeModel.removeNodeFromParent(sent);
|
||||
bookTreeModel.insertNodeInto(sent, chap, pos);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
JMenuObject ins = new JMenuObject("Insert sentence above", s);
|
||||
JMenuObject del = new JMenuObject("Delete sentence", s);
|
||||
|
||||
@@ -656,6 +736,10 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
menu.add(rec);
|
||||
menu.addSeparator();
|
||||
menu.add(moveUp);
|
||||
menu.add(moveDown);
|
||||
menu.add(moveMenu);
|
||||
menu.addSeparator();
|
||||
menu.add(ins);
|
||||
menu.add(del);
|
||||
menu.show(bookTree, e.getX(), e.getY());
|
||||
@@ -666,6 +750,51 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
JMenuObject peak = new JMenuObject("Auto-trim all (Peak)", c);
|
||||
JMenuObject moveUp = new JMenuObject("Move Up", c);
|
||||
JMenuObject moveDown = new JMenuObject("Move Down", c);
|
||||
|
||||
int idNumber = s2i(c.getId());
|
||||
|
||||
moveUp.setEnabled(idNumber > 0);
|
||||
moveDown.setEnabled(idNumber > 0);
|
||||
|
||||
moveUp.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
Chapter chap = (Chapter)o.getObject();
|
||||
int pos = bookTreeModel.getIndexOfChild(book, chap);
|
||||
if (pos > 0) pos--;
|
||||
|
||||
int id = s2i(chap.getId());
|
||||
if (id > 0) {
|
||||
Chapter prevChap = (Chapter)bookTreeModel.getChild(book, pos);
|
||||
id = s2i(prevChap.getId());
|
||||
if (id > 0) {
|
||||
bookTreeModel.removeNodeFromParent(chap);
|
||||
bookTreeModel.insertNodeInto(chap, book, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
moveDown.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
Chapter chap = (Chapter)o.getObject();
|
||||
int pos = bookTreeModel.getIndexOfChild(book, chap);
|
||||
pos++;
|
||||
int id = s2i(chap.getId());
|
||||
if (id > 0) {
|
||||
Chapter nextChap = (Chapter)bookTreeModel.getChild(book, pos);
|
||||
if (nextChap != null) {
|
||||
id = s2i(nextChap.getId());
|
||||
if (id > 0) {
|
||||
bookTreeModel.removeNodeFromParent(chap);
|
||||
bookTreeModel.insertNodeInto(chap, book, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
peak.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -680,6 +809,11 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
menu.add(moveUp);
|
||||
menu.add(moveDown);
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
menu.add(peak);
|
||||
menu.show(bookTree, e.getX(), e.getY());
|
||||
}
|
||||
@@ -926,6 +1060,15 @@ public class AudiobookRecorder extends JFrame {
|
||||
prefs.loadFromXML(fis);
|
||||
|
||||
buildBook(prefs);
|
||||
|
||||
File r = f.getParentFile();
|
||||
File cf = new File(r, "coverart.png");
|
||||
if (cf.exists()) {
|
||||
ImageIcon i = new ImageIcon(cf.getAbsolutePath());
|
||||
Image ri = Utils.getScaledImage(i.getImage(), 22, 22);
|
||||
book.setIcon(new ImageIcon(ri));
|
||||
bookTreeModel.reload(book);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -1108,6 +1251,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
toolBar.enableBook();
|
||||
statusLabel.setText("Noise floor: " + getNoiseFloor());
|
||||
book.setIcon(Icons.book);
|
||||
}
|
||||
|
||||
public void openBook() {
|
||||
|
||||
@@ -16,6 +16,8 @@ public class Book extends DefaultMutableTreeNode {
|
||||
String genre;
|
||||
String comment;
|
||||
|
||||
ImageIcon icon;
|
||||
|
||||
public Book(String bookname) {
|
||||
super(bookname);
|
||||
name = bookname;
|
||||
@@ -99,4 +101,39 @@ public class Book extends DefaultMutableTreeNode {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ImageIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(ImageIcon i) {
|
||||
icon = i;
|
||||
}
|
||||
|
||||
public void setUserObject(Object o) {
|
||||
if (o instanceof String) {
|
||||
String newName = (String)o;
|
||||
|
||||
File oldDir = new File(Options.get("path.storage"), name);
|
||||
File newDir = new File(Options.get("path.storage"), newName);
|
||||
|
||||
if (newDir.exists()) {
|
||||
JOptionPane.showMessageDialog(AudiobookRecorder.window, "Book already exists", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldDir.exists() && oldDir.isDirectory()) {
|
||||
oldDir.renameTo(newDir);
|
||||
name = newName;
|
||||
AudiobookRecorder.window.saveBookStructure();
|
||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||
Options.set("path.last-book", name);
|
||||
Options.savePreferences();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
96
src/uk/co/majenko/audiobookrecorder/BookPanel.java
Normal file
96
src/uk/co/majenko/audiobookrecorder/BookPanel.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import javax.swing.border.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
public class BookPanel extends JPanel {
|
||||
String name;
|
||||
String author;
|
||||
String genre;
|
||||
String comment;
|
||||
ImageIcon cover;
|
||||
Image resizedCover;
|
||||
|
||||
JLabel iconLabel;
|
||||
JLabel titleLabel;
|
||||
JLabel authorLabel;
|
||||
JLabel otherLabel;
|
||||
|
||||
JPanel panel;
|
||||
|
||||
File root;
|
||||
|
||||
boolean highlight = false;
|
||||
|
||||
public BookPanel(File r) {
|
||||
try {
|
||||
root = r;
|
||||
Properties props = new Properties();
|
||||
props.loadFromXML(new FileInputStream(new File(root, "audiobook.abk")));
|
||||
name = props.getProperty("book.name");
|
||||
author = props.getProperty("book.author");
|
||||
genre = props.getProperty("book.genre");
|
||||
comment = props.getProperty("book.comment");
|
||||
File icon = new File(root, "coverart.png");
|
||||
if (icon.exists()) {
|
||||
cover = new ImageIcon(icon.getAbsolutePath());
|
||||
resizedCover = Utils.getScaledImage(cover.getImage(), 75, 75);
|
||||
iconLabel = new JLabel(new ImageIcon(resizedCover));
|
||||
} else {
|
||||
cover = null;
|
||||
resizedCover = null;
|
||||
iconLabel = new JLabel("");
|
||||
}
|
||||
|
||||
iconLabel.setSize(new Dimension(75, 75));
|
||||
iconLabel.setPreferredSize(new Dimension(75, 75));
|
||||
|
||||
titleLabel = new JLabel(name);
|
||||
authorLabel = new JLabel(author);
|
||||
otherLabel = new JLabel(genre + " :: " + comment);
|
||||
|
||||
authorLabel.setForeground(new Color(0x80, 0x80, 0x80));
|
||||
otherLabel.setForeground(new Color(0x80, 0x80, 0x80));
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
panel = new JPanel();
|
||||
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
|
||||
panel.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
|
||||
panel.add(titleLabel);
|
||||
panel.add(authorLabel);
|
||||
panel.add(otherLabel);
|
||||
|
||||
add(iconLabel, BorderLayout.WEST);
|
||||
add(panel, BorderLayout.CENTER);
|
||||
panel.setBackground(new Color(0x20, 0x20, 0x20));
|
||||
panel.setOpaque(true);
|
||||
setBackground(new Color(0x20, 0x20, 0x20));
|
||||
setOpaque(true);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public File getConfigFile() {
|
||||
return new File(root, "audiobook.abk");
|
||||
}
|
||||
|
||||
public void highlight() {
|
||||
setBackground(new Color(0x00, 0x20, 0x40));
|
||||
panel.setBackground(new Color(0x00, 0x20, 0x40));
|
||||
}
|
||||
|
||||
public void lowlight() {
|
||||
setBackground(new Color(0x20, 0x20, 0x20));
|
||||
panel.setBackground(new Color(0x20, 0x20, 0x20));
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
} else if (value instanceof Chapter) {
|
||||
ret.setIcon(Icons.chapter);
|
||||
} else if (value instanceof Book) {
|
||||
ret.setIcon(Icons.book);
|
||||
ret.setIcon(((Book)value).getIcon());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -28,13 +28,28 @@ public class OpenBookPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public class BookCellRenderer implements TableCellRenderer {
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (value == null) return null;
|
||||
BookPanel p = (BookPanel)value;
|
||||
|
||||
if (isSelected) {
|
||||
p.highlight();
|
||||
} else {
|
||||
p.lowlight();
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
class BookTableModel extends AbstractTableModel {
|
||||
|
||||
ArrayList<BookInfo> books;
|
||||
ArrayList<BookPanel> books;
|
||||
|
||||
public BookTableModel() {
|
||||
super();
|
||||
books = new ArrayList<BookInfo>();
|
||||
books = new ArrayList<BookPanel>();
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
@@ -42,38 +57,27 @@ public class OpenBookPanel extends JPanel {
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return 4;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addBook(BookInfo b) {
|
||||
public void addBook(BookPanel b) {
|
||||
books.add(b);
|
||||
}
|
||||
|
||||
public Object getValueAt(int r, int c) {
|
||||
if (c > 3) return null;
|
||||
if (r > books.size()) return null;
|
||||
BookInfo b = books.get(r);
|
||||
switch (c) {
|
||||
case 0: return b.name;
|
||||
case 1: return b.author;
|
||||
case 2: return b.genre;
|
||||
case 4: return b.comment;
|
||||
}
|
||||
return null;
|
||||
return books.get(r);
|
||||
}
|
||||
|
||||
public String getColumnName(int i) {
|
||||
switch(i) {
|
||||
case 0: return "Name";
|
||||
case 1: return "Author";
|
||||
case 2: return "Genre";
|
||||
case 3: return "Comment";
|
||||
return "Book";
|
||||
}
|
||||
return null;
|
||||
|
||||
public Class getColumnClass(int i) {
|
||||
return BookPanel.class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +89,6 @@ public class OpenBookPanel extends JPanel {
|
||||
model = new BookTableModel();
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
scroll = new JScrollPane();
|
||||
add(scroll, BorderLayout.CENTER);
|
||||
|
||||
@@ -97,22 +100,17 @@ public class OpenBookPanel extends JPanel {
|
||||
if (!b.isDirectory()) continue;
|
||||
File xml = new File(b, "audiobook.abk");
|
||||
if (xml.exists()) {
|
||||
Properties props = new Properties();
|
||||
props.loadFromXML(new FileInputStream(xml));
|
||||
|
||||
BookInfo book = new BookInfo(
|
||||
props.getProperty("book.name"),
|
||||
props.getProperty("book.author"),
|
||||
props.getProperty("book.genre"),
|
||||
props.getProperty("book.comment")
|
||||
);
|
||||
|
||||
BookPanel book = new BookPanel(b);
|
||||
model.addBook(book);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
table = new JTable(model);
|
||||
table.setDefaultRenderer(BookPanel.class, new BookCellRenderer());
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
table.setRowHeight(80);
|
||||
table.getTableHeader().setUI(null);
|
||||
scroll.setViewportView(table);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -126,9 +124,7 @@ public class OpenBookPanel extends JPanel {
|
||||
return null;
|
||||
}
|
||||
|
||||
String name = (String)table.getValueAt(sel, 0);
|
||||
File d = new File(Options.get("path.storage"), name);
|
||||
File f = new File(d, "audiobook.abk");
|
||||
return f;
|
||||
BookPanel b = (BookPanel)table.getValueAt(sel, 0);
|
||||
return b.getConfigFile();
|
||||
}
|
||||
}
|
||||
|
||||
23
src/uk/co/majenko/audiobookrecorder/Utils.java
Normal file
23
src/uk/co/majenko/audiobookrecorder/Utils.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import javax.swing.border.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Utils {
|
||||
public static Image getScaledImage(Image srcImg, int w, int h){
|
||||
BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2 = resizedImg.createGraphics();
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
g2.drawImage(srcImg, 0, 0, w, h, null);
|
||||
g2.dispose();
|
||||
|
||||
return resizedImg;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user