Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ebe777bdc5 | |||
| 3b5cacb8ad | |||
| db7d297dbc | |||
| 2f9abf7629 | |||
| b6063d2fed | |||
| e1f566f0c8 | |||
| 9fa892a6fd | |||
| 1572e163ef | |||
| 2791691057 | |||
| 575537ae66 | |||
| fde4a597c7 | |||
| e69ae52f50 | |||
| 8bdb06749f |
@@ -1,7 +1,4 @@
|
||||
<effect name="Alien">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<lfo frequency="100" depth="0.5" />
|
||||
<!--biquad type="lowpass" fc="10000" q="1" gain="-10" /-->
|
||||
<lfo frequency="50" depth="1.0" waveform="triangle" mode="replace"/>
|
||||
</effect>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<effect name="Big Echo">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<delayline>
|
||||
<delay samples="22000" gain="0.2" pan="-0.3">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<agc ceiling="0.666" limit="1" attack="0.1" decay="0.01" />
|
||||
<agc ceiling="0.666" limit="1.5" attack="0.08" decay="0.01" />
|
||||
</effect>
|
||||
|
||||
15
ExampleFilters/cuthumagcstereo.eff
Normal file
15
ExampleFilters/cuthumagcstereo.eff
Normal file
@@ -0,0 +1,15 @@
|
||||
<effect name="Cut Computer Hum (with AGC and Stereo)">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<delayline wetonly="false">
|
||||
<delay samples="-100" gain="0.1" pan="-1.0">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="100" gain="0.1" pan="1.0">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
</delay>
|
||||
</delayline>
|
||||
<agc ceiling="0.666" limit="1.5" attack="0.1" decay="0.01" />
|
||||
</effect>
|
||||
@@ -1,7 +1,4 @@
|
||||
<effect name="Ethereal Voice">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<amplifier gain="0.1" />
|
||||
<delayline>
|
||||
<delay samples="2000" gain="1.0" pan="-0.3">
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<effect name="Large Room (quiet)">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<delayline>
|
||||
<delay samples="5500" gain="0.2" pan="-0.3">
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<effect name="Large Room (loud)">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<delayline>
|
||||
<delay samples="5500" gain="0.2" pan="-0.3">
|
||||
|
||||
3
ExampleFilters/panleft.eff
Normal file
3
ExampleFilters/panleft.eff
Normal file
@@ -0,0 +1,3 @@
|
||||
<effect name="Pan Left">
|
||||
<pan pan="-0.4" />
|
||||
</effect>
|
||||
3
ExampleFilters/panright.eff
Normal file
3
ExampleFilters/panright.eff
Normal file
@@ -0,0 +1,3 @@
|
||||
<effect name="Pan Right">
|
||||
<pan pan="0.4" />
|
||||
</effect>
|
||||
@@ -1,7 +1,4 @@
|
||||
<effect name="Telephone">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowshelf" fc="400" q="10" gain="-20" />
|
||||
<biquad type="highshelf" fc="8000" q="10" gain="-20" />
|
||||
<delayline>
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
<effect name="Radio">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<amplifier gain="0.1" />
|
||||
<biquad type="peak" fc="1000" q="10" gain="45" />
|
||||
<lfo frequency="5000" depth="0.3" />
|
||||
<clipping clip="0.3" />
|
||||
<amplifier gain="0.5" />
|
||||
<biquad type="peak" fc="1000" q="10" gain="25" />
|
||||
<lfo frequency="3000" depth="0.3" waveform="sine" mode="add" />
|
||||
<clipping clip="0.9" />
|
||||
<biquad type="highshelf" fc="8000" q="1" gain="-20" />
|
||||
<delayline>
|
||||
<delay samples="100" gain="0.7" />
|
||||
<delay samples="200" gain="0.5" />
|
||||
</delayline>
|
||||
<amplifier gain="0.3" />
|
||||
</effect>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<effect name="Robotic">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowshelf" fc="100" q="2" gain="-20" />
|
||||
<delayline>
|
||||
<delay samples="400" gain="1" pan="-0.3" />
|
||||
|
||||
10
ExampleFilters/stereochorus.eff
Normal file
10
ExampleFilters/stereochorus.eff
Normal file
@@ -0,0 +1,10 @@
|
||||
<effect name="Stereo Chorus">
|
||||
<delayline>
|
||||
<delay samples="2000" gain="0.1" pan="-0.3">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="4000" gain="0.1" pan="0.3">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
</delay>
|
||||
</delayline>
|
||||
</effect>
|
||||
@@ -1 +1 @@
|
||||
version=0.2.1
|
||||
version=0.3.2
|
||||
|
||||
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 |
@@ -26,6 +26,19 @@ import edu.cmu.sphinx.result.*;
|
||||
import org.w3c.dom.Node;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
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
|
||||
@@ -35,8 +48,6 @@ public class AudiobookRecorder extends JFrame {
|
||||
static Properties config = new Properties();
|
||||
TreeMap<String, EffectGroup> effects;
|
||||
|
||||
String defaultEffectChain = "none";
|
||||
|
||||
public final static int IDLE = 0;
|
||||
public final static int RECORDING = 1;
|
||||
public final static int STOPPING = 2;
|
||||
@@ -67,6 +78,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
JMenuItem toolsMerge;
|
||||
JMenuItem toolsArchive;
|
||||
JMenuItem toolsCoverArt;
|
||||
JMenuItem toolsManuscript;
|
||||
JMenuItem toolsOptions;
|
||||
|
||||
JMenuItem helpAbout;
|
||||
@@ -92,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;
|
||||
@@ -278,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) {
|
||||
@@ -288,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);
|
||||
|
||||
@@ -549,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("%"));
|
||||
|
||||
@@ -613,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;
|
||||
@@ -651,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;
|
||||
@@ -666,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;
|
||||
@@ -681,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;
|
||||
@@ -696,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;
|
||||
@@ -710,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();
|
||||
@@ -718,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();
|
||||
}
|
||||
@@ -725,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();
|
||||
@@ -736,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();
|
||||
@@ -744,24 +780,60 @@ 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("")) {
|
||||
File f = new File(Options.get("path.storage"), lastBook);
|
||||
if (f.exists() && f.isDirectory()) {
|
||||
File x = new File(f, "audiobook.abk");
|
||||
if (x.exists()) {
|
||||
loadBookStructure(x);
|
||||
File y = new File(f, "audiobook.abx");
|
||||
if (y.exists()) {
|
||||
loadXMLBookStructure(y);
|
||||
} else {
|
||||
File x = new File(f, "audiobook.abk");
|
||||
if (x.exists()) {
|
||||
loadBookStructure(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -779,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"));
|
||||
@@ -803,30 +919,44 @@ public class AudiobookRecorder extends JFrame {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Properties prefs = new Properties();
|
||||
Book newbook = new Book(prefs, info.getTitle().trim());
|
||||
newbook.setAuthor(info.getAuthor().trim());
|
||||
newbook.setGenre(info.getGenre().trim());
|
||||
newbook.setComment(info.getComment().trim());
|
||||
newbook.setACX(info.getACX().trim());
|
||||
|
||||
Properties prefs = new Properties();
|
||||
Chapter caud = new Chapter("audition", "Audition");
|
||||
Chapter copen = new Chapter("open", "Opening Credits");
|
||||
Chapter cone = new Chapter("0001", "Chapter 1");
|
||||
Chapter cclose = new Chapter("close", "Closing Credits");
|
||||
|
||||
prefs.setProperty("book.name", info.getTitle());
|
||||
prefs.setProperty("book.author", info.getAuthor());
|
||||
prefs.setProperty("book.genre", info.getGenre());
|
||||
prefs.setProperty("book.comment", info.getComment());
|
||||
prefs.setProperty("book.acx", info.getACX());
|
||||
prefs.setProperty("chapter.audition.name", "Audition");
|
||||
prefs.setProperty("chapter.audition.pre-gap", Options.get("catenation.pre-chapter"));
|
||||
prefs.setProperty("chapter.audition.post-gap", Options.get("catenation.post-chapter"));
|
||||
prefs.setProperty("chapter.open.name", "Opening Credits");
|
||||
prefs.setProperty("chapter.open.pre-gap", Options.get("catenation.pre-chapter"));
|
||||
prefs.setProperty("chapter.open.post-gap", Options.get("catenation.post-chapter"));
|
||||
prefs.setProperty("chapter.0001.name", "Chapter 1");
|
||||
prefs.setProperty("chapter.0001.pre-gap", Options.get("catenation.pre-chapter"));
|
||||
prefs.setProperty("chapter.0001.post-gap", Options.get("catenation.post-chapter"));
|
||||
prefs.setProperty("chapter.close.name", "Closing Credits");
|
||||
prefs.setProperty("chapter.close.pre-gap", Options.get("catenation.pre-chapter"));
|
||||
prefs.setProperty("chapter.close.post-gap", Options.get("catenation.post-chapter"));
|
||||
newbook.add(caud);
|
||||
newbook.add(copen);
|
||||
newbook.add(cone);
|
||||
newbook.add(cclose);
|
||||
|
||||
buildBook(prefs);
|
||||
File bookRoot = new File(Options.get("path.storage"), newbook.getName());
|
||||
if (!bookRoot.exists()) {
|
||||
bookRoot.mkdirs();
|
||||
}
|
||||
|
||||
Options.set("path.last-book", book.getName());
|
||||
File xml = new File(bookRoot, "audiobook.abx");
|
||||
Document doc = newbook.buildDocument();
|
||||
|
||||
|
||||
// write the content into xml file
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
DOMSource source = new DOMSource(doc);
|
||||
StreamResult result = new StreamResult(xml);
|
||||
transformer.transform(source, result);
|
||||
|
||||
loadXMLBookStructure(xml);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
class JMenuObject extends JMenuItem {
|
||||
@@ -924,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) {
|
||||
@@ -1426,7 +1555,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
int i = 0;
|
||||
if (effects != null) {
|
||||
for (String k : effects.keySet()) {
|
||||
if (k.equals(defaultEffectChain)) {
|
||||
if (k.equals(book.getDefaultEffect())) {
|
||||
selEff = i;
|
||||
}
|
||||
KVPair<String, String> p = new KVPair<String, String>(k, effects.get(k).toString());
|
||||
@@ -1452,7 +1581,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
i = defEff.getSelectedIndex();
|
||||
KVPair<String, String> de = defEff.getItemAt(i);
|
||||
defaultEffectChain = de.getKey();
|
||||
book.setDefaultEffect(de.getKey());
|
||||
|
||||
book.setAuthor(aut);
|
||||
book.setGenre(gen);
|
||||
@@ -1797,53 +1926,136 @@ public class AudiobookRecorder extends JFrame {
|
||||
bookRoot.mkdirs();
|
||||
}
|
||||
|
||||
File config = new File(bookRoot, "audiobook.abk");
|
||||
Properties prefs = new Properties();
|
||||
|
||||
prefs.setProperty("book.name", book.getName());
|
||||
prefs.setProperty("book.author", book.getAuthor());
|
||||
prefs.setProperty("book.genre", book.getGenre());
|
||||
prefs.setProperty("book.comment", book.getComment());
|
||||
prefs.setProperty("book.acx", book.getACX());
|
||||
|
||||
prefs.setProperty("audio.recording.samplerate", "" + book.getSampleRate());
|
||||
prefs.setProperty("audio.recording.resolution", "" + book.getResolution());
|
||||
prefs.setProperty("audio.recording.channels", "" + book.getChannels());
|
||||
|
||||
prefs.setProperty("audio.effect.default", defaultEffectChain);
|
||||
|
||||
for (Enumeration o = book.children(); o.hasMoreElements();) {
|
||||
|
||||
Chapter c = (Chapter)o.nextElement();
|
||||
String keybase = "chapter." + c.getId();
|
||||
prefs.setProperty(keybase + ".name", c.getName());
|
||||
prefs.setProperty(keybase + ".pre-gap", Integer.toString(c.getPreGap()));
|
||||
prefs.setProperty(keybase + ".post-gap", Integer.toString(c.getPostGap()));
|
||||
|
||||
int i = 0;
|
||||
for (Enumeration s = c.children(); s.hasMoreElements();) {
|
||||
Sentence snt = (Sentence)s.nextElement();
|
||||
TreeMap<String, String> settings = snt.getSentenceData();
|
||||
for (String key : settings.keySet()) {
|
||||
prefs.setProperty(String.format("%s.sentence.%08d.%s", keybase, i, key), settings.get(key));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
FileOutputStream fos = null;
|
||||
|
||||
try {
|
||||
fos = new FileOutputStream(config);
|
||||
prefs.storeToXML(fos, "Audiobook Recorder Description");
|
||||
File xml = new File(bookRoot, "audiobook.abx");
|
||||
Document doc = book.buildDocument();
|
||||
|
||||
|
||||
// write the content into xml file
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
DOMSource source = new DOMSource(doc);
|
||||
StreamResult result = new StreamResult(xml);
|
||||
transformer.transform(source, result);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (fos != null) {
|
||||
try {
|
||||
fos.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
public void loadXMLBookStructure(File inputFile) {
|
||||
|
||||
try {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document doc = dBuilder.parse(inputFile);
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
Element root = doc.getDocumentElement();
|
||||
|
||||
book = new Book(root);
|
||||
|
||||
bookTreeModel = new DefaultTreeModel(book);
|
||||
|
||||
book.loadBookXML(root, bookTreeModel);
|
||||
|
||||
loadEffects();
|
||||
|
||||
bookTree = new JTree(bookTreeModel);
|
||||
bookTree.setEditable(true);
|
||||
bookTree.setUI(new CustomTreeUI(mainScroll));
|
||||
|
||||
bookTree.setCellRenderer(new BookTreeRenderer());
|
||||
|
||||
|
||||
InputMap im = bookTree.getInputMap(JComponent.WHEN_FOCUSED);
|
||||
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "startStopPlayback");
|
||||
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.SHIFT_DOWN_MASK), "startPlaybackFrom");
|
||||
|
||||
roomNoise = new Sentence("room-noise", "Room Noise");
|
||||
|
||||
bookTree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
DefaultMutableTreeNode n = (DefaultMutableTreeNode)bookTree.getLastSelectedPathComponent();
|
||||
if (n instanceof Sentence) {
|
||||
Sentence s = (Sentence)n;
|
||||
selectedSentence = s;
|
||||
sampleWaveform.setData(s.getDoubleAudioData(effectsEnabled));
|
||||
sampleWaveform.setMarkers(s.getStartOffset(), s.getEndOffset());
|
||||
s.updateCrossings();
|
||||
sampleWaveform.setAltMarkers(s.getStartCrossing(), s.getEndCrossing());
|
||||
postSentenceGap.setValue(s.getPostGap());
|
||||
gainPercent.setValue((int)(s.getGain() * 100d));
|
||||
locked.setSelected(s.isLocked());
|
||||
attention.setSelected(s.getAttentionFlag());
|
||||
|
||||
setEffectChain(s.getEffectChain());
|
||||
|
||||
postSentenceGap.setEnabled(!s.isLocked());
|
||||
gainPercent.setEnabled(!s.isLocked());
|
||||
reprocessAudioFFT.setEnabled(!s.isLocked());
|
||||
reprocessAudioPeak.setEnabled(!s.isLocked());
|
||||
selectCutMode.setEnabled(!s.isLocked());
|
||||
selectSplitMode.setEnabled(!s.isLocked());
|
||||
doCutSplit.setEnabled(false);
|
||||
selectCutMode.setSelected(false);
|
||||
selectSplitMode.setSelected(false);
|
||||
} else {
|
||||
selectedSentence = null;
|
||||
sampleWaveform.clearData();
|
||||
postSentenceGap.setValue(0);
|
||||
gainPercent.setValue(100);
|
||||
locked.setSelected(false);
|
||||
attention.setSelected(false);
|
||||
selectCutMode.setEnabled(false);
|
||||
selectSplitMode.setEnabled(false);
|
||||
doCutSplit.setEnabled(false);
|
||||
selectCutMode.setSelected(false);
|
||||
selectSplitMode.setSelected(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
bookTree.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
treePopup(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
treePopup(e);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mainScroll.setViewportView(bookTree);
|
||||
File r = inputFile.getParentFile();
|
||||
|
||||
File cf = new File(r, "coverart.png");
|
||||
if (!cf.exists()) {
|
||||
cf = new File(r, "coverart.jpg");
|
||||
if (!cf.exists()) {
|
||||
cf = new File(r, "coverart.gif");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
bookTree.expandPath(new TreePath(book.getPath()));
|
||||
|
||||
statusLabel.setText("Noise floor: " + getNoiseFloorDB() + "dB");
|
||||
book.setIcon(Icons.book);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1876,6 +2088,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
/* Retained for legacy use...! */
|
||||
public void buildBook(Properties prefs) {
|
||||
|
||||
book = new Book(prefs, prefs.getProperty("book.name"));
|
||||
@@ -1887,11 +2100,14 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
loadEffects();
|
||||
|
||||
defaultEffectChain = prefs.getProperty("audio.effect.default");
|
||||
String defaultEffectChain = prefs.getProperty("audio.effect.default");
|
||||
|
||||
if (defaultEffectChain == null) {
|
||||
defaultEffectChain = "none";
|
||||
}
|
||||
|
||||
book.setDefaultEffect(defaultEffectChain);
|
||||
|
||||
int sr = Utils.s2i(prefs.getProperty("audio.recording.samplerate"));
|
||||
if (sr == 0) {
|
||||
sr = Options.getInteger("audio.recording.samplerate");
|
||||
@@ -2103,12 +2319,16 @@ public class AudiobookRecorder extends JFrame {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!f.getName().endsWith(".abk")) {
|
||||
JOptionPane.showMessageDialog(this, "Not a .abk file.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
if (!(f.getName().endsWith(".abk") || f.getName().endsWith(".abx"))) {
|
||||
JOptionPane.showMessageDialog(this, "Not a .abk or .abx file.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
loadBookStructure(f);
|
||||
if (f.getName().endsWith(".abx")) {
|
||||
loadXMLBookStructure(f);
|
||||
} else {
|
||||
loadBookStructure(f);
|
||||
}
|
||||
|
||||
Options.set("path.last-book", book.getName());
|
||||
Options.savePreferences();
|
||||
@@ -2517,7 +2737,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
if (roomNoise == null) return null;
|
||||
|
||||
roomNoise.setEffectChain(defaultEffectChain);
|
||||
roomNoise.setEffectChain(book.getDefaultEffect());
|
||||
|
||||
int len = roomNoise.getSampleSize();
|
||||
if (len == 0) return null;
|
||||
@@ -2629,8 +2849,8 @@ public class AudiobookRecorder extends JFrame {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!f.getName().endsWith(".abk")) {
|
||||
JOptionPane.showMessageDialog(this, "Not a .abk file.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
if (!(f.getName().endsWith(".abk") || f.getName().endsWith(".abx"))) {
|
||||
JOptionPane.showMessageDialog(this, "Not a .abk or .abx file.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2875,7 +3095,16 @@ public class AudiobookRecorder extends JFrame {
|
||||
File f = jc.getSelectedFile();
|
||||
if (f.exists()) {
|
||||
|
||||
BookPanel pan = null;
|
||||
|
||||
try {
|
||||
|
||||
String bookName = null;
|
||||
String bookAuthor = null;
|
||||
String bookGenre = null;
|
||||
String bookComment = null;
|
||||
ImageIcon bookCover = null;
|
||||
|
||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(f)) {
|
||||
public void close() throws IOException {
|
||||
return;
|
||||
@@ -2885,15 +3114,28 @@ public class AudiobookRecorder extends JFrame {
|
||||
ImageIcon cover = null;
|
||||
Properties props = new Properties();
|
||||
|
||||
boolean gotMeta = false;
|
||||
boolean gotCover = false;
|
||||
|
||||
while ((entry = zis.getNextEntry()) != null) {
|
||||
if (gotMeta && gotCover) break;
|
||||
|
||||
if (entry.getName().endsWith("/audiobook.abk")) {
|
||||
props.loadFromXML(zis);
|
||||
gotMeta = true;
|
||||
|
||||
if (bookName == null) bookName = props.getProperty("book.name");
|
||||
if (bookAuthor == null) bookAuthor = props.getProperty("book.author");
|
||||
if (bookGenre == null) bookGenre = props.getProperty("book.genre");
|
||||
if (bookComment == null) bookComment = props.getProperty("book.comment");
|
||||
}
|
||||
|
||||
if (entry.getName().endsWith("/audiobook.abx")) {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document doc = dBuilder.parse(zis);
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
Element rootnode = doc.getDocumentElement();
|
||||
|
||||
bookName = Book.getTextNode(rootnode, "title");
|
||||
bookAuthor = Book.getTextNode(rootnode, "author");
|
||||
bookGenre = Book.getTextNode(rootnode, "genre");
|
||||
bookComment = Book.getTextNode(rootnode, "comment");
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -2901,13 +3143,13 @@ public class AudiobookRecorder extends JFrame {
|
||||
entry.getName().endsWith("/coverart.jpg") ||
|
||||
entry.getName().endsWith("/coverart.gif")
|
||||
) {
|
||||
cover = new ImageIcon(ImageIO.read(zis));
|
||||
gotCover = true;
|
||||
bookCover = new ImageIcon(ImageIO.read(zis));
|
||||
}
|
||||
}
|
||||
zis.close();
|
||||
|
||||
BookPanel pan = new BookPanel(props, cover);
|
||||
pan = new BookPanel(bookName, bookAuthor, bookGenre, bookComment, bookCover);
|
||||
|
||||
int okToImport = JOptionPane.showConfirmDialog(this, pan, "Import this book?", JOptionPane.OK_CANCEL_OPTION);
|
||||
if (okToImport == JOptionPane.OK_OPTION) {
|
||||
zis = new ZipInputStream(new FileInputStream(f));
|
||||
@@ -2928,8 +3170,13 @@ public class AudiobookRecorder extends JFrame {
|
||||
zis.close();
|
||||
|
||||
File bookdir = new File(Options.get("path.storage"), props.getProperty("book.name"));
|
||||
File conf = new File(bookdir, "audiobook.abk");
|
||||
loadBookStructure(conf);
|
||||
File conf = new File(bookdir, "audiobook.abx");
|
||||
if (conf.exists()) {
|
||||
loadXMLBookStructure(conf);
|
||||
} else {
|
||||
conf = new File(bookdir, "audiobook.abk");
|
||||
loadBookStructure(conf);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -3227,7 +3474,40 @@ public class AudiobookRecorder extends JFrame {
|
||||
double f = Utils.s2d(root.getAttribute("frequency"));
|
||||
double d = Utils.s2d(root.getAttribute("depth"));
|
||||
double p = Utils.s2d(root.getAttribute("phase"));
|
||||
return new LFO(f, d, p);
|
||||
double dty = Math.PI;
|
||||
String waveform = root.getAttribute("waveform");
|
||||
if (waveform == null) {
|
||||
waveform = "sine";
|
||||
}
|
||||
|
||||
int w = LFO.SINE;
|
||||
|
||||
switch (waveform.toLowerCase()) {
|
||||
case "sine": w = LFO.SINE; break;
|
||||
case "cosine": w = LFO.COSINE; break;
|
||||
case "square": w = LFO.SQUARE; break;
|
||||
case "triangle": w = LFO.TRIANGLE; break;
|
||||
case "sawtooth": w = LFO.SAWTOOTH; break;
|
||||
}
|
||||
|
||||
int m = LFO.ADD;
|
||||
|
||||
String mode = root.getAttribute("mode");
|
||||
|
||||
if (mode == null) {
|
||||
mode = "add";
|
||||
}
|
||||
|
||||
switch (mode.toLowerCase()) {
|
||||
case "add": m = LFO.ADD; break;
|
||||
case "replace": m = LFO.REPLACE; break;
|
||||
}
|
||||
|
||||
if (root.getAttribute("duty") != null) {
|
||||
int di = Utils.s2i(root.getAttribute("duty")); // 0-100;
|
||||
dty = (Math.PI * 2) * ((double)di / 100d);
|
||||
}
|
||||
return new LFO(f, d, p, w, dty, m);
|
||||
}
|
||||
|
||||
public AGC loadAGC(Element root) {
|
||||
@@ -3262,7 +3542,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
if (ent != null) {
|
||||
setEffectChain(ent.getKey());
|
||||
} else {
|
||||
setEffectChain(defaultEffectChain);
|
||||
setEffectChain(book.getDefaultEffect());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3276,8 +3556,8 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
if (effects.get(defaultEffectChain) != null) {
|
||||
setEffectChain(defaultEffectChain);
|
||||
if (effects.get(book.getDefaultEffect()) != null) {
|
||||
setEffectChain(book.getDefaultEffect());
|
||||
updateWaveform();
|
||||
} else {
|
||||
effectChain.setSelectedIndex(0);
|
||||
@@ -3286,7 +3566,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
|
||||
public String getDefaultEffectsChain() {
|
||||
return defaultEffectChain;
|
||||
return book.getDefaultEffect();
|
||||
}
|
||||
|
||||
public synchronized boolean getLock() {
|
||||
@@ -3407,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,20 @@ import java.nio.file.*;
|
||||
import javax.swing.tree.*;
|
||||
import javax.sound.sampled.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class Book extends DefaultMutableTreeNode {
|
||||
|
||||
String name;
|
||||
@@ -17,6 +31,9 @@ public class Book extends DefaultMutableTreeNode {
|
||||
String genre;
|
||||
String comment;
|
||||
String ACX;
|
||||
String manuscript;
|
||||
|
||||
String defaultEffect = "none";
|
||||
|
||||
int sampleRate;
|
||||
int channels;
|
||||
@@ -31,7 +48,60 @@ public class Book extends DefaultMutableTreeNode {
|
||||
|
||||
prefs = p;
|
||||
name = bookname;
|
||||
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name);
|
||||
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name); // This should be in the load routine!!!!
|
||||
}
|
||||
|
||||
public Book(Element root) {
|
||||
super(getTextNode(root, "title"));
|
||||
|
||||
name = getTextNode(root, "title");
|
||||
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name); // This should be in the load routine!!!!
|
||||
}
|
||||
|
||||
public void loadBookXML(Element root, DefaultTreeModel model) {
|
||||
name = getTextNode(root, "title");
|
||||
author = getTextNode(root, "author");
|
||||
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");
|
||||
Element effectSettings = getNode(settings, "effects");
|
||||
|
||||
sampleRate = Utils.s2i(getTextNode(audioSettings, "samplerate"));
|
||||
channels = Utils.s2i(getTextNode(audioSettings, "channels"));
|
||||
resolution = Utils.s2i(getTextNode(audioSettings, "resolution"));
|
||||
|
||||
defaultEffect = getTextNode(settings, "default");
|
||||
|
||||
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name); // This should be in the load routine!!!!
|
||||
|
||||
Element chapters = getNode(root, "chapters");
|
||||
|
||||
NodeList chapterList = chapters.getElementsByTagName("chapter");
|
||||
|
||||
for (int i = 0; i < chapterList.getLength(); i++) {
|
||||
Element chapterElement = (Element)chapterList.item(i);
|
||||
Chapter newChapter = new Chapter(chapterElement, model);
|
||||
model.insertNodeInto(newChapter, this, getChildCount());
|
||||
}
|
||||
}
|
||||
|
||||
public static Element getNode(Element r, String n) {
|
||||
NodeList nl = r.getElementsByTagName(n);
|
||||
if (nl == null) return null;
|
||||
if (nl.getLength() == 0) return null;
|
||||
return (Element)nl.item(0);
|
||||
}
|
||||
|
||||
public static String getTextNode(Element r, String n) {
|
||||
Element node = getNode(r, n);
|
||||
if (node == null) return "";
|
||||
return node.getTextContent();
|
||||
}
|
||||
|
||||
public void setAuthor(String a) { author = a; }
|
||||
@@ -115,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()) {
|
||||
@@ -216,4 +290,108 @@ public class Book extends DefaultMutableTreeNode {
|
||||
}
|
||||
}
|
||||
|
||||
public Document buildDocument() throws ParserConfigurationException {
|
||||
DocumentBuilderFactory dbFactory =
|
||||
DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document doc = dBuilder.newDocument();
|
||||
|
||||
Element root = doc.createElement("book");
|
||||
doc.appendChild(root);
|
||||
|
||||
root.appendChild(makeTextNode(doc, "title", name));
|
||||
root.appendChild(makeTextNode(doc, "author", author));
|
||||
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);
|
||||
|
||||
Element audioSettingsNode = doc.createElement("audio");
|
||||
settingsNode.appendChild(audioSettingsNode);
|
||||
|
||||
audioSettingsNode.appendChild(makeTextNode(doc, "channels", channels));
|
||||
audioSettingsNode.appendChild(makeTextNode(doc, "resolution", resolution));
|
||||
audioSettingsNode.appendChild(makeTextNode(doc, "samplerate", sampleRate));
|
||||
|
||||
Element effectsNode = doc.createElement("effects");
|
||||
settingsNode.appendChild(effectsNode);
|
||||
|
||||
effectsNode.appendChild(makeTextNode(doc, "default", defaultEffect));
|
||||
|
||||
Element chaptersNode = doc.createElement("chapters");
|
||||
|
||||
root.appendChild(chaptersNode);
|
||||
|
||||
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||
Object ob = (Object)o.nextElement();
|
||||
if (ob instanceof Chapter) {
|
||||
Chapter c = (Chapter)ob;
|
||||
chaptersNode.appendChild(c.getChapterXML(doc));
|
||||
}
|
||||
}
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
public static Element makeTextNode(Document doc, String name, String text) {
|
||||
Element node = doc.createElement(name);
|
||||
Text tnode = doc.createTextNode(text == null ? "" : text);
|
||||
node.appendChild(tnode);
|
||||
return node;
|
||||
}
|
||||
|
||||
public static Element makeTextNode(Document doc, String name, Integer text) {
|
||||
Element node = doc.createElement(name);
|
||||
Text tnode = doc.createTextNode(Integer.toString(text));
|
||||
node.appendChild(tnode);
|
||||
return node;
|
||||
}
|
||||
|
||||
public static Element makeTextNode(Document doc, String name, Double text) {
|
||||
Element node = doc.createElement(name);
|
||||
Text tnode = doc.createTextNode(String.format("%.8f", text));
|
||||
node.appendChild(tnode);
|
||||
return node;
|
||||
}
|
||||
|
||||
public static Element makeTextNode(Document doc, String name, Boolean text) {
|
||||
Element node = doc.createElement(name);
|
||||
Text tnode = doc.createTextNode(text ? "true" : "false");
|
||||
node.appendChild(tnode);
|
||||
return node;
|
||||
}
|
||||
|
||||
public String getDefaultEffect() {
|
||||
return defaultEffect;
|
||||
}
|
||||
|
||||
public void setDefaultEffect(String 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,20 @@ import javax.swing.border.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class BookPanel extends JPanel {
|
||||
String name;
|
||||
String author;
|
||||
@@ -25,6 +39,7 @@ public class BookPanel extends JPanel {
|
||||
JPanel panel;
|
||||
|
||||
File root;
|
||||
File configFile;
|
||||
|
||||
boolean highlight = false;
|
||||
|
||||
@@ -36,13 +51,78 @@ public class BookPanel extends JPanel {
|
||||
try {
|
||||
root = r;
|
||||
Properties props = new Properties();
|
||||
props.loadFromXML(new FileInputStream(new File(root, "audiobook.abk")));
|
||||
loadBookData(props, null);
|
||||
|
||||
configFile = new File(root, "audiobook.abx");
|
||||
|
||||
if (configFile.exists()) {
|
||||
loadXMLData(configFile);
|
||||
} else {
|
||||
configFile = new File(root, "audiobook.abk");
|
||||
props.loadFromXML(new FileInputStream(configFile));
|
||||
loadBookData(props, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public BookPanel(String n, String a, String g, String c, ImageIcon i) {
|
||||
name = n;
|
||||
author = a;
|
||||
genre = g;
|
||||
comment = c;
|
||||
cover = i;
|
||||
if (i != null) {
|
||||
cover = i;
|
||||
resizedCover = Utils.getScaledImage(cover.getImage(), 75, 75);
|
||||
iconLabel = new JLabel(new ImageIcon(resizedCover));
|
||||
} else {
|
||||
cover = null;
|
||||
resizedCover = null;
|
||||
iconLabel = new JLabel("");
|
||||
}
|
||||
populate();
|
||||
}
|
||||
|
||||
public void loadXMLData(File inputFile) {
|
||||
try {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document doc = dBuilder.parse(inputFile);
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
Element rootnode = doc.getDocumentElement();
|
||||
|
||||
name = Book.getTextNode(rootnode, "title");
|
||||
author = Book.getTextNode(rootnode, "author");
|
||||
genre = Book.getTextNode(rootnode, "genre");
|
||||
comment = Book.getTextNode(rootnode, "comment");
|
||||
|
||||
File icon = new File(root, "coverart.png");
|
||||
if (!icon.exists()) {
|
||||
icon = new File(root, "coverart.jpg");
|
||||
}
|
||||
if (!icon.exists()) {
|
||||
icon = new File(root, "coverart.gif");
|
||||
}
|
||||
|
||||
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("");
|
||||
}
|
||||
|
||||
populate();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void loadBookData(Properties props, ImageIcon i) {
|
||||
try {
|
||||
name = props.getProperty("book.name");
|
||||
@@ -71,41 +151,44 @@ public class BookPanel extends JPanel {
|
||||
resizedCover = Utils.getScaledImage(cover.getImage(), 75, 75);
|
||||
iconLabel = new JLabel(new ImageIcon(resizedCover));
|
||||
}
|
||||
|
||||
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);
|
||||
populate();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
void populate() {
|
||||
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);
|
||||
}
|
||||
|
||||
public File getConfigFile() {
|
||||
return new File(root, "audiobook.abk");
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void highlight() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
icn.add(Overlays.important, OverlayIcon.TOP_RIGHT);
|
||||
}
|
||||
|
||||
if (s.getEndOffset() == s.getSampleSize() - 1) {
|
||||
icn.add(Overlays.important, OverlayIcon.TOP_RIGHT);
|
||||
}
|
||||
|
||||
if (s.getEffectChain() != null) {
|
||||
if (!s.getEffectChain().equals("none")) {
|
||||
icn.add(Overlays.filter, OverlayIcon.BOTTOM_RIGHT);
|
||||
|
||||
@@ -12,6 +12,19 @@ import it.sauronsoftware.jave.*;
|
||||
import com.mpatric.mp3agic.*;
|
||||
import javax.sound.sampled.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class Chapter extends DefaultMutableTreeNode {
|
||||
|
||||
@@ -28,7 +41,23 @@ public class Chapter extends DefaultMutableTreeNode {
|
||||
name = chaptername;
|
||||
preGap = Options.getInteger("catenation.pre-chapter");
|
||||
postGap = Options.getInteger("catenation.post-chapter");
|
||||
}
|
||||
|
||||
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"));
|
||||
|
||||
Element sentencesNode = Book.getNode(root, "sentences");
|
||||
NodeList sentences = sentencesNode.getElementsByTagName("sentence");
|
||||
|
||||
for (int i = 0; i < sentences.getLength(); i++) {
|
||||
Element sentenceElement = (Element)sentences.item(i);
|
||||
Sentence newSentence = new Sentence(sentenceElement);
|
||||
model.insertNodeInto(newSentence, this, getChildCount());
|
||||
}
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
@@ -249,4 +278,25 @@ public class Chapter extends DefaultMutableTreeNode {
|
||||
}
|
||||
}
|
||||
|
||||
public Element getChapterXML(Document doc) {
|
||||
Element chapterNode = doc.createElement("chapter");
|
||||
chapterNode.setAttribute("id", id);
|
||||
chapterNode.appendChild(Book.makeTextNode(doc, "name", name));
|
||||
chapterNode.appendChild(Book.makeTextNode(doc, "pre-gap", preGap));
|
||||
chapterNode.appendChild(Book.makeTextNode(doc, "post-gap", postGap));
|
||||
|
||||
Element sentencesNode = doc.createElement("sentences");
|
||||
chapterNode.appendChild(sentencesNode);
|
||||
|
||||
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||
Object ob = (Object)o.nextElement();
|
||||
if (ob instanceof Sentence) {
|
||||
Sentence s = (Sentence)ob;
|
||||
sentencesNode.appendChild(s.getSentenceXML(doc));
|
||||
}
|
||||
}
|
||||
|
||||
return chapterNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
@@ -9,37 +9,73 @@ public class LFO implements Effect {
|
||||
double depth;
|
||||
double sampleRate;
|
||||
double sampleStep;
|
||||
int waveform;
|
||||
double duty;
|
||||
int mode;
|
||||
|
||||
public static final int SINE = 0;
|
||||
public static final int COSINE = 1;
|
||||
public static final int SQUARE = 2;
|
||||
public static final int TRIANGLE = 3;
|
||||
public static final int SAWTOOTH = 4;
|
||||
|
||||
public static final int ADD = 0;
|
||||
public static final int REPLACE = 1;
|
||||
|
||||
public LFO(double f, double d) {
|
||||
frequency = f;
|
||||
depth = d;
|
||||
phase = 0;
|
||||
this(f, d, 0, SINE, Math.PI, REPLACE);
|
||||
}
|
||||
|
||||
public LFO(double f, double d, double p) {
|
||||
this(f, d, p, SINE, Math.PI, REPLACE);
|
||||
}
|
||||
|
||||
public LFO(double f, double d, double p, int w) {
|
||||
this(f, d, p, w, Math.PI, REPLACE);
|
||||
}
|
||||
|
||||
public LFO(double f, double d, double p, int w, double dty) {
|
||||
this(f, d, p, w, dty, REPLACE);
|
||||
}
|
||||
|
||||
public LFO(double f, double d, double p, int w, double dty, int m) {
|
||||
frequency = f;
|
||||
depth = d;
|
||||
phase = p;
|
||||
waveform = w;
|
||||
duty = dty;
|
||||
mode = m;
|
||||
}
|
||||
|
||||
public void process(double[][] samples) {
|
||||
for (double[] sample : samples) {
|
||||
double v = Math.sin(phase);
|
||||
double v = 0;
|
||||
switch (waveform) {
|
||||
case SINE: v = Math.sin(phase); break;
|
||||
case COSINE: v = Math.cos(phase); break;
|
||||
case SQUARE: v = (phase > duty) ? 1d : 0d; break;
|
||||
case TRIANGLE: v = (phase < Math.PI) ? (phase / Math.PI) : (1d - ((phase - Math.PI) / Math.PI)); break;
|
||||
case SAWTOOTH: v = (phase / (Math.PI*2d)); break;
|
||||
}
|
||||
phase += sampleStep;
|
||||
if (phase > (Math.PI * 2d)) {
|
||||
phase -= (Math.PI * 2d);
|
||||
}
|
||||
|
||||
// // Make it between 0 and 1.
|
||||
// v = 1d + v;
|
||||
// v /= 2d;
|
||||
|
||||
// Multiply it by the gain factor
|
||||
v *= depth;
|
||||
|
||||
// Apply it to the sample
|
||||
sample[Sentence.LEFT] += (sample[Sentence.LEFT] * v);
|
||||
sample[Sentence.RIGHT] += (sample[Sentence.RIGHT] * v);
|
||||
switch (mode) {
|
||||
case REPLACE:
|
||||
sample[Sentence.LEFT] = (sample[Sentence.LEFT] * v);
|
||||
sample[Sentence.RIGHT] = (sample[Sentence.RIGHT] * v);
|
||||
break;
|
||||
case ADD:
|
||||
sample[Sentence.LEFT] += (sample[Sentence.LEFT] * v);
|
||||
sample[Sentence.RIGHT] += (sample[Sentence.RIGHT] * v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,10 +86,16 @@ public class OpenBookPanel extends JPanel {
|
||||
for (File b : dir.listFiles()) {
|
||||
if (b == null) continue;
|
||||
if (!b.isDirectory()) continue;
|
||||
File xml = new File(b, "audiobook.abk");
|
||||
File xml = new File(b, "audiobook.abx");
|
||||
if (xml.exists()) {
|
||||
BookPanel book = new BookPanel(b);
|
||||
model.addBook(book);
|
||||
} else {
|
||||
xml = new File(b, "audiobook.abk");
|
||||
if (xml.exists()) {
|
||||
BookPanel book = new BookPanel(b);
|
||||
model.addBook(book);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,17 @@ import org.json.*;
|
||||
|
||||
import java.util.Timer;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
|
||||
@@ -155,6 +166,22 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
postGap = Options.getInteger("catenation.post-sentence");
|
||||
}
|
||||
|
||||
public Sentence(Element root) {
|
||||
super("");
|
||||
id = root.getAttribute("id");
|
||||
text = Book.getTextNode(root, "text");
|
||||
setUserObject(text);
|
||||
setPostGap(Utils.s2i(Book.getTextNode(root, "post-gap")));
|
||||
setStartOffset(Utils.s2i(Book.getTextNode(root, "start-offset")));
|
||||
setEndOffset(Utils.s2i(Book.getTextNode(root, "end-offset")));
|
||||
setLocked(Utils.s2b(Book.getTextNode(root, "locked")));
|
||||
setAttentionFlag(Utils.s2b(Book.getTextNode(root, "attention")));
|
||||
setGain(Utils.s2d(Book.getTextNode(root, "gain")));
|
||||
setEffectChain(Book.getTextNode(root, "effect"));
|
||||
setPostGapType(Book.getTextNode(root, "gaptype"));
|
||||
sampleSize = Utils.s2i(Book.getTextNode(root, "samples"));
|
||||
}
|
||||
|
||||
public boolean startRecording() {
|
||||
if (AudiobookRecorder.window.microphone == null) {
|
||||
JOptionPane.showMessageDialog(AudiobookRecorder.window, "Microphone not started. Start the microphone first.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
@@ -679,17 +706,21 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
}
|
||||
|
||||
public double getPeakValue() {
|
||||
return getPeakValue(false);
|
||||
return getPeakValue(false, true);
|
||||
}
|
||||
|
||||
public double getPeakValue(boolean useRaw) {
|
||||
return getPeakValue(useRaw, true);
|
||||
}
|
||||
|
||||
public double getPeakValue(boolean useRaw, boolean applyGain) {
|
||||
double oldGain = gain;
|
||||
gain = 1.0d;
|
||||
double[][] samples = null;
|
||||
if (useRaw) {
|
||||
samples = getRawAudioData();
|
||||
} else {
|
||||
samples = getProcessedAudioData();
|
||||
samples = getProcessedAudioData(true, applyGain);
|
||||
}
|
||||
gain = oldGain;
|
||||
if (samples == null) {
|
||||
@@ -731,7 +762,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
|
||||
public void normalize() {
|
||||
if (locked) return;
|
||||
double max = getPeakValue();
|
||||
double max = getPeakValue(true, false);
|
||||
double d = 0.708 / max;
|
||||
if (d > 1d) d = 1d;
|
||||
setGain(d);
|
||||
@@ -1155,10 +1186,14 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
}
|
||||
|
||||
synchronized public double[][] getProcessedAudioData() {
|
||||
return getProcessedAudioData(true);
|
||||
return getProcessedAudioData(true, true);
|
||||
}
|
||||
|
||||
synchronized public double[][] getProcessedAudioData(boolean effectsEnabled) {
|
||||
return getProcessedAudioData(effectsEnabled, true);
|
||||
}
|
||||
|
||||
synchronized public double[][] getProcessedAudioData(boolean effectsEnabled, boolean applyGain) {
|
||||
loadFile();
|
||||
if (processedAudio != null) {
|
||||
return processedAudio;
|
||||
@@ -1194,14 +1229,14 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add final master gain stage
|
||||
for (int i = 0; i < processedAudio.length; i++) {
|
||||
processedAudio[i][LEFT] *= gain;
|
||||
processedAudio[i][RIGHT] *= gain;
|
||||
if (applyGain) {
|
||||
// Add final master gain stage
|
||||
for (int i = 0; i < processedAudio.length; i++) {
|
||||
processedAudio[i][LEFT] *= gain;
|
||||
processedAudio[i][RIGHT] *= gain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return processedAudio;
|
||||
}
|
||||
|
||||
@@ -1325,6 +1360,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
out.put("gain", String.format("%.8f", getGain()));
|
||||
out.put("effect", getEffectChain());
|
||||
out.put("gaptype", getPostGapType());
|
||||
// out.put("samples", Integer.toString(getSampleSize()));
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -1341,4 +1377,21 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Element getSentenceXML(Document doc) {
|
||||
Element sentenceNode = doc.createElement("sentence");
|
||||
sentenceNode.setAttribute("id", getId());
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "text", getText()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "post-gap", getPostGap()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "start-offset", getStartOffset()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "end-offset", getEndOffset()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "locked", isLocked()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "attention", getAttentionFlag()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "gain", getGain()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "effect", getEffectChain()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "gaptype", getPostGapType()));
|
||||
sentenceNode.appendChild(Book.makeTextNode(doc, "samples", getSampleSize()));
|
||||
return sentenceNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
double lmax = 0;
|
||||
|
||||
for (int o = 0; o < step; o++) {
|
||||
if (offset + (n * step) + o >= samples.length) break;
|
||||
double sample = (samples[offset + (n * step) + o][Sentence.LEFT] + samples[offset + (n * step) + o][Sentence.RIGHT]) / 2d;
|
||||
if (sample >= 0) {
|
||||
have += sample;
|
||||
|
||||
Reference in New Issue
Block a user