Added section break and stopped effects chain dropdown from intercepting keypresses

This commit is contained in:
2019-04-03 13:11:19 +01:00
parent c0efd152e8
commit 52b04a754c
4 changed files with 68 additions and 1 deletions

View File

@@ -515,6 +515,7 @@ public class AudiobookRecorder extends JFrame {
controlsBottom.add(new JLabel("Effects Chain: "));
effectChain = new JComboBox<KVPair<String, String>>();
effectChain.setFocusable(false);
controlsBottom.add(effectChain);
controlsBottom.add(sampleScroll);
@@ -555,6 +556,9 @@ public class AudiobookRecorder extends JFrame {
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");
@@ -592,6 +596,16 @@ public class AudiobookRecorder extends JFrame {
startRecordingNewParagraph();
}
});
centralPanel.getActionMap().put("startRecordNewSection", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (bookTree.isEditing()) return;
if (getNoiseFloor() == 0) {
alertNoRoomNoise();
return;
}
startRecordingNewSection();
}
});
centralPanel.getActionMap().put("startRerecord", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (bookTree.isEditing()) return;
@@ -1376,6 +1390,55 @@ public class AudiobookRecorder extends JFrame {
}
}
public void startRecordingNewSection() {
if (recording != null) return;
if (book == null) return;
if (microphone == null) {
JOptionPane.showMessageDialog(this, "Microphone not started. Start microphone first.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
if (selectedNode == null) {
selectedNode = book.getLastChapter();
bookTree.setSelectionPath(new TreePath(selectedNode.getPath()));
}
if (selectedNode instanceof Book) {
selectedNode = book.getLastChapter();
bookTree.setSelectionPath(new TreePath(selectedNode.getPath()));
}
if (selectedNode instanceof Sentence) {
selectedNode = (DefaultMutableTreeNode)selectedNode.getParent();
bookTree.setSelectionPath(new TreePath(selectedNode.getPath()));
}
Chapter c = (Chapter)selectedNode;
DefaultMutableTreeNode lastLeaf = c.getLastLeaf();
if (lastLeaf instanceof Sentence) {
Sentence lastSentence = (Sentence)lastLeaf;
lastSentence.setPostGap(Options.getInteger("catenation.post-section"));
}
Sentence s = new Sentence();
bookTreeModel.insertNodeInto(s, c, c.getChildCount());
bookTree.expandPath(new TreePath(c.getPath()));
bookTree.setSelectionPath(new TreePath(s.getPath()));
bookTree.scrollPathToVisible(new TreePath(s.getPath()));
if (s.startRecording()) {
recording = s;
centralPanel.setFlash(true);
}
}
public void startRecording() {
if (recording != null) return;

View File

@@ -57,7 +57,6 @@ public class DelayLine implements Effect {
public void init(double sf) {
for (DelayLineStore s : delayLines) {
s.init(sf);
s.purge();
}
}

View File

@@ -70,6 +70,7 @@ public class DelayLineStore {
for (Effect e : effects) {
e.init(sf);
}
purge();
}
public void dump() {

View File

@@ -31,6 +31,7 @@ public class Options extends JDialog {
JSpinner postSentenceGap;
JSpinner shortSentenceGap;
JSpinner postParagraphGap;
JSpinner postSectionGap;
JTextField ffmpegLocation;
JComboBox<KVPair> bitRate;
JComboBox<KVPair> exportRate;
@@ -313,6 +314,7 @@ public class Options extends JDialog {
postSentenceGap = addSpinner(optionsPanel, "Default post-sentence gap:", 0, 5000, 100, getInteger("catenation.post-sentence"), "ms");
shortSentenceGap = addSpinner(optionsPanel, "Short post-sentence gap:", 0, 5000, 100, getInteger("catenation.short-sentence"), "ms");
postParagraphGap = addSpinner(optionsPanel, "Default post-paragraph gap:", 0, 5000, 100, getInteger("catenation.post-paragraph"), "ms");
postSectionGap = addSpinner(optionsPanel, "Default post-section gap:", 0, 5000, 100, getInteger("catenation.post-section"), "ms");
addSeparator(optionsPanel);
@@ -572,6 +574,7 @@ public class Options extends JDialog {
defaultPrefs.put("catenation.post-sentence", "1000");
defaultPrefs.put("catenation.short-sentence", "100");
defaultPrefs.put("catenation.post-paragraph", "2000");
defaultPrefs.put("catenation.post-section", "3000");
defaultPrefs.put("audio.recording.trim.fft", "10");
@@ -703,6 +706,7 @@ public class Options extends JDialog {
set("catenation.post-sentence", postSentenceGap.getValue());
set("catenation.short-sentence", shortSentenceGap.getValue());
set("catenation.post-paragraph", postParagraphGap.getValue());
set("catenation.post-section", postSectionGap.getValue());
set("audio.export.bitrate", ((KVPair)bitRate.getSelectedItem()).key);
set("audio.export.samplerate", ((KVPair)exportRate.getSelectedItem()).key);
set("process.sphinx", enableParsing.isSelected());