Move effects reloading into worker thread
This commit is contained in:
@@ -68,6 +68,7 @@ import javax.swing.JTree;
|
|||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.tree.TreeCellRenderer;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
@@ -139,6 +140,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
JMenuItem toolsArchive;
|
JMenuItem toolsArchive;
|
||||||
JMenuItem toolsCoverArt;
|
JMenuItem toolsCoverArt;
|
||||||
JMenuItem toolsManuscript;
|
JMenuItem toolsManuscript;
|
||||||
|
JMenuItem toolsReloadEffects;
|
||||||
JMenuItem toolsOptions;
|
JMenuItem toolsOptions;
|
||||||
|
|
||||||
JMenuItem helpAbout;
|
JMenuItem helpAbout;
|
||||||
@@ -372,6 +374,18 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
loadManuscript();
|
loadManuscript();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
toolsReloadEffects = new JMenuItem("Reload effects");
|
||||||
|
toolsReloadEffects.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Debug.trace();
|
||||||
|
queueJob(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
loadEffects();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
toolsOptions = new JMenuItem("Options");
|
toolsOptions = new JMenuItem("Options");
|
||||||
toolsOptions.addActionListener(new ActionListener() {
|
toolsOptions.addActionListener(new ActionListener() {
|
||||||
@@ -385,6 +399,7 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
toolsMenu.add(toolsArchive);
|
toolsMenu.add(toolsArchive);
|
||||||
toolsMenu.add(toolsCoverArt);
|
toolsMenu.add(toolsCoverArt);
|
||||||
toolsMenu.add(toolsManuscript);
|
toolsMenu.add(toolsManuscript);
|
||||||
|
toolsMenu.add(toolsReloadEffects);
|
||||||
toolsMenu.addSeparator();
|
toolsMenu.addSeparator();
|
||||||
toolsMenu.add(toolsOptions);
|
toolsMenu.add(toolsOptions);
|
||||||
|
|
||||||
@@ -2210,11 +2225,11 @@ public class AudiobookRecorder extends JFrame implements DocumentListener {
|
|||||||
bookTree.setEditable(true);
|
bookTree.setEditable(true);
|
||||||
bookTree.setUI(new CustomTreeUI(mainScroll));
|
bookTree.setUI(new CustomTreeUI(mainScroll));
|
||||||
|
|
||||||
|
TreeCellRenderer renderer = new BookTreeRenderer();
|
||||||
try {
|
try {
|
||||||
bookTree.setCellRenderer(new BookTreeRenderer());
|
bookTree.setCellRenderer(renderer);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
bookTree.setCellRenderer(renderer);
|
||||||
bookTree.setCellRenderer(new BookTreeRenderer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputMap im = bookTree.getInputMap(JComponent.WHEN_FOCUSED);
|
InputMap im = bookTree.getInputMap(JComponent.WHEN_FOCUSED);
|
||||||
|
|||||||
@@ -155,12 +155,7 @@ public class Book extends BookTreeNode {
|
|||||||
|
|
||||||
public Chapter getLastChapter() {
|
public Chapter getLastChapter() {
|
||||||
Debug.trace();
|
Debug.trace();
|
||||||
Chapter cc = getClosingCredits();
|
return (Chapter)getLastLeaf();
|
||||||
if (cc == null) return null;
|
|
||||||
Chapter c = (Chapter)getChildBefore(cc);
|
|
||||||
if (c == null) return null;
|
|
||||||
if (c.getId().equals("open")) return null;
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chapter getChapter(int n) {
|
public Chapter getChapter(int n) {
|
||||||
@@ -453,6 +448,8 @@ public class Book extends BookTreeNode {
|
|||||||
Debug.trace();
|
Debug.trace();
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (AudiobookRecorder.window == null) return;
|
||||||
|
if (AudiobookRecorder.window.bookTreeModel == null) return;
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(Book.this);
|
AudiobookRecorder.window.bookTreeModel.reload(Book.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ public class MainToolBar extends JToolBar {
|
|||||||
JButtonSpacePlay playonSentence;
|
JButtonSpacePlay playonSentence;
|
||||||
JButtonSpacePlay playtoSentence;
|
JButtonSpacePlay playtoSentence;
|
||||||
JButtonSpacePlay stopPlaying;
|
JButtonSpacePlay stopPlaying;
|
||||||
JButtonSpacePlay eq;
|
|
||||||
JButtonSpacePlay openManuscript;
|
JButtonSpacePlay openManuscript;
|
||||||
JToggleButtonSpacePlay mic;
|
JToggleButtonSpacePlay mic;
|
||||||
|
|
||||||
@@ -102,16 +101,6 @@ public class MainToolBar extends JToolBar {
|
|||||||
});
|
});
|
||||||
add(stopPlaying);
|
add(stopPlaying);
|
||||||
|
|
||||||
addSeparator();
|
|
||||||
eq = new JButtonSpacePlay(Icons.eq, "Reload Effects", new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
root.loadEffects();
|
|
||||||
CacheManager.purgeCache();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add(eq);
|
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
mic = new JToggleButtonSpacePlay(Icons.mic, "Enable / disable microphone", new ActionListener() {
|
mic = new JToggleButtonSpacePlay(Icons.mic, "Enable / disable microphone", new ActionListener() {
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ public class Options extends JDialog {
|
|||||||
|
|
||||||
enableParsing = addCheckBox(optionsPanel, "Enable automatic speech-to-text (**SLOW**)", getBoolean("process.sphinx"), "This will automatically start recognising the speech in every sentence you record. This can really slow down recording though so it's recommended to leave it turned off and do your recognition afterwards as a batch operation.");
|
enableParsing = addCheckBox(optionsPanel, "Enable automatic speech-to-text (**SLOW**)", getBoolean("process.sphinx"), "This will automatically start recognising the speech in every sentence you record. This can really slow down recording though so it's recommended to leave it turned off and do your recognition afterwards as a batch operation.");
|
||||||
speechCommand = addTextField(optionsPanel, "Speech to text command (must take 1 filename parameter):", get("process.command"), "This specifies what command to run to recognize the speech. This command must take only one parameter, which is the full path of the WAV file. It should return (on standard output) the recognised speech.");
|
speechCommand = addTextField(optionsPanel, "Speech to text command (must take 1 filename parameter):", get("process.command"), "This specifies what command to run to recognize the speech. This command must take only one parameter, which is the full path of the WAV file. It should return (on standard output) the recognised speech.");
|
||||||
workerThreads = addSpinner(optionsPanel, "Worker threads:", 1, 100, 1, getInteger("process.threads"), "", "How many concurrent threads to run when processing speech. This should ideally be no more than the number of CPU cores you have in your computer.");
|
workerThreads = addSpinner(optionsPanel, "Worker threads:", 1, 100, 1, getInteger("process.threads"), "", "How many concurrent threads to run when processing speech. This should ideally be no more than the number of CPU cores you have in your computer minus one.");
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user