Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 423d840d83 | |||
| 1997b0bf9b | |||
| b206fb33aa | |||
| 11b26e396c | |||
| 94139e6ac6 | |||
| c0cc2432ff | |||
| f86aaa3782 | |||
| 690a8f0c3b | |||
| 1de0ca8d60 | |||
| de149c5d85 | |||
| 7d2b11473b | |||
| 4c25fccc86 | |||
| 5e310b0224 | |||
| 169802ccaf | |||
| 28257e00c0 | |||
| 38c6af7090 | |||
| bdbf4c604d | |||
| 73bcba2c9a |
38
README.md
38
README.md
@@ -29,12 +29,13 @@ From here on much is controlled by key presses.
|
|||||||
appended to the currently selected chapter, or to the last chapter if none is selected.
|
appended to the currently selected chapter, or to the last chapter if none is selected.
|
||||||
* Press and hold "T" to record a new phrase that is the start of a new paragraph. This adds the "post paragraph" gap to the previous sentence. Otherwise it does the same as "R".
|
* Press and hold "T" to record a new phrase that is the start of a new paragraph. This adds the "post paragraph" gap to the previous sentence. Otherwise it does the same as "R".
|
||||||
* Press and hold "F" to record a "continuation" phrase. This sets the previous phrase's post-gap to be the "short" gap instead of the normal length gap.
|
* Press and hold "F" to record a "continuation" phrase. This sets the previous phrase's post-gap to be the "short" gap instead of the normal length gap.
|
||||||
|
* Press and hold "Y" to record a new phrase that is the start of a new section. This add the "post section" gap to the previous sentence. Otherwise it does the same as "R".
|
||||||
* Press "D" to delete the last phrase you recorded.
|
* Press "D" to delete the last phrase you recorded.
|
||||||
* Press "E" to re-record the currently selected phrase.
|
* Press "E" to re-record the currently selected phrase.
|
||||||
|
|
||||||
Each phrase you record will be briefly analysed using FFT to find the start and end of the audio and set
|
Each phrase you record can be automatically analysed to find the start and end of the audio and set
|
||||||
crop marks appropriately. These can be adjusted in the waveform display when a phrase is selected. You can also
|
crop marks appropriately. These can be adjusted in the waveform display when a phrase is selected. You can also
|
||||||
re-run the analysis using either the default FFT method or using a peak detector method (finding the first and last points
|
re-run the analysis using either FFT or a peak detector method (finding the first and last points
|
||||||
where the audio amplitude rises above the backround noise).
|
where the audio amplitude rises above the backround noise).
|
||||||
|
|
||||||
The phrases also have a "post gap" associated with them. This is the amount of room noise (in milliseconds) to place between
|
The phrases also have a "post gap" associated with them. This is the amount of room noise (in milliseconds) to place between
|
||||||
@@ -53,18 +54,14 @@ edit the text of this ID to identify the recordings. You
|
|||||||
may, for instance, change it to have the same text as the
|
may, for instance, change it to have the same text as the
|
||||||
audio contains.
|
audio contains.
|
||||||
|
|
||||||
To help with this the Haven On-Demand online speech recognition
|
The audio can also be automatically converted to text if you have an suitable command-line
|
||||||
service is integrated with the system and can be used to try and convert the
|
executable that will work. One example is (on Linux) [DeepSpeech](https://github.com/mozilla/DeepSpeech) by Mozilla.
|
||||||
audio into text. Right clicking on a recording brings
|
|
||||||
up a menu which includes the option to try and convert
|
|
||||||
the audio into text. The detected text is then used to
|
|
||||||
replace the current recording ID / text.
|
|
||||||
|
|
||||||
File layout
|
File layout
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
All data is stored in your "storage" directory (specified in Options). Each book (which is a directory named after the
|
All data is stored in your "storage" directory (specified in Options). Each book (which is a directory named after the
|
||||||
title of the book) has an associated XML file (audiobook.abk) and a directory "files" where all the audio (stored as WAV
|
title of the book) has an associated XML file (audiobook.abx) and a directory "files" where all the audio (stored as WAV
|
||||||
files) is placed.
|
files) is placed.
|
||||||
|
|
||||||
When you export the book as MP3 a new folder "export" is created within the book's folder where the MP3 files are placed.
|
When you export the book as MP3 a new folder "export" is created within the book's folder where the MP3 files are placed.
|
||||||
@@ -81,3 +78,26 @@ Building
|
|||||||
5. Build with `ant build`
|
5. Build with `ant build`
|
||||||
6. Run with `java -jar ./AudiobookRecorder.jar`
|
6. Run with `java -jar ./AudiobookRecorder.jar`
|
||||||
|
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Extra Resources
|
||||||
|
===============
|
||||||
|
|
||||||
|
* DeepSpeech wrapper script
|
||||||
|
|
||||||
|
This is a small script that will convert the audio into a format DeepSpeech likes and call the `deepspeech` executable, removing any extra rubbish from the output. It
|
||||||
|
also requires `sox` to be installed for the audio conversion.
|
||||||
|
|
||||||
|
```
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ID=$$
|
||||||
|
FILE=$1
|
||||||
|
BINPATH=${HOME}/local/bin
|
||||||
|
MODELS=${HOME}/ds/deepspeech-0.6.1-models
|
||||||
|
|
||||||
|
sox "$FILE" -r 16000 -c 1 -b 16 "/tmp/ds-${ID}.wav"
|
||||||
|
${BINPATH}/deepspeech --model ${MODELS}/output_graph.pbmm --lm ${MODELS}/lm.binary --trie ${MODELS}/trie --audio "/tmp/ds-${ID}.wav" 2>/dev/null
|
||||||
|
rm /tmp/ds-${ID}.wav
|
||||||
|
```
|
||||||
|
|||||||
BIN
deps/commons-lang3.jar
LFS
vendored
Normal file
BIN
deps/commons-lang3.jar
LFS
vendored
Normal file
Binary file not shown.
BIN
deps/commons-text.jar
LFS
vendored
Normal file
BIN
deps/commons-text.jar
LFS
vendored
Normal file
Binary file not shown.
BIN
deps/sphinx4-core-5prealpha-SNAPSHOT.jar
LFS
vendored
BIN
deps/sphinx4-core-5prealpha-SNAPSHOT.jar
LFS
vendored
Binary file not shown.
BIN
deps/sphinx4-data-5prealpha-SNAPSHOT.jar
LFS
vendored
BIN
deps/sphinx4-data-5prealpha-SNAPSHOT.jar
LFS
vendored
Binary file not shown.
@@ -1 +1 @@
|
|||||||
version=0.3.4
|
version=0.3.8
|
||||||
|
|||||||
BIN
resources/uk/co/majenko/audiobookrecorder/icons/processing.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/processing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 489 B |
BIN
resources/uk/co/majenko/audiobookrecorder/icons/queued.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/queued.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 717 B |
BIN
resources/uk/co/majenko/audiobookrecorder/icons/tooltip.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/tooltip.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -10,6 +10,7 @@ public class AGC implements Effect {
|
|||||||
double attack;
|
double attack;
|
||||||
|
|
||||||
public AGC(double c, double a, double d, double l) {
|
public AGC(double c, double a, double d, double l) {
|
||||||
|
Debug.trace();
|
||||||
ceiling = c;
|
ceiling = c;
|
||||||
attack = a;
|
attack = a;
|
||||||
decay = d;
|
decay = d;
|
||||||
@@ -18,18 +19,21 @@ public class AGC implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
Debug.trace();
|
||||||
return "AGC (Ceiling = " + ceiling + " attack = " + attack + " decay = " + decay + " limit = " + limit;
|
return "AGC (Ceiling = " + ceiling + " attack = " + attack + " decay = " + decay + " limit = " + limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
Debug.trace();
|
||||||
return getName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(double[][] samples) {
|
public void process(double[][] samples) {
|
||||||
|
Debug.trace();
|
||||||
gain = 1d;
|
gain = 1d;
|
||||||
for (int i = 0; i < samples.length; i++) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
double absSampleLeft = Math.abs(samples[i][Sentence.LEFT]) * gain;
|
double absSampleLeft = Math.abs(samples[Sentence.LEFT][i]) * gain;
|
||||||
double absSampleRight = Math.abs(samples[i][Sentence.RIGHT]) * gain;
|
double absSampleRight = Math.abs(samples[Sentence.RIGHT][i]) * gain;
|
||||||
|
|
||||||
double factor = 0.0d;
|
double factor = 0.0d;
|
||||||
|
|
||||||
@@ -49,20 +53,23 @@ public class AGC implements Effect {
|
|||||||
if (gain > limit) gain = limit;
|
if (gain > limit) gain = limit;
|
||||||
if (gain < 0) gain = 0;
|
if (gain < 0) gain = 0;
|
||||||
|
|
||||||
samples[i][Sentence.LEFT] *= gain;
|
samples[Sentence.LEFT][i] *= gain;
|
||||||
samples[i][Sentence.RIGHT] *= gain;
|
samples[Sentence.RIGHT][i] *= gain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(double sr) {
|
public void init(double sr) {
|
||||||
|
Debug.trace();
|
||||||
gain = 1d;
|
gain = 1d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump() {
|
public void dump() {
|
||||||
|
Debug.trace();
|
||||||
System.out.println(toString());
|
System.out.println(toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Effect> getChildEffects() {
|
public ArrayList<Effect> getChildEffects() {
|
||||||
|
Debug.trace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.*;
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
public class AboutPanel extends JPanel {
|
public class AboutPanel extends JPanel {
|
||||||
|
|
||||||
public AboutPanel() {
|
public AboutPanel() {
|
||||||
|
Debug.trace();
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
JLabel icon = new JLabel(Icons.appIcon);
|
JLabel icon = new JLabel(Icons.appIcon);
|
||||||
add(icon, BorderLayout.WEST);
|
add(icon, BorderLayout.WEST);
|
||||||
@@ -17,7 +22,7 @@ public class AboutPanel extends JPanel {
|
|||||||
|
|
||||||
JLabel l1 = new JLabel("AudiobookRecorder");
|
JLabel l1 = new JLabel("AudiobookRecorder");
|
||||||
JLabel l2 = new JLabel("Version " + AudiobookRecorder.config.getProperty("version"));
|
JLabel l2 = new JLabel("Version " + AudiobookRecorder.config.getProperty("version"));
|
||||||
JLabel l3 = new JLabel("(c) 2018 Majenko Technologies");
|
JLabel l3 = new JLabel("(c) 2020 Majenko Technologies");
|
||||||
|
|
||||||
l1.setAlignmentX(JComponent.CENTER_ALIGNMENT);
|
l1.setAlignmentX(JComponent.CENTER_ALIGNMENT);
|
||||||
l2.setAlignmentX(JComponent.CENTER_ALIGNMENT);
|
l2.setAlignmentX(JComponent.CENTER_ALIGNMENT);
|
||||||
|
|||||||
@@ -5,43 +5,53 @@ import java.util.ArrayList;
|
|||||||
public class Amplifier implements Effect {
|
public class Amplifier implements Effect {
|
||||||
double gain;
|
double gain;
|
||||||
public Amplifier() {
|
public Amplifier() {
|
||||||
|
Debug.trace();
|
||||||
gain = 1.0d;
|
gain = 1.0d;
|
||||||
}
|
}
|
||||||
public Amplifier(double g) {
|
public Amplifier(double g) {
|
||||||
|
Debug.trace();
|
||||||
gain = g;
|
gain = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
Debug.trace();
|
||||||
return "Amplifier (" + gain + ")";
|
return "Amplifier (" + gain + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Effect> getChildEffects() {
|
public ArrayList<Effect> getChildEffects() {
|
||||||
|
Debug.trace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(double[][] samples) {
|
public void process(double[][] samples) {
|
||||||
for (int i = 0; i < samples.length; i++) {
|
Debug.trace();
|
||||||
samples[i][Sentence.LEFT] *= gain;
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
samples[i][Sentence.RIGHT] *= gain;
|
samples[Sentence.LEFT][i] *= gain;
|
||||||
|
samples[Sentence.RIGHT][i] *= gain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getGain() {
|
public double getGain() {
|
||||||
|
Debug.trace();
|
||||||
return gain;
|
return gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGain(double g) {
|
public void setGain(double g) {
|
||||||
|
Debug.trace();
|
||||||
gain = g;
|
gain = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
Debug.trace();
|
||||||
return getName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump() {
|
public void dump() {
|
||||||
|
Debug.trace();
|
||||||
System.out.println(toString());
|
System.out.println(toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(double sf) {
|
public void init(double sf) {
|
||||||
|
Debug.trace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,7 @@ public class Biquad implements Effect {
|
|||||||
double sampleFrequency;
|
double sampleFrequency;
|
||||||
|
|
||||||
public Biquad() {
|
public Biquad() {
|
||||||
|
Debug.trace();
|
||||||
type = Lowpass;
|
type = Lowpass;
|
||||||
a0 = 1.0d;
|
a0 = 1.0d;
|
||||||
a1 = 0.0d;
|
a1 = 0.0d;
|
||||||
@@ -54,6 +55,7 @@ public class Biquad implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Biquad(int type, double Fc, double Q, double peakGainDB) {
|
public Biquad(int type, double Fc, double Q, double peakGainDB) {
|
||||||
|
Debug.trace();
|
||||||
setBiquad(type, Fc, Q, peakGainDB);
|
setBiquad(type, Fc, Q, peakGainDB);
|
||||||
lz1 = 0.0;
|
lz1 = 0.0;
|
||||||
lz2 = 0.0;
|
lz2 = 0.0;
|
||||||
@@ -63,26 +65,31 @@ public class Biquad implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setType(int typei) {
|
public void setType(int typei) {
|
||||||
|
Debug.trace();
|
||||||
type = typei;
|
type = typei;
|
||||||
calcBiquad();
|
calcBiquad();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQ(double Qi) {
|
public void setQ(double Qi) {
|
||||||
|
Debug.trace();
|
||||||
Q = Qi;
|
Q = Qi;
|
||||||
calcBiquad();
|
calcBiquad();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFc(double Fci) {
|
public void setFc(double Fci) {
|
||||||
|
Debug.trace();
|
||||||
Fc = Fci;
|
Fc = Fci;
|
||||||
calcBiquad();
|
calcBiquad();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPeakGain(double peakGainDB) {
|
public void setPeakGain(double peakGainDB) {
|
||||||
|
Debug.trace();
|
||||||
peakGain = peakGainDB;
|
peakGain = peakGainDB;
|
||||||
calcBiquad();
|
calcBiquad();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBiquad(int typei, double Fci, double Qi, double peakGainDB) {
|
public void setBiquad(int typei, double Fci, double Qi, double peakGainDB) {
|
||||||
|
Debug.trace();
|
||||||
type = typei;
|
type = typei;
|
||||||
Q = Qi;
|
Q = Qi;
|
||||||
Fc = Fci;
|
Fc = Fci;
|
||||||
@@ -90,27 +97,29 @@ public class Biquad implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process(double[][] samples) {
|
public void process(double[][] samples) {
|
||||||
|
Debug.trace();
|
||||||
lz1 = 0d;
|
lz1 = 0d;
|
||||||
lz2 = 0d;
|
lz2 = 0d;
|
||||||
rz1 = 0d;
|
rz1 = 0d;
|
||||||
rz2 = 0d;
|
rz2 = 0d;
|
||||||
for (double[] in : samples) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
double lout = in[Sentence.LEFT] * a0 + lz1;
|
double lout = samples[Sentence.LEFT][i] * a0 + lz1;
|
||||||
|
|
||||||
lz1 = in[Sentence.LEFT] * a1 + lz2 - b1 * lout;
|
lz1 = samples[Sentence.LEFT][i] * a1 + lz2 - b1 * lout;
|
||||||
lz2 = in[Sentence.LEFT] * a2 - b2 * lout;
|
lz2 = samples[Sentence.LEFT][i] * a2 - b2 * lout;
|
||||||
|
|
||||||
double rout = in[Sentence.RIGHT] * a0 + rz1;
|
double rout = samples[Sentence.RIGHT][i] * a0 + rz1;
|
||||||
|
|
||||||
rz1 = in[Sentence.RIGHT] * a1 + rz2 - b1 * rout;
|
rz1 = samples[Sentence.RIGHT][i] * a1 + rz2 - b1 * rout;
|
||||||
rz2 = in[Sentence.RIGHT] * a2 - b2 * rout;
|
rz2 = samples[Sentence.RIGHT][i] * a2 - b2 * rout;
|
||||||
|
|
||||||
in[Sentence.LEFT] = lout;
|
samples[Sentence.LEFT][i] = lout;
|
||||||
in[Sentence.RIGHT] = rout;
|
samples[Sentence.RIGHT][i] = rout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(double sf) {
|
public void init(double sf) {
|
||||||
|
Debug.trace();
|
||||||
sampleFrequency = sf;
|
sampleFrequency = sf;
|
||||||
lz1 = 0d;
|
lz1 = 0d;
|
||||||
lz2 = 0d;
|
lz2 = 0d;
|
||||||
@@ -120,6 +129,7 @@ public class Biquad implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void calcBiquad() {
|
void calcBiquad() {
|
||||||
|
Debug.trace();
|
||||||
|
|
||||||
double norm;
|
double norm;
|
||||||
double V = Math.pow(10, Math.abs(peakGain) / 20.0);
|
double V = Math.pow(10, Math.abs(peakGain) / 20.0);
|
||||||
@@ -221,6 +231,7 @@ public class Biquad implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
Debug.trace();
|
||||||
String n = "Biquad Filter (";
|
String n = "Biquad Filter (";
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Lowpass: n += "Lowpass"; break;
|
case Lowpass: n += "Lowpass"; break;
|
||||||
@@ -242,14 +253,17 @@ public class Biquad implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Effect> getChildEffects() {
|
public ArrayList<Effect> getChildEffects() {
|
||||||
|
Debug.trace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
Debug.trace();
|
||||||
return getName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump() {
|
public void dump() {
|
||||||
|
Debug.trace();
|
||||||
System.out.println(toString());
|
System.out.println(toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.io.File;
|
||||||
import javax.swing.event.*;
|
import java.nio.file.Files;
|
||||||
import java.awt.*;
|
import java.util.ArrayList;
|
||||||
import java.awt.event.*;
|
import java.util.Enumeration;
|
||||||
import java.util.*;
|
import java.util.UUID;
|
||||||
import java.io.*;
|
import java.util.Properties;
|
||||||
import java.nio.file.*;
|
import javax.sound.sampled.AudioFormat;
|
||||||
import javax.swing.tree.*;
|
import javax.swing.JOptionPane;
|
||||||
import javax.sound.sampled.*;
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
@@ -24,7 +25,7 @@ import org.w3c.dom.NodeList;
|
|||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Text;
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
public class Book extends DefaultMutableTreeNode {
|
public class Book extends BookTreeNode {
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
String author;
|
String author;
|
||||||
@@ -39,13 +40,17 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
int channels;
|
int channels;
|
||||||
int resolution;
|
int resolution;
|
||||||
|
|
||||||
|
String notes = null;
|
||||||
|
|
||||||
ImageIcon icon;
|
ImageIcon icon;
|
||||||
|
|
||||||
Properties prefs;
|
Properties prefs;
|
||||||
|
|
||||||
|
File location;
|
||||||
|
|
||||||
public Book(Properties p, String bookname) {
|
public Book(Properties p, String bookname) {
|
||||||
super(bookname);
|
super(bookname);
|
||||||
|
Debug.trace();
|
||||||
prefs = p;
|
prefs = p;
|
||||||
name = bookname;
|
name = bookname;
|
||||||
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name); // This should be in the load routine!!!!
|
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name); // This should be in the load routine!!!!
|
||||||
@@ -53,12 +58,13 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
|
|
||||||
public Book(Element root) {
|
public Book(Element root) {
|
||||||
super(getTextNode(root, "title"));
|
super(getTextNode(root, "title"));
|
||||||
|
Debug.trace();
|
||||||
name = getTextNode(root, "title");
|
name = getTextNode(root, "title");
|
||||||
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name); // This should be in the load routine!!!!
|
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name); // This should be in the load routine!!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadBookXML(Element root, DefaultTreeModel model) {
|
public void loadBookXML(Element root, DefaultTreeModel model) {
|
||||||
|
Debug.trace();
|
||||||
name = getTextNode(root, "title");
|
name = getTextNode(root, "title");
|
||||||
author = getTextNode(root, "author");
|
author = getTextNode(root, "author");
|
||||||
genre = getTextNode(root, "genre");
|
genre = getTextNode(root, "genre");
|
||||||
@@ -67,6 +73,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
manuscript = getTextNode(root, "manuscript");
|
manuscript = getTextNode(root, "manuscript");
|
||||||
|
|
||||||
AudiobookRecorder.window.setBookNotes(getTextNode(root, "notes"));
|
AudiobookRecorder.window.setBookNotes(getTextNode(root, "notes"));
|
||||||
|
notes = getTextNode(root, "notes");
|
||||||
|
|
||||||
Element settings = getNode(root, "settings");
|
Element settings = getNode(root, "settings");
|
||||||
Element audioSettings = getNode(settings, "audio");
|
Element audioSettings = getNode(settings, "audio");
|
||||||
@@ -92,6 +99,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Element getNode(Element r, String n) {
|
public static Element getNode(Element r, String n) {
|
||||||
|
Debug.trace();
|
||||||
NodeList nl = r.getElementsByTagName(n);
|
NodeList nl = r.getElementsByTagName(n);
|
||||||
if (nl == null) return null;
|
if (nl == null) return null;
|
||||||
if (nl.getLength() == 0) return null;
|
if (nl.getLength() == 0) return null;
|
||||||
@@ -99,35 +107,40 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getTextNode(Element r, String n) {
|
public static String getTextNode(Element r, String n) {
|
||||||
|
Debug.trace();
|
||||||
return getTextNode(r, n, "");
|
return getTextNode(r, n, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTextNode(Element r, String n, String d) {
|
public static String getTextNode(Element r, String n, String d) {
|
||||||
|
Debug.trace();
|
||||||
Element node = getNode(r, n);
|
Element node = getNode(r, n);
|
||||||
if (node == null) return d;
|
if (node == null) return d;
|
||||||
return node.getTextContent();
|
return node.getTextContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthor(String a) { author = a; }
|
public void setAuthor(String a) { Debug.trace(); author = a; }
|
||||||
public void setGenre(String g) { genre = g; }
|
public void setGenre(String g) { Debug.trace(); genre = g; }
|
||||||
public void setComment(String c) { comment = c; }
|
public void setComment(String c) { Debug.trace(); comment = c; }
|
||||||
public void setACX(String c) { ACX = c; }
|
public void setACX(String c) { Debug.trace(); ACX = c; }
|
||||||
|
|
||||||
public String getAuthor() { return author; }
|
public String getAuthor() { Debug.trace(); return author; }
|
||||||
public String getGenre() { return genre; }
|
public String getGenre() { Debug.trace(); return genre; }
|
||||||
public String getComment() { return comment; }
|
public String getComment() { Debug.trace(); return comment; }
|
||||||
public String getACX() { if (ACX == null) return ""; return ACX; }
|
public String getACX() { Debug.trace(); if (ACX == null) return ""; return ACX; }
|
||||||
|
|
||||||
public Chapter getClosingCredits() {
|
public Chapter getClosingCredits() {
|
||||||
|
Debug.trace();
|
||||||
return getChapterById("close");
|
return getChapterById("close");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chapter getOpeningCredits() {
|
public Chapter getOpeningCredits() {
|
||||||
|
Debug.trace();
|
||||||
return getChapterById("open");
|
return getChapterById("open");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Chapter getChapterById(String id) {
|
public Chapter getChapterById(String id) {
|
||||||
|
Debug.trace();
|
||||||
for (Enumeration o = children(); o.hasMoreElements();) {
|
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||||
Object ob = (Object)o.nextElement();
|
Object ob = (Object)o.nextElement();
|
||||||
if (ob instanceof Chapter) {
|
if (ob instanceof Chapter) {
|
||||||
@@ -141,6 +154,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Chapter getLastChapter() {
|
public Chapter getLastChapter() {
|
||||||
|
Debug.trace();
|
||||||
Chapter cc = getClosingCredits();
|
Chapter cc = getClosingCredits();
|
||||||
if (cc == null) return null;
|
if (cc == null) return null;
|
||||||
Chapter c = (Chapter)getChildBefore(cc);
|
Chapter c = (Chapter)getChildBefore(cc);
|
||||||
@@ -150,38 +164,34 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Chapter getChapter(int n) {
|
public Chapter getChapter(int n) {
|
||||||
|
Debug.trace();
|
||||||
if (n == 0) return null;
|
if (n == 0) return null;
|
||||||
return (Chapter)getChildAt(n);
|
return (Chapter)getChildAt(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chapter addChapter() {
|
public Chapter addChapter() {
|
||||||
Chapter lc = getLastChapter();
|
Debug.trace();
|
||||||
if (lc == null) return new Chapter("1", "Chapter 1");
|
String uuid = UUID.randomUUID().toString();
|
||||||
try {
|
return new Chapter(uuid, uuid);
|
||||||
int lcid = Integer.parseInt(lc.getId());
|
|
||||||
lcid++;
|
|
||||||
|
|
||||||
Chapter nc = new Chapter(String.format("%04d", lcid), "Chapter " + lcid);
|
|
||||||
return nc;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
Debug.trace();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageIcon getIcon() {
|
public ImageIcon getIcon() {
|
||||||
|
Debug.trace();
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIcon(ImageIcon i) {
|
public void setIcon(ImageIcon i) {
|
||||||
|
Debug.trace();
|
||||||
icon = i;
|
icon = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserObject(Object o) {
|
public void setUserObject(Object o) {
|
||||||
|
Debug.trace();
|
||||||
if (o instanceof String) {
|
if (o instanceof String) {
|
||||||
String newName = (String)o;
|
String newName = (String)o;
|
||||||
if (newName.equals(name)) return;
|
if (newName.equals(name)) return;
|
||||||
@@ -190,10 +200,12 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File getBookPath() {
|
public File getBookPath() {
|
||||||
|
Debug.trace();
|
||||||
return new File(Options.get("path.storage"), name);
|
return new File(Options.get("path.storage"), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renameBook(String newName) {
|
public void renameBook(String newName) {
|
||||||
|
Debug.trace();
|
||||||
File oldDir = getBookPath();
|
File oldDir = getBookPath();
|
||||||
File newDir = new File(Options.get("path.storage"), newName);
|
File newDir = new File(Options.get("path.storage"), newName);
|
||||||
|
|
||||||
@@ -206,7 +218,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
oldDir.renameTo(newDir);
|
oldDir.renameTo(newDir);
|
||||||
name = newName;
|
name = newName;
|
||||||
AudiobookRecorder.window.saveBookStructure();
|
AudiobookRecorder.window.saveBookStructure();
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
reloadTree();
|
||||||
Options.set("path.last-book", name);
|
Options.set("path.last-book", name);
|
||||||
Options.savePreferences();
|
Options.savePreferences();
|
||||||
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name);
|
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name);
|
||||||
@@ -214,11 +226,13 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
Debug.trace();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void renumberChapters() {
|
public void renumberChapters() {
|
||||||
|
Debug.trace();
|
||||||
int id = 1;
|
int id = 1;
|
||||||
|
|
||||||
for (Enumeration c = children(); c.hasMoreElements();) {
|
for (Enumeration c = children(); c.hasMoreElements();) {
|
||||||
@@ -230,41 +244,48 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSampleRate() { return sampleRate; }
|
public int getSampleRate() { Debug.trace(); return sampleRate; }
|
||||||
public void setSampleRate(int sr) { sampleRate = sr; }
|
public void setSampleRate(int sr) { Debug.trace(); sampleRate = sr; }
|
||||||
public int getChannels() { return channels; }
|
public int getChannels() { Debug.trace(); return channels; }
|
||||||
public void setChannels(int c) { channels = c; }
|
public void setChannels(int c) { Debug.trace(); channels = c; }
|
||||||
public int getResolution() { return resolution; }
|
public int getResolution() { Debug.trace(); return resolution; }
|
||||||
public void setResolution(int r) { resolution = r; }
|
public void setResolution(int r) { Debug.trace(); resolution = r; }
|
||||||
|
|
||||||
public AudioFormat getAudioFormat() {
|
public AudioFormat getAudioFormat() {
|
||||||
|
Debug.trace();
|
||||||
return new AudioFormat(getSampleRate(), getResolution(), getChannels(), true, false);
|
return new AudioFormat(getSampleRate(), getResolution(), getChannels(), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String get(String key) {
|
public String get(String key) {
|
||||||
|
Debug.trace();
|
||||||
if (prefs.getProperty(key) == null) { return Options.get(key); }
|
if (prefs.getProperty(key) == null) { return Options.get(key); }
|
||||||
return prefs.getProperty(key);
|
return prefs.getProperty(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getInteger(String key) {
|
public Integer getInteger(String key) {
|
||||||
|
Debug.trace();
|
||||||
if (prefs.getProperty(key) == null) { return Options.getInteger(key); }
|
if (prefs.getProperty(key) == null) { return Options.getInteger(key); }
|
||||||
return Utils.s2i(prefs.getProperty(key));
|
return Utils.s2i(prefs.getProperty(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(String key, String value) {
|
public void set(String key, String value) {
|
||||||
|
Debug.trace();
|
||||||
prefs.setProperty(key, value);
|
prefs.setProperty(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(String key, Integer value) {
|
public void set(String key, Integer value) {
|
||||||
|
Debug.trace();
|
||||||
prefs.setProperty(key, "" + value);
|
prefs.setProperty(key, "" + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getBookFolder() {
|
public File getBookFolder() {
|
||||||
|
Debug.trace();
|
||||||
File dir = new File(Options.get("path.storage"), name);
|
File dir = new File(Options.get("path.storage"), name);
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getUsedEffects() {
|
public ArrayList<String> getUsedEffects() {
|
||||||
|
Debug.trace();
|
||||||
|
|
||||||
ArrayList<String> out = new ArrayList<String>();
|
ArrayList<String> out = new ArrayList<String>();
|
||||||
|
|
||||||
@@ -285,6 +306,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void purgeBackups() {
|
public void purgeBackups() {
|
||||||
|
Debug.trace();
|
||||||
for (Enumeration o = children(); o.hasMoreElements();) {
|
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||||
Object ob = (Object)o.nextElement();
|
Object ob = (Object)o.nextElement();
|
||||||
if (ob instanceof Chapter) {
|
if (ob instanceof Chapter) {
|
||||||
@@ -295,6 +317,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Document buildDocument() throws ParserConfigurationException {
|
public Document buildDocument() throws ParserConfigurationException {
|
||||||
|
Debug.trace();
|
||||||
DocumentBuilderFactory dbFactory =
|
DocumentBuilderFactory dbFactory =
|
||||||
DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||||
@@ -343,6 +366,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Element makeTextNode(Document doc, String name, String text) {
|
public static Element makeTextNode(Document doc, String name, String text) {
|
||||||
|
Debug.trace();
|
||||||
Element node = doc.createElement(name);
|
Element node = doc.createElement(name);
|
||||||
Text tnode = doc.createTextNode(text == null ? "" : text);
|
Text tnode = doc.createTextNode(text == null ? "" : text);
|
||||||
node.appendChild(tnode);
|
node.appendChild(tnode);
|
||||||
@@ -350,6 +374,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Element makeTextNode(Document doc, String name, Integer text) {
|
public static Element makeTextNode(Document doc, String name, Integer text) {
|
||||||
|
Debug.trace();
|
||||||
Element node = doc.createElement(name);
|
Element node = doc.createElement(name);
|
||||||
Text tnode = doc.createTextNode(Integer.toString(text));
|
Text tnode = doc.createTextNode(Integer.toString(text));
|
||||||
node.appendChild(tnode);
|
node.appendChild(tnode);
|
||||||
@@ -357,6 +382,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Element makeTextNode(Document doc, String name, Double text) {
|
public static Element makeTextNode(Document doc, String name, Double text) {
|
||||||
|
Debug.trace();
|
||||||
Element node = doc.createElement(name);
|
Element node = doc.createElement(name);
|
||||||
Text tnode = doc.createTextNode(String.format("%.8f", text));
|
Text tnode = doc.createTextNode(String.format("%.8f", text));
|
||||||
node.appendChild(tnode);
|
node.appendChild(tnode);
|
||||||
@@ -364,6 +390,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Element makeTextNode(Document doc, String name, Boolean text) {
|
public static Element makeTextNode(Document doc, String name, Boolean text) {
|
||||||
|
Debug.trace();
|
||||||
Element node = doc.createElement(name);
|
Element node = doc.createElement(name);
|
||||||
Text tnode = doc.createTextNode(text ? "true" : "false");
|
Text tnode = doc.createTextNode(text ? "true" : "false");
|
||||||
node.appendChild(tnode);
|
node.appendChild(tnode);
|
||||||
@@ -371,14 +398,17 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultEffect() {
|
public String getDefaultEffect() {
|
||||||
|
Debug.trace();
|
||||||
return defaultEffect;
|
return defaultEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultEffect(String eff) {
|
public void setDefaultEffect(String eff) {
|
||||||
|
Debug.trace();
|
||||||
defaultEffect = eff;
|
defaultEffect = eff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setManuscript(File f) {
|
public void setManuscript(File f) {
|
||||||
|
Debug.trace();
|
||||||
manuscript = f.getName();
|
manuscript = f.getName();
|
||||||
File dst = new File(getBookPath(), manuscript);
|
File dst = new File(getBookPath(), manuscript);
|
||||||
|
|
||||||
@@ -390,6 +420,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File getManuscript() {
|
public File getManuscript() {
|
||||||
|
Debug.trace();
|
||||||
if (manuscript == null) return null;
|
if (manuscript == null) return null;
|
||||||
if (manuscript.equals("")) return null;
|
if (manuscript.equals("")) return null;
|
||||||
File f = new File(getBookPath(), manuscript);
|
File f = new File(getBookPath(), manuscript);
|
||||||
@@ -398,4 +429,32 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSelect() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String n) {
|
||||||
|
notes = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(File l) {
|
||||||
|
location = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadTree() {
|
||||||
|
Debug.trace();
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
AudiobookRecorder.window.bookTreeModel.reload(Book.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.util.regex.Matcher;
|
||||||
import javax.swing.event.*;
|
import java.util.regex.Pattern;
|
||||||
import java.awt.*;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.*;
|
import java.awt.GridBagLayout;
|
||||||
import java.util.regex.*;
|
import java.awt.GridBagConstraints;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
public class BookInfoPanel extends JPanel {
|
public class BookInfoPanel extends JPanel {
|
||||||
|
|
||||||
@@ -16,6 +19,7 @@ public class BookInfoPanel extends JPanel {
|
|||||||
|
|
||||||
public BookInfoPanel(String t, String a, String g, String c, String x) {
|
public BookInfoPanel(String t, String a, String g, String c, String x) {
|
||||||
super();
|
super();
|
||||||
|
Debug.trace();
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
GridBagConstraints con = new GridBagConstraints();
|
GridBagConstraints con = new GridBagConstraints();
|
||||||
|
|
||||||
@@ -69,12 +73,13 @@ public class BookInfoPanel extends JPanel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() { return title.getText(); }
|
public String getTitle() { Debug.trace(); return title.getText(); }
|
||||||
public String getAuthor() { return author.getText(); }
|
public String getAuthor() { Debug.trace(); return author.getText(); }
|
||||||
public String getGenre() { return genre.getText(); }
|
public String getGenre() { Debug.trace(); return genre.getText(); }
|
||||||
public String getComment() { return comment.getText(); }
|
public String getComment() { Debug.trace(); return comment.getText(); }
|
||||||
|
|
||||||
public String getACX() {
|
public String getACX() {
|
||||||
|
Debug.trace();
|
||||||
Pattern p = Pattern.compile("\\/titleview\\/([A-Z0-9]{14})");
|
Pattern p = Pattern.compile("\\/titleview\\/([A-Z0-9]{14})");
|
||||||
Matcher m = p.matcher(acx.getText());
|
Matcher m = p.matcher(acx.getText());
|
||||||
if (m.find()) {
|
if (m.find()) {
|
||||||
@@ -84,10 +89,10 @@ public class BookInfoPanel extends JPanel {
|
|||||||
return acx.getText();
|
return acx.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String t) { title.setText(t); }
|
public void setTitle(String t) { Debug.trace(); title.setText(t); }
|
||||||
public void setAuthor(String a) { author.setText(a); }
|
public void setAuthor(String a) { Debug.trace(); author.setText(a); }
|
||||||
public void setGenre(String g) { genre.setText(g); }
|
public void setGenre(String g) { Debug.trace(); genre.setText(g); }
|
||||||
public void setComment(String c) { comment.setText(c); }
|
public void setComment(String c) { Debug.trace(); comment.setText(c); }
|
||||||
public void setACX(String a) { acx.setText(a); }
|
public void setACX(String a) { Debug.trace(); acx.setText(a); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.io.File;
|
||||||
import javax.swing.event.*;
|
import java.io.FileInputStream;
|
||||||
import java.awt.*;
|
import java.util.Properties;
|
||||||
import java.awt.event.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.image.*;
|
import java.awt.Color;
|
||||||
import javax.swing.border.*;
|
import java.awt.Dimension;
|
||||||
import java.util.*;
|
import java.awt.Image;
|
||||||
import java.io.*;
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Component;
|
||||||
import javax.swing.tree.*;
|
import java.awt.Color;
|
||||||
import java.awt.*;
|
import java.awt.Dimension;
|
||||||
import javax.swing.border.*;
|
import java.awt.Font;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
|
||||||
public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||||
|
|
||||||
@@ -77,32 +86,54 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JLabel time = new JLabel(Utils.secToTime(s.getLength(), "mm:ss.SSS") + " ");
|
JLabel time = new JLabelFixedWidth(75, " " + Utils.secToTime(s.getLength(), "ss.SSS") + " ");
|
||||||
|
time.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||||
|
|
||||||
ctx.gridx = 0;
|
ctx.gridx = 0;
|
||||||
ctx.gridy = 0;
|
ctx.gridy = 0;
|
||||||
|
ctx.weightx = 1.0d;
|
||||||
ctx.fill = GridBagConstraints.HORIZONTAL;
|
ctx.fill = GridBagConstraints.HORIZONTAL;
|
||||||
ctx.anchor = GridBagConstraints.LINE_START;
|
ctx.anchor = GridBagConstraints.LINE_START;
|
||||||
|
p.add(ret, ctx);
|
||||||
|
|
||||||
String effectChain = s.getEffectChain();
|
if (s.isProcessing()) {
|
||||||
if ((effectChain == null) || (effectChain.equals("none"))) {
|
JLabel eff = new JLabel();
|
||||||
ctx.weightx = 1.0d;
|
eff.setIcon(Icons.processing);
|
||||||
ctx.gridwidth = 2;
|
ctx.weightx = 0.0d;
|
||||||
p.add(ret, ctx);
|
ctx.gridx = 1;
|
||||||
} else {
|
p.add(eff);
|
||||||
ctx.weightx = 0.1d;
|
} else if (s.isQueued()) {
|
||||||
ctx.gridwidth = 1;
|
JLabel eff = new JLabel();
|
||||||
p.add(ret, ctx);
|
eff.setIcon(Icons.queued);
|
||||||
Effect e = AudiobookRecorder.window.effects.get(effectChain);
|
|
||||||
JLabel eff = new JLabel(e.toString() + " ");
|
|
||||||
ctx.weightx = 0.0d;
|
ctx.weightx = 0.0d;
|
||||||
ctx.gridwidth = 1;
|
|
||||||
ctx.gridx = 1;
|
ctx.gridx = 1;
|
||||||
p.add(eff);
|
p.add(eff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String effectChain = s.getEffectChain();
|
||||||
|
if ((effectChain != null) && (!effectChain.equals("none"))) {
|
||||||
|
Effect e = AudiobookRecorder.window.effects.get(effectChain);
|
||||||
|
if (e != null) {
|
||||||
|
JLabel eff = new JLabel(e.toString() + " ");
|
||||||
ctx.weightx = 0.0d;
|
ctx.weightx = 0.0d;
|
||||||
ctx.gridx = 2;
|
ctx.gridx = 2;
|
||||||
|
p.add(eff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.weightx = 0.0d;
|
||||||
|
ctx.gridx = 3;
|
||||||
|
ctx.anchor = GridBagConstraints.LINE_END;
|
||||||
|
int peak = s.getPeakDB();
|
||||||
|
JLabel peakLabel = new JLabelFixedWidth(50, peak + "dB ");
|
||||||
|
peakLabel.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||||
|
if (peak > 0) {
|
||||||
|
peakLabel.setForeground(new Color(0xCC, 0x00, 0x00));
|
||||||
|
}
|
||||||
|
p.add(peakLabel, ctx);
|
||||||
|
|
||||||
|
ctx.weightx = 0.0d;
|
||||||
|
ctx.gridx = 4;
|
||||||
ctx.anchor = GridBagConstraints.LINE_END;
|
ctx.anchor = GridBagConstraints.LINE_END;
|
||||||
p.add(time, ctx);
|
p.add(time, ctx);
|
||||||
|
|
||||||
@@ -134,7 +165,33 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
p.setOpaque(false);
|
p.setOpaque(false);
|
||||||
return p;
|
return p;
|
||||||
} else if (value instanceof Book) {
|
} else if (value instanceof Book) {
|
||||||
ret.setIcon(((Book)value).getIcon());
|
Book b = (Book)value;
|
||||||
|
|
||||||
|
JPanel p = new JPanel();
|
||||||
|
p.setLayout(new GridBagLayout());
|
||||||
|
GridBagConstraints ctx = new GridBagConstraints();
|
||||||
|
|
||||||
|
ctx.gridx = 0;
|
||||||
|
ctx.gridy = 0;
|
||||||
|
ctx.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
ctx.anchor = GridBagConstraints.LINE_START;
|
||||||
|
ctx.weightx = 1.0d;
|
||||||
|
|
||||||
|
ret.setIcon(b.getIcon());
|
||||||
|
p.add(ret, ctx);
|
||||||
|
|
||||||
|
JLabel author = new JLabel(b.getAuthor());
|
||||||
|
ctx.gridy++;
|
||||||
|
author.setBorder(new EmptyBorder(0, 27, 0, 0));
|
||||||
|
Font f = author.getFont();
|
||||||
|
Font nf = f.deriveFont(Font.ITALIC, (int)(f.getSize() * 0.75));
|
||||||
|
author.setFont(nf);
|
||||||
|
author.setForeground(author.getForeground().darker());
|
||||||
|
p.add(author, ctx);
|
||||||
|
|
||||||
|
p.setOpaque(false);
|
||||||
|
return p;
|
||||||
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CacheManager {
|
public class CacheManager {
|
||||||
static ArrayList<Cacheable> cache = new ArrayList<Cacheable>();
|
static ArrayList<Cacheable> cache = new ArrayList<Cacheable>();
|
||||||
|
|||||||
@@ -1,16 +1,33 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.io.File;
|
||||||
import javax.swing.event.*;
|
import java.io.FileInputStream;
|
||||||
import java.awt.*;
|
import java.io.FileOutputStream;
|
||||||
import java.awt.event.*;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.*;
|
import java.io.IOException;
|
||||||
import java.io.*;
|
import java.util.ArrayList;
|
||||||
import java.nio.file.*;
|
import java.util.Enumeration;
|
||||||
import javax.swing.tree.*;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import it.sauronsoftware.jave.*;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import com.mpatric.mp3agic.*;
|
|
||||||
import javax.sound.sampled.*;
|
import it.sauronsoftware.jave.FFMPEGLocator;
|
||||||
|
import it.sauronsoftware.jave.AudioAttributes;
|
||||||
|
import it.sauronsoftware.jave.EncodingAttributes;
|
||||||
|
import it.sauronsoftware.jave.Encoder;
|
||||||
|
import it.sauronsoftware.jave.EncoderException;
|
||||||
|
import it.sauronsoftware.jave.InputFormatException;
|
||||||
|
|
||||||
|
import com.mpatric.mp3agic.Mp3File;
|
||||||
|
import com.mpatric.mp3agic.ID3v2;
|
||||||
|
import com.mpatric.mp3agic.ID3v24Tag;
|
||||||
|
import com.mpatric.mp3agic.InvalidDataException;
|
||||||
|
import com.mpatric.mp3agic.NotSupportedException;
|
||||||
|
import com.mpatric.mp3agic.UnsupportedTagException;
|
||||||
|
|
||||||
|
import javax.sound.sampled.AudioFormat;
|
||||||
|
import javax.sound.sampled.AudioFileFormat;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
@@ -38,7 +55,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
|
|
||||||
public Chapter(String i, String chaptername) {
|
public Chapter(String i, String chaptername) {
|
||||||
super(chaptername);
|
super(chaptername);
|
||||||
|
Debug.trace();
|
||||||
id = i;
|
id = i;
|
||||||
name = chaptername;
|
name = chaptername;
|
||||||
preGap = Options.getInteger("catenation.pre-chapter");
|
preGap = Options.getInteger("catenation.pre-chapter");
|
||||||
@@ -46,7 +63,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Chapter(Element root, DefaultTreeModel model) {
|
public Chapter(Element root, DefaultTreeModel model) {
|
||||||
|
Debug.trace();
|
||||||
name = Book.getTextNode(root, "name");
|
name = Book.getTextNode(root, "name");
|
||||||
id = root.getAttribute("id");
|
id = root.getAttribute("id");
|
||||||
preGap = Utils.s2i(Book.getTextNode(root, "pre-gap"));
|
preGap = Utils.s2i(Book.getTextNode(root, "pre-gap"));
|
||||||
@@ -65,24 +82,29 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
Debug.trace();
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String i) {
|
public void setId(String i) {
|
||||||
|
Debug.trace();
|
||||||
id = i;
|
id = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sentence getLastSentence() {
|
public Sentence getLastSentence() {
|
||||||
|
Debug.trace();
|
||||||
DefaultMutableTreeNode ls = getLastLeaf();
|
DefaultMutableTreeNode ls = getLastLeaf();
|
||||||
if (ls instanceof Sentence) return (Sentence)ls;
|
if (ls instanceof Sentence) return (Sentence)ls;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
Debug.trace();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserObject(Object o) {
|
public void setUserObject(Object o) {
|
||||||
|
Debug.trace();
|
||||||
if (o instanceof String) {
|
if (o instanceof String) {
|
||||||
String so = (String)o;
|
String so = (String)o;
|
||||||
name = so;
|
name = so;
|
||||||
@@ -90,26 +112,32 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
Debug.trace();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String n) {
|
public void setName(String n) {
|
||||||
|
Debug.trace();
|
||||||
name = n;
|
name = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPreGap(int g) {
|
public void setPreGap(int g) {
|
||||||
|
Debug.trace();
|
||||||
preGap = g;
|
preGap = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreGap() {
|
public int getPreGap() {
|
||||||
|
Debug.trace();
|
||||||
return preGap;
|
return preGap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPostGap(int g) {
|
public void setPostGap(int g) {
|
||||||
|
Debug.trace();
|
||||||
postGap = g;
|
postGap = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPostGap() {
|
public int getPostGap() {
|
||||||
|
Debug.trace();
|
||||||
return postGap;
|
return postGap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +145,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
public void exportChapter(ProgressDialog exportDialog) throws
|
public void exportChapter(ProgressDialog exportDialog) throws
|
||||||
FileNotFoundException, IOException, InputFormatException, NotSupportedException,
|
FileNotFoundException, IOException, InputFormatException, NotSupportedException,
|
||||||
EncoderException, UnsupportedTagException, InvalidDataException {
|
EncoderException, UnsupportedTagException, InvalidDataException {
|
||||||
|
Debug.trace();
|
||||||
|
|
||||||
if (getChildCount() == 0) return;
|
if (getChildCount() == 0) return;
|
||||||
|
|
||||||
@@ -235,6 +264,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getChapterLength() {
|
public double getChapterLength() {
|
||||||
|
Debug.trace();
|
||||||
double totalTime = Options.getInteger("audio.recording.pre-chapter") / 1000d;
|
double totalTime = Options.getInteger("audio.recording.pre-chapter") / 1000d;
|
||||||
for (Enumeration s = children(); s.hasMoreElements();) {
|
for (Enumeration s = children(); s.hasMoreElements();) {
|
||||||
Sentence sentence = (Sentence)s.nextElement();
|
Sentence sentence = (Sentence)s.nextElement();
|
||||||
@@ -249,6 +279,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getUsedEffects() {
|
public ArrayList<String> getUsedEffects() {
|
||||||
|
Debug.trace();
|
||||||
|
|
||||||
ArrayList<String> out = new ArrayList<String>();
|
ArrayList<String> out = new ArrayList<String>();
|
||||||
|
|
||||||
@@ -266,6 +297,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetPostGaps() {
|
public void resetPostGaps() {
|
||||||
|
Debug.trace();
|
||||||
for (Enumeration s = children(); s.hasMoreElements();) {
|
for (Enumeration s = children(); s.hasMoreElements();) {
|
||||||
Sentence snt = (Sentence)s.nextElement();
|
Sentence snt = (Sentence)s.nextElement();
|
||||||
snt.resetPostGap();
|
snt.resetPostGap();
|
||||||
@@ -273,6 +305,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void purgeBackups() {
|
public void purgeBackups() {
|
||||||
|
Debug.trace();
|
||||||
for (Enumeration o = children(); o.hasMoreElements();) {
|
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||||
Object ob = (Object)o.nextElement();
|
Object ob = (Object)o.nextElement();
|
||||||
if (ob instanceof Sentence) {
|
if (ob instanceof Sentence) {
|
||||||
@@ -283,6 +316,7 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Element getChapterXML(Document doc) {
|
public Element getChapterXML(Document doc) {
|
||||||
|
Debug.trace();
|
||||||
Element chapterNode = doc.createElement("chapter");
|
Element chapterNode = doc.createElement("chapter");
|
||||||
chapterNode.setAttribute("id", id);
|
chapterNode.setAttribute("id", id);
|
||||||
chapterNode.appendChild(Book.makeTextNode(doc, "name", name));
|
chapterNode.appendChild(Book.makeTextNode(doc, "name", name));
|
||||||
@@ -305,18 +339,22 @@ public class Chapter extends BookTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getNotes() {
|
public String getNotes() {
|
||||||
|
Debug.trace();
|
||||||
return notes;
|
return notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotes(String t) {
|
public void setNotes(String t) {
|
||||||
|
Debug.trace();
|
||||||
notes = t;
|
notes = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSelect() {
|
public void onSelect() {
|
||||||
|
Debug.trace();
|
||||||
AudiobookRecorder.window.setChapterNotes(notes);
|
AudiobookRecorder.window.setChapterNotes(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLength() {
|
public double getLength() {
|
||||||
|
Debug.trace();
|
||||||
double len = 0;
|
double len = 0;
|
||||||
for (Enumeration o = children(); o.hasMoreElements();) {
|
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||||
Object ob = (Object)o.nextElement();
|
Object ob = (Object)o.nextElement();
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ public class Clipping implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process(double[][] samples) {
|
public void process(double[][] samples) {
|
||||||
for (double[] sample : samples) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
if (sample[Sentence.LEFT] > clip) sample[Sentence.LEFT] = clip;
|
if (samples[Sentence.LEFT][i] > clip) samples[Sentence.LEFT][i] = clip;
|
||||||
if (sample[Sentence.LEFT] < -clip) sample[Sentence.LEFT] = -clip;
|
if (samples[Sentence.LEFT][i] < -clip) samples[Sentence.LEFT][i] = -clip;
|
||||||
if (sample[Sentence.RIGHT] > clip) sample[Sentence.RIGHT] = clip;
|
if (samples[Sentence.RIGHT][i] > clip) samples[Sentence.RIGHT][i] = clip;
|
||||||
if (sample[Sentence.RIGHT] < -clip) sample[Sentence.RIGHT] = -clip;
|
if (samples[Sentence.RIGHT][i] < -clip) samples[Sentence.RIGHT][i] = -clip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
192
src/uk/co/majenko/audiobookrecorder/CommandLine.java
Normal file
192
src/uk/co/majenko/audiobookrecorder/CommandLine.java
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class CommandLine {
|
||||||
|
HashMap<String, Class<?>> parameterTypes = new HashMap<String, Class<?>>();
|
||||||
|
HashMap<String, String> parameterComments = new HashMap<String, String>();
|
||||||
|
HashMap<String, Object> parameterValues = new HashMap<String, Object>();
|
||||||
|
HashMap<String, String> parameterNames = new HashMap<String, String>();
|
||||||
|
ArrayList<String> extraValues = new ArrayList<String>();
|
||||||
|
|
||||||
|
public CommandLine() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addParameter(String key, String name, Class<?> type, String comment) {
|
||||||
|
parameterNames.put(key, name);
|
||||||
|
parameterTypes.put(key, type);
|
||||||
|
parameterComments.put(key, comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] process(String[] args) {
|
||||||
|
parameterValues = new HashMap<String, Object>();
|
||||||
|
extraValues = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (String arg : args) {
|
||||||
|
if (arg.startsWith("--")) {
|
||||||
|
arg = arg.substring(2);
|
||||||
|
String value = "";
|
||||||
|
int equals = arg.indexOf("=");
|
||||||
|
if (equals > -1) {
|
||||||
|
value = arg.substring(equals + 1);
|
||||||
|
arg = arg.substring(0, equals);
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<?> aclass = parameterTypes.get(arg);
|
||||||
|
if (aclass == null) {
|
||||||
|
help();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
if (aclass == Boolean.class) {
|
||||||
|
Boolean b = true;
|
||||||
|
parameterValues.put(arg, b);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (value.equals("")) {
|
||||||
|
help();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
if (aclass == Integer.class) {
|
||||||
|
Integer i = 0;
|
||||||
|
try {
|
||||||
|
i = Integer.parseInt(value);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
parameterValues.put(arg, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (aclass == Float.class) {
|
||||||
|
Float f = 0F;
|
||||||
|
try {
|
||||||
|
f = Float.parseFloat(value);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
parameterValues.put(arg, f);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (aclass == Double.class) {
|
||||||
|
Double d = 0D;
|
||||||
|
try {
|
||||||
|
d = Double.parseDouble(value);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
parameterValues.put(arg, d);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (aclass == String.class) {
|
||||||
|
parameterValues.put(arg, value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
extraValues.add(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return extraValues.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void help() {
|
||||||
|
System.out.println("Available command line arguments:");
|
||||||
|
int maxlen = 0;
|
||||||
|
|
||||||
|
String[] arglist = parameterTypes.keySet().toArray(new String[0]);
|
||||||
|
Arrays.sort(arglist);
|
||||||
|
|
||||||
|
for (String s : arglist) {
|
||||||
|
int thislen = s.length();
|
||||||
|
if (parameterTypes.get(s) != Boolean.class) {
|
||||||
|
thislen++;
|
||||||
|
thislen += parameterNames.get(s).length();
|
||||||
|
}
|
||||||
|
if (thislen > maxlen) {
|
||||||
|
maxlen = thislen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String s : arglist) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
System.out.print(" --");
|
||||||
|
sb.append(s);
|
||||||
|
if (parameterTypes.get(s) != Boolean.class) {
|
||||||
|
sb.append("=");
|
||||||
|
sb.append(parameterNames.get(s));
|
||||||
|
}
|
||||||
|
while (sb.length() < maxlen) {
|
||||||
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
System.out.print(sb.toString());
|
||||||
|
System.out.print(" ");
|
||||||
|
System.out.println(parameterComments.get(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSet(String key) {
|
||||||
|
Object value = parameterValues.get(key);
|
||||||
|
if (value == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString(String key) {
|
||||||
|
Class<?> type = parameterTypes.get(key);
|
||||||
|
if (type == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (type != String.class) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String value = (String)parameterValues.get(key);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInteger(String key) {
|
||||||
|
Class<?> type = parameterTypes.get(key);
|
||||||
|
if (type == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (type != Integer.class) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Integer value = (Integer)parameterValues.get(key);
|
||||||
|
if (value == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (int)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getFloat(String key) {
|
||||||
|
Class<?> type = parameterTypes.get(key);
|
||||||
|
if (type == null) {
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
if (type != Float.class) {
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
Float value = (Float)parameterValues.get(key);
|
||||||
|
if (value == null) {
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
return (float)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDouble(String key) {
|
||||||
|
Class<?> type = parameterTypes.get(key);
|
||||||
|
if (type == null) {
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
if (type != Double.class) {
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
Double value = (Double)parameterValues.get(key);
|
||||||
|
if (value == null) {
|
||||||
|
return 0d;
|
||||||
|
}
|
||||||
|
return (double)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(String key, String value) {
|
||||||
|
parameterValues.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.tree.*;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.plaf.*;
|
import javax.swing.tree.AbstractLayoutCache;
|
||||||
import javax.swing.plaf.basic.*;
|
import javax.swing.tree.TreePath;
|
||||||
import java.awt.*;
|
import javax.swing.plaf.basic.BasicTreeUI;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
public class CustomTreeUI extends BasicTreeUI {
|
public class CustomTreeUI extends BasicTreeUI {
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,53 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
public class Debug {
|
public class Debug {
|
||||||
static long timestamp;
|
static long timestamp;
|
||||||
|
static public boolean debugEnabled = false;
|
||||||
|
static public boolean traceEnabled = false;
|
||||||
|
|
||||||
static void debug(String msg) {
|
static void debug(String msg) {
|
||||||
|
if (!debugEnabled) return;
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long diff = now - timestamp;
|
long diff = now - timestamp;
|
||||||
timestamp = now;
|
timestamp = now;
|
||||||
System.err.println(String.format("%8d - %s", diff, msg));
|
System.err.println(String.format("%8d - %s", diff, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void d(Object... args) {
|
||||||
|
if (!debugEnabled) return;
|
||||||
|
|
||||||
|
Thread t = Thread.currentThread();
|
||||||
|
StackTraceElement[] st = t.getStackTrace();
|
||||||
|
StackTraceElement caller = st[2];
|
||||||
|
|
||||||
|
String tag = "[" + getCurrentLocalDateTimeStamp() + "] " + caller.getFileName() + " " + caller.getLineNumber() + " (" + caller.getMethodName() + "):";
|
||||||
|
|
||||||
|
System.err.print(tag);
|
||||||
|
|
||||||
|
for (Object o : args) {
|
||||||
|
System.err.print(" ");
|
||||||
|
System.err.print(o);
|
||||||
|
}
|
||||||
|
System.err.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void trace() {
|
||||||
|
if (!traceEnabled) return;
|
||||||
|
Thread t = Thread.currentThread();
|
||||||
|
StackTraceElement[] st = t.getStackTrace();
|
||||||
|
StackTraceElement caller = st[3];
|
||||||
|
StackTraceElement callee = st[2];
|
||||||
|
|
||||||
|
String tag = "[" + getCurrentLocalDateTimeStamp() + "] " + t.getName() + " - " + caller.getFileName() + ":" + caller.getLineNumber() + " " + caller.getMethodName() + "(...) -> " + callee.getFileName() + ":" + callee.getLineNumber() + " " + callee.getMethodName() + "(...)";
|
||||||
|
|
||||||
|
System.err.println(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCurrentLocalDateTimeStamp() {
|
||||||
|
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,60 +17,50 @@ public class DelayLine implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process(double[][] samples) {
|
public void process(double[][] samples) {
|
||||||
double[][] savedSamples = new double[samples.length][2];
|
double[][] savedSamples = new double[2][samples[Sentence.LEFT].length];
|
||||||
for (int i = 0; i < samples.length; i++) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
savedSamples[i][Sentence.LEFT] = samples[i][Sentence.LEFT];
|
savedSamples[Sentence.LEFT][i] = samples[Sentence.LEFT][i];
|
||||||
savedSamples[i][Sentence.RIGHT] = samples[i][Sentence.RIGHT];
|
savedSamples[Sentence.RIGHT][i] = samples[Sentence.RIGHT][i];
|
||||||
}
|
}
|
||||||
if (wetOnly) {
|
if (wetOnly) {
|
||||||
for (int i = 0; i < samples.length; i++) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
samples[i][Sentence.LEFT] = 0d;
|
samples[Sentence.LEFT][i] = 0d;
|
||||||
samples[i][Sentence.RIGHT] = 0d;
|
samples[Sentence.RIGHT][i] = 0d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double[][] subSamples = new double[samples.length][2];
|
double[][] subSamples = new double[2][samples[Sentence.LEFT].length];
|
||||||
for (int i = 0; i < samples.length; i++) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
subSamples[i][Sentence.LEFT] = savedSamples[i][Sentence.LEFT];
|
subSamples[Sentence.LEFT][i] = savedSamples[Sentence.LEFT][i];
|
||||||
subSamples[i][Sentence.RIGHT] = savedSamples[i][Sentence.RIGHT];
|
subSamples[Sentence.RIGHT][i] = savedSamples[Sentence.RIGHT][i];
|
||||||
}
|
}
|
||||||
for (DelayLineStore d : delayLines) {
|
for (DelayLineStore d : delayLines) {
|
||||||
for (int i = 0; i < samples.length; i++) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
subSamples[i][Sentence.LEFT] = savedSamples[i][Sentence.LEFT];
|
subSamples[Sentence.LEFT][i] = savedSamples[Sentence.LEFT][i];
|
||||||
subSamples[i][Sentence.RIGHT] = savedSamples[i][Sentence.RIGHT];
|
subSamples[Sentence.RIGHT][i] = savedSamples[Sentence.RIGHT][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
d.process(subSamples);
|
d.process(subSamples);
|
||||||
|
|
||||||
for (int i = 0; i < subSamples.length; i++) {
|
for (int i = 0; i < subSamples[Sentence.LEFT].length; i++) {
|
||||||
int off = i + d.getSamples();
|
int off = i + d.getSamples();
|
||||||
if ((off < samples.length) && (off > 0)) {
|
if ((off < samples[Sentence.LEFT].length) && (off > 0)) {
|
||||||
|
samples[Sentence.LEFT][off] = mix(samples[Sentence.LEFT][off], subSamples[Sentence.LEFT][i]);
|
||||||
double[] ns = mix(samples[off], subSamples[i]);
|
samples[Sentence.RIGHT][off] = mix(samples[Sentence.RIGHT][off], subSamples[Sentence.RIGHT][i]);
|
||||||
samples[off][Sentence.LEFT] = ns[Sentence.LEFT];
|
|
||||||
samples[off][Sentence.RIGHT] = ns[Sentence.RIGHT];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double[] mix(double[] a, double[] b) {
|
double mix(double a, double b) {
|
||||||
double[] out = new double[2];
|
double out;
|
||||||
|
|
||||||
if ((a[Sentence.LEFT] < 0) && (b[Sentence.LEFT] < 0)) {
|
if ((a < 0) && (b < 0)) {
|
||||||
out[Sentence.LEFT] = (a[Sentence.LEFT] + b[Sentence.LEFT]) - (a[Sentence.LEFT] * b[Sentence.LEFT]);
|
out = (a + b) - (a * b);
|
||||||
} else if ((a[Sentence.LEFT] > 0) && (b[Sentence.LEFT] > 0)) {
|
} else if ((a > 0) && (b > 0)) {
|
||||||
out[Sentence.LEFT] = (a[Sentence.LEFT] + b[Sentence.LEFT]) - (a[Sentence.LEFT] * b[Sentence.LEFT]);
|
out = (a + b) - (a * b);
|
||||||
} else {
|
} else {
|
||||||
out[Sentence.LEFT] = a[Sentence.LEFT] + b[Sentence.LEFT];
|
out = a + b;
|
||||||
}
|
|
||||||
|
|
||||||
if ((a[Sentence.RIGHT] < 0) && (b[Sentence.RIGHT] < 0)) {
|
|
||||||
out[Sentence.RIGHT] = (a[Sentence.RIGHT] + b[Sentence.RIGHT]) - (a[Sentence.RIGHT] * b[Sentence.RIGHT]);
|
|
||||||
} else if ((a[Sentence.RIGHT] > 0) && (b[Sentence.RIGHT] > 0)) {
|
|
||||||
out[Sentence.RIGHT] = (a[Sentence.RIGHT] + b[Sentence.RIGHT]) - (a[Sentence.RIGHT] * b[Sentence.RIGHT]);
|
|
||||||
} else {
|
|
||||||
out[Sentence.RIGHT] = a[Sentence.RIGHT] + b[Sentence.RIGHT];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
@@ -29,16 +29,16 @@ public class DelayLineStore {
|
|||||||
e.process(samples);
|
e.process(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (double[] sample : samples) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
sample[Sentence.LEFT] *= gain;
|
samples[Sentence.LEFT][i] *= gain;
|
||||||
sample[Sentence.RIGHT] *= gain;
|
samples[Sentence.RIGHT][i] *= gain;
|
||||||
|
|
||||||
if (pan < 0) {
|
if (pan < 0) {
|
||||||
double p = 1 + pan;
|
double p = 1 + pan;
|
||||||
sample[Sentence.RIGHT] *= p;
|
samples[Sentence.RIGHT][i] *= p;
|
||||||
} else {
|
} else {
|
||||||
double p = 1 - pan;
|
double p = 1 - pan;
|
||||||
sample[Sentence.LEFT] *= p;
|
samples[Sentence.LEFT][i] *= p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JButton;
|
||||||
import java.awt.*;
|
import javax.swing.JPanel;
|
||||||
import java.awt.event.*;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.border.*;
|
import javax.swing.JTextArea;
|
||||||
import java.net.*;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
public class DonationPanel extends JPanel {
|
public class DonationPanel extends JPanel {
|
||||||
public DonationPanel() {
|
public DonationPanel() {
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.util.TimerTask;
|
||||||
import java.awt.*;
|
import java.util.Timer;
|
||||||
import java.util.*;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
|
||||||
public class FlashPanel extends JPanel {
|
public class FlashPanel extends JPanel {
|
||||||
|
|
||||||
boolean flash = false;
|
boolean flash = false;
|
||||||
boolean col = false;
|
boolean col = false;
|
||||||
|
|
||||||
java.util.Timer ticker;
|
Timer ticker;
|
||||||
|
|
||||||
public FlashPanel() {
|
public FlashPanel() {
|
||||||
super();
|
super();
|
||||||
ticker = new java.util.Timer(true);
|
ticker = new Timer(true);
|
||||||
ticker.scheduleAtFixedRate(new TimerTask() {
|
ticker.scheduleAtFixedRate(new TimerTask() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (flash) {
|
if (flash) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class Icons {
|
public class Icons {
|
||||||
static public final ImageIcon book = new ImageIcon(Icons.class.getResource("icons/book.png"));
|
static public final ImageIcon book = new ImageIcon(Icons.class.getResource("icons/book.png"));
|
||||||
@@ -39,4 +39,7 @@ public class Icons {
|
|||||||
static public final ImageIcon playto = new ImageIcon(Icons.class.getResource("icons/play-to.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 disable = new ImageIcon(Icons.class.getResource("icons/disable-effects.png"));
|
||||||
static public final ImageIcon manuscript = new ImageIcon(Icons.class.getResource("icons/manuscript.png"));
|
static public final ImageIcon manuscript = new ImageIcon(Icons.class.getResource("icons/manuscript.png"));
|
||||||
|
static public final ImageIcon tooltip = new ImageIcon(Icons.class.getResource("icons/tooltip.png"));
|
||||||
|
static public final ImageIcon queued = new ImageIcon(Icons.class.getResource("icons/queued.png"));
|
||||||
|
static public final ImageIcon processing = new ImageIcon(Icons.class.getResource("icons/processing.png"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JButton;
|
||||||
import javax.swing.event.*;
|
import javax.swing.ImageIcon;
|
||||||
import java.awt.*;
|
import javax.swing.JComponent;
|
||||||
import java.awt.event.*;
|
import javax.swing.KeyStroke;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
public class JButtonSpacePlay extends JButton {
|
public class JButtonSpacePlay extends JButton {
|
||||||
public JButtonSpacePlay(ImageIcon i, String tt, ActionListener al) {
|
public JButtonSpacePlay(ImageIcon i, String tt, ActionListener al) {
|
||||||
|
|||||||
38
src/uk/co/majenko/audiobookrecorder/JLabelFixedWidth.java
Normal file
38
src/uk/co/majenko/audiobookrecorder/JLabelFixedWidth.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
|
||||||
|
public class JLabelFixedWidth extends JLabel {
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
Dimension size;
|
||||||
|
public JLabelFixedWidth(int w, String txt) {
|
||||||
|
super(txt);
|
||||||
|
JLabel t = new JLabel(txt);
|
||||||
|
size = t.getPreferredSize();
|
||||||
|
size.width = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JLabelFixedWidth(int w) {
|
||||||
|
super();
|
||||||
|
JLabel t = new JLabel("nothing");
|
||||||
|
size = t.getPreferredSize();
|
||||||
|
size.width = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getMaximumSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getMinimumSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JSlider;
|
||||||
|
|
||||||
public class JSliderOb extends JSlider {
|
public class JSliderOb extends JSlider {
|
||||||
Object object;
|
Object object;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
import javax.swing.*;
|
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
public class JTextFieldOb extends JTextField {
|
public class JTextFieldOb extends JTextField {
|
||||||
Object object;
|
Object object;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.event.ActionListener;
|
||||||
import javax.swing.event.*;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.*;
|
import javax.swing.JToggleButton;
|
||||||
import java.awt.event.*;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.KeyStroke;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class JToggleButtonSpacePlay extends JToggleButton {
|
public class JToggleButtonSpacePlay extends JToggleButton {
|
||||||
public JToggleButtonSpacePlay(ImageIcon i, String tt, ActionListener al) {
|
public JToggleButtonSpacePlay(ImageIcon i, String tt, ActionListener al) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class LFO implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process(double[][] samples) {
|
public void process(double[][] samples) {
|
||||||
for (double[] sample : samples) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
double v = 0;
|
double v = 0;
|
||||||
switch (waveform) {
|
switch (waveform) {
|
||||||
case SINE: v = Math.sin(phase); break;
|
case SINE: v = Math.sin(phase); break;
|
||||||
@@ -68,12 +68,12 @@ public class LFO implements Effect {
|
|||||||
// Apply it to the sample
|
// Apply it to the sample
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case REPLACE:
|
case REPLACE:
|
||||||
sample[Sentence.LEFT] = (sample[Sentence.LEFT] * v);
|
samples[Sentence.LEFT][i] = (samples[Sentence.LEFT][i] * v);
|
||||||
sample[Sentence.RIGHT] = (sample[Sentence.RIGHT] * v);
|
samples[Sentence.RIGHT][i] = (samples[Sentence.RIGHT][i] * v);
|
||||||
break;
|
break;
|
||||||
case ADD:
|
case ADD:
|
||||||
sample[Sentence.LEFT] += (sample[Sentence.LEFT] * v);
|
samples[Sentence.LEFT][i] += (samples[Sentence.LEFT][i] * v);
|
||||||
sample[Sentence.RIGHT] += (sample[Sentence.RIGHT] * v);
|
samples[Sentence.RIGHT][i] += (samples[Sentence.RIGHT][i] * v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.event.ActionEvent;
|
||||||
import javax.swing.event.*;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
import java.awt.event.*;
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
public class MainToolBar extends JToolBar {
|
public class MainToolBar extends JToolBar {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import java.awt.event.*;
|
|
||||||
|
|
||||||
public class MarkerDragEvent {
|
public class MarkerDragEvent {
|
||||||
|
|
||||||
Object src;
|
Object src;
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.table.*;
|
import javax.swing.table.TableCellRenderer;
|
||||||
import javax.swing.event.*;
|
import javax.swing.JTable;
|
||||||
import java.awt.*;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import java.awt.event.*;
|
import java.util.ArrayList;
|
||||||
import java.io.*;
|
import javax.swing.JScrollPane;
|
||||||
import java.util.*;
|
import java.io.File;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
public class OpenBookPanel extends JPanel {
|
public class OpenBookPanel extends JPanel {
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,42 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.sound.sampled.*;
|
import java.io.File;
|
||||||
import javax.swing.*;
|
import java.util.TreeSet;
|
||||||
import javax.swing.event.*;
|
import java.util.ArrayList;
|
||||||
import java.awt.*;
|
import java.util.HashMap;
|
||||||
import java.awt.event.*;
|
import java.util.prefs.Preferences;
|
||||||
import java.util.*;
|
import java.awt.GridBagConstraints;
|
||||||
import java.util.prefs.*;
|
import java.awt.GridBagLayout;
|
||||||
import java.io.*;
|
import java.awt.BorderLayout;
|
||||||
import javax.swing.tree.*;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Dialog;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.sound.sampled.AudioFormat;
|
||||||
|
import javax.sound.sampled.Mixer;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.sound.sampled.DataLine;
|
||||||
|
import javax.sound.sampled.TargetDataLine;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.SourceDataLine;
|
||||||
|
|
||||||
public class Options extends JDialog {
|
public class Options extends JDialog {
|
||||||
|
|
||||||
@@ -16,8 +44,6 @@ public class Options extends JDialog {
|
|||||||
|
|
||||||
GridBagConstraints constraint;
|
GridBagConstraints constraint;
|
||||||
|
|
||||||
public static ArrayList<EffectGroup> effectChains;
|
|
||||||
|
|
||||||
JComboBox<KVPair> mixerList;
|
JComboBox<KVPair> mixerList;
|
||||||
JComboBox<KVPair> playbackList;
|
JComboBox<KVPair> playbackList;
|
||||||
JComboBox<KVPair> channelList;
|
JComboBox<KVPair> channelList;
|
||||||
@@ -50,6 +76,9 @@ public class Options extends JDialog {
|
|||||||
|
|
||||||
JTextField externalEditor;
|
JTextField externalEditor;
|
||||||
|
|
||||||
|
JTextField speechCommand;
|
||||||
|
JSpinner workerThreads;
|
||||||
|
|
||||||
JTextArea startupScript;
|
JTextArea startupScript;
|
||||||
|
|
||||||
ArrayList<JTextField[]> processorList;
|
ArrayList<JTextField[]> processorList;
|
||||||
@@ -69,7 +98,7 @@ public class Options extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JComboBox<KVPair> addDropdown(JPanel panel, String label, KVPair[] options, String def) {
|
JComboBox<KVPair> addDropdown(JPanel panel, String label, KVPair[] options, String def, String tip) {
|
||||||
JLabel l = new JLabel(label);
|
JLabel l = new JLabel(label);
|
||||||
constraint.gridx = 0;
|
constraint.gridx = 0;
|
||||||
constraint.gridwidth = 1;
|
constraint.gridwidth = 1;
|
||||||
@@ -80,6 +109,9 @@ public class Options extends JDialog {
|
|||||||
JComboBox<KVPair> o = new JComboBox<KVPair>(options);
|
JComboBox<KVPair> o = new JComboBox<KVPair>(options);
|
||||||
constraint.gridx = 1;
|
constraint.gridx = 1;
|
||||||
panel.add(o, constraint);
|
panel.add(o, constraint);
|
||||||
|
Tip t = new Tip(tip);
|
||||||
|
constraint.gridx = 2;
|
||||||
|
panel.add(t, constraint);
|
||||||
|
|
||||||
for (KVPair p : options) {
|
for (KVPair p : options) {
|
||||||
if (p.key.equals(def)) {
|
if (p.key.equals(def)) {
|
||||||
@@ -110,7 +142,7 @@ public class Options extends JDialog {
|
|||||||
constraint.gridy++;
|
constraint.gridy++;
|
||||||
}
|
}
|
||||||
|
|
||||||
JTextField addTextField(JPanel panel, String label, String def) {
|
JTextField addTextField(JPanel panel, String label, String def, String tip) {
|
||||||
JLabel l = new JLabel(label);
|
JLabel l = new JLabel(label);
|
||||||
constraint.gridx = 0;
|
constraint.gridx = 0;
|
||||||
constraint.gridwidth = 1;
|
constraint.gridwidth = 1;
|
||||||
@@ -124,13 +156,18 @@ public class Options extends JDialog {
|
|||||||
constraint.fill = GridBagConstraints.HORIZONTAL;
|
constraint.fill = GridBagConstraints.HORIZONTAL;
|
||||||
panel.add(a, constraint);
|
panel.add(a, constraint);
|
||||||
|
|
||||||
|
Tip t = new Tip(tip);
|
||||||
|
constraint.gridx = 2;
|
||||||
|
panel.add(t, constraint);
|
||||||
|
|
||||||
|
|
||||||
constraint.fill = GridBagConstraints.NONE;
|
constraint.fill = GridBagConstraints.NONE;
|
||||||
|
|
||||||
constraint.gridy++;
|
constraint.gridy++;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
JTextField[] addTwoField(JPanel panel, String def1, String def2) {
|
JTextField[] addTwoField(JPanel panel, String def1, String def2, String tip) {
|
||||||
JTextField a = new JTextField(def1);
|
JTextField a = new JTextField(def1);
|
||||||
constraint.gridx = 0;
|
constraint.gridx = 0;
|
||||||
constraint.fill = GridBagConstraints.HORIZONTAL;
|
constraint.fill = GridBagConstraints.HORIZONTAL;
|
||||||
@@ -141,13 +178,18 @@ public class Options extends JDialog {
|
|||||||
panel.add(b, constraint);
|
panel.add(b, constraint);
|
||||||
constraint.fill = GridBagConstraints.NONE;
|
constraint.fill = GridBagConstraints.NONE;
|
||||||
|
|
||||||
|
Tip t = new Tip(tip);
|
||||||
|
constraint.gridx = 2;
|
||||||
|
panel.add(t, constraint);
|
||||||
|
|
||||||
|
|
||||||
constraint.gridy++;
|
constraint.gridy++;
|
||||||
return new JTextField[] { a, b };
|
return new JTextField[] { a, b };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JTextField addFilePath(JPanel panel, String label, String path, boolean dironly) {
|
JTextField addFilePath(JPanel panel, String label, String path, boolean dironly, String tip) {
|
||||||
JLabel l = new JLabel(label);
|
JLabel l = new JLabel(label);
|
||||||
constraint.gridx = 0;
|
constraint.gridx = 0;
|
||||||
constraint.gridwidth = 1;
|
constraint.gridwidth = 1;
|
||||||
@@ -209,6 +251,10 @@ public class Options extends JDialog {
|
|||||||
constraint.fill = GridBagConstraints.HORIZONTAL;
|
constraint.fill = GridBagConstraints.HORIZONTAL;
|
||||||
panel.add(p, constraint);
|
panel.add(p, constraint);
|
||||||
|
|
||||||
|
Tip t = new Tip(tip);
|
||||||
|
constraint.gridx = 2;
|
||||||
|
panel.add(t, constraint);
|
||||||
|
|
||||||
constraint.fill = GridBagConstraints.NONE;
|
constraint.fill = GridBagConstraints.NONE;
|
||||||
|
|
||||||
constraint.gridy++;
|
constraint.gridy++;
|
||||||
@@ -235,7 +281,7 @@ public class Options extends JDialog {
|
|||||||
constraint.gridy++;
|
constraint.gridy++;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSpinner addSpinner(JPanel panel, String label, int min, int max, int step, int value, String suffix) {
|
JSpinner addSpinner(JPanel panel, String label, int min, int max, int step, int value, String suffix, String tip) {
|
||||||
JLabel l = new JLabel(label);
|
JLabel l = new JLabel(label);
|
||||||
constraint.gridx = 0;
|
constraint.gridx = 0;
|
||||||
constraint.gridwidth = 1;
|
constraint.gridwidth = 1;
|
||||||
@@ -255,6 +301,10 @@ public class Options extends JDialog {
|
|||||||
|
|
||||||
constraint.fill = GridBagConstraints.HORIZONTAL;
|
constraint.fill = GridBagConstraints.HORIZONTAL;
|
||||||
panel.add(p, constraint);
|
panel.add(p, constraint);
|
||||||
|
Tip t = new Tip(tip);
|
||||||
|
constraint.gridx = 2;
|
||||||
|
panel.add(t, constraint);
|
||||||
|
|
||||||
|
|
||||||
constraint.fill = GridBagConstraints.NONE;
|
constraint.fill = GridBagConstraints.NONE;
|
||||||
|
|
||||||
@@ -263,11 +313,16 @@ public class Options extends JDialog {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JCheckBox addCheckBox(JPanel panel, String label, boolean state) {
|
JCheckBox addCheckBox(JPanel panel, String label, boolean state, String tip) {
|
||||||
constraint.gridx = 1;
|
constraint.gridx = 1;
|
||||||
JCheckBox cb = new JCheckBox(label);
|
JCheckBox cb = new JCheckBox(label);
|
||||||
cb.setSelected(state);
|
cb.setSelected(state);
|
||||||
panel.add(cb, constraint);
|
panel.add(cb, constraint);
|
||||||
|
Tip t = new Tip(tip);
|
||||||
|
constraint.gridx = 2;
|
||||||
|
panel.add(t, constraint);
|
||||||
|
|
||||||
|
|
||||||
constraint.gridy++;
|
constraint.gridy++;
|
||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
@@ -295,93 +350,71 @@ public class Options extends JDialog {
|
|||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
mixerList = addDropdown(optionsPanel, "Recording device:", getRecordingMixerList(), get("audio.recording.device"));
|
mixerList = addDropdown(optionsPanel, "Recording device:", getRecordingMixerList(), get("audio.recording.device"), "This is the system device to record through");
|
||||||
channelList = addDropdown(optionsPanel, "Channels:", getChannelCountList(), get("audio.recording.channels"));
|
channelList = addDropdown(optionsPanel, "Channels:", getChannelCountList(), get("audio.recording.channels"), "How many channels do you want to record - stereo or mono?");
|
||||||
rateList = addDropdown(optionsPanel, "Sample rate:", getSampleRateList(), get("audio.recording.samplerate"));
|
rateList = addDropdown(optionsPanel, "Sample rate:", getSampleRateList(), get("audio.recording.samplerate"), "The higher the sample rate the better the quality, but the bigger the files.");
|
||||||
bitDepth = addDropdown(optionsPanel, "Sample resolution:", getResolutionList(), get("audio.recording.resolution"));
|
bitDepth = addDropdown(optionsPanel, "Sample resolution:", getResolutionList(), get("audio.recording.resolution"), "The higher the resolution the better the quality, but the bigger the files.");
|
||||||
trimMethod = addDropdown(optionsPanel, "Auto-trim method:", getTrimMethods(), get("audio.recording.trim"));
|
trimMethod = addDropdown(optionsPanel, "Auto-trim method:", getTrimMethods(), get("audio.recording.trim"), "None: don't auto-trim. FFT: Compare the FFT profile of blocks to the room noise profile and trim silent blocks, Peak: Look for the start and end rise and fall points");
|
||||||
fftThreshold = addSpinner(optionsPanel, "FFT threshold:", 0, 100, 1, getInteger("audio.recording.trim.fft"), "");
|
fftThreshold = addSpinner(optionsPanel, "FFT threshold:", 0, 100, 1, getInteger("audio.recording.trim.fft"), "", "This specifies the difference (in hundredths) between the power of FFT buckets in a sample block compared to the overall power of the same FFT bucket in the room noise. Raising this number makes the FFT trimming less sensitive.");
|
||||||
fftBlockSize = addDropdown(optionsPanel, "FFT Block size:", getFFTBlockSizes(), get("audio.recording.trim.blocksize"));
|
fftBlockSize = addDropdown(optionsPanel, "FFT Block size:", getFFTBlockSizes(), get("audio.recording.trim.blocksize"), "How large an FFT block should be when processing. Larger values increase sensitivity but at the epxense of resolution.");
|
||||||
maxGainVariance = addSpinner(optionsPanel, "Maximum gain variance:", 0, 100, 1, getInteger("audio.recording.variance"), "");
|
maxGainVariance = addSpinner(optionsPanel, "Maximum gain variance:", 0, 100, 1, getInteger("audio.recording.variance"), "", "This is how much the gain is allowed to vary by from phrase to phrase when normalizing an entire chapter.");
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
playbackList = addDropdown(optionsPanel, "Playback device:", getPlaybackMixerList(), get("audio.playback.device"));
|
playbackList = addDropdown(optionsPanel, "Playback device:", getPlaybackMixerList(), get("audio.playback.device"), "Which device to play back through");
|
||||||
playbackBlockSize = addDropdown(optionsPanel, "Playback Block size:", getPlaybackBlockSizes(), get("audio.playback.blocksize"));
|
playbackBlockSize = addDropdown(optionsPanel, "Playback Block size:", getPlaybackBlockSizes(), get("audio.playback.blocksize"), "How big the playback buffer should be. Larger is smoother playback but the playback marker in the waveform becomes more out of sync");
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
storageFolder = addFilePath(optionsPanel, "Storage folder:", get("path.storage"), true);
|
storageFolder = addFilePath(optionsPanel, "Storage folder:", get("path.storage"), true, "This is where all your working audiobooks are stored.");
|
||||||
archiveFolder = addFilePath(optionsPanel, "Archive folder:", get("path.archive"), true);
|
archiveFolder = addFilePath(optionsPanel, "Archive folder:", get("path.archive"), true, "This is where audiobooks are archived to.");
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
preChapterGap = addSpinner(optionsPanel, "Default pre-chapter gap:", 0, 5000, 100, getInteger("catenation.pre-chapter"), "ms");
|
preChapterGap = addSpinner(optionsPanel, "Default pre-chapter gap:", 0, 5000, 100, getInteger("catenation.pre-chapter"), "ms", "How much room noise to add at the beginning of a chapter.");
|
||||||
postChapterGap = addSpinner(optionsPanel, "Default post-chapter gap:", 0, 5000, 100, getInteger("catenation.post-chapter"), "ms");
|
postChapterGap = addSpinner(optionsPanel, "Default post-chapter gap:", 0, 5000, 100, getInteger("catenation.post-chapter"), "ms", "How much room noise to add to the end of a chapter.");
|
||||||
postSentenceGap = addSpinner(optionsPanel, "Default post-sentence gap:", 0, 5000, 100, getInteger("catenation.post-sentence"), "ms");
|
postSentenceGap = addSpinner(optionsPanel, "Default post-sentence gap:", 0, 5000, 100, getInteger("catenation.post-sentence"), "ms", "How much room noise to add between normal sentences.");
|
||||||
shortSentenceGap = addSpinner(optionsPanel, "Short post-sentence gap:", 0, 5000, 100, getInteger("catenation.short-sentence"), "ms");
|
shortSentenceGap = addSpinner(optionsPanel, "Short post-sentence gap:", 0, 5000, 100, getInteger("catenation.short-sentence"), "ms", "How much room noise to add between 'continuations'.");
|
||||||
postParagraphGap = addSpinner(optionsPanel, "Default post-paragraph gap:", 0, 5000, 100, getInteger("catenation.post-paragraph"), "ms");
|
postParagraphGap = addSpinner(optionsPanel, "Default post-paragraph gap:", 0, 5000, 100, getInteger("catenation.post-paragraph"), "ms", "How much room noise to add between paragraphs.");
|
||||||
postSectionGap = addSpinner(optionsPanel, "Default post-section gap:", 0, 5000, 100, getInteger("catenation.post-section"), "ms");
|
postSectionGap = addSpinner(optionsPanel, "Default post-section gap:", 0, 5000, 100, getInteger("catenation.post-section"), "ms", "How much room noise to add between sections.");
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
ffmpegLocation = addFilePath(optionsPanel, "FFMPEG location:", get("path.ffmpeg"), false);
|
ffmpegLocation = addFilePath(optionsPanel, "FFMPEG location:", get("path.ffmpeg"), false, "Path to your ffmpeg executable.");
|
||||||
bitRate = addDropdown(optionsPanel, "Export bitrate:", getBitrates(), get("audio.export.bitrate"));
|
bitRate = addDropdown(optionsPanel, "Export bitrate:", getBitrates(), get("audio.export.bitrate"), "The MP3 bitrate to produce");
|
||||||
channels = addDropdown(optionsPanel, "Export channels:", getChannelCountList(), get("audio.export.channels"));
|
channels = addDropdown(optionsPanel, "Export channels:", getChannelCountList(), get("audio.export.channels"), "Mono or stereo MP3 production");
|
||||||
exportRate = addDropdown(optionsPanel, "Export sample rate:", getSampleRateList(), get("audio.export.samplerate"));
|
exportRate = addDropdown(optionsPanel, "Export sample rate:", getSampleRateList(), get("audio.export.samplerate"), "Sample frequency of the produced MP3");
|
||||||
|
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
enableParsing = addCheckBox(optionsPanel, "Enable automatic sphinx speech-to-text (**SLOW**)", getBoolean("process.sphinx"));
|
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.");
|
||||||
|
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.");
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
externalEditor = addTextField(optionsPanel, "External Editor Command", get("editor.external"));
|
externalEditor = addTextField(optionsPanel, "External Editor Command", get("editor.external"), "The program to run when you select 'Open in external editor'.");
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
cacheSize = addSpinner(optionsPanel, "Cache size:", 2, 100, 1, getInteger("cache.size"), "");
|
cacheSize = addSpinner(optionsPanel, "Cache size:", 2, 100, 1, getInteger("cache.size"), "", "How many phrases to keep cached in memory at once. More gives a smoother editing experience, but you can easily run out of memory if you are not careful.");
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
tabs.add("Options", new JScrollPane(optionsPanel));
|
tabs.add("Options", new JScrollPane(optionsPanel));
|
||||||
|
|
||||||
JPanel effectChains = new JPanel();
|
|
||||||
effectChains.setLayout(new BorderLayout());
|
|
||||||
|
|
||||||
JPanel effectDetails = new JPanel() {
|
|
||||||
public Dimension getPreferredSize() {
|
|
||||||
return new Dimension(200, 400);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DefaultTreeModel m = new DefaultTreeModel(new DefaultMutableTreeNode("Effect Chains"));
|
|
||||||
|
|
||||||
JTree effectChainTree = new JTree(m);
|
|
||||||
effectChains.add(effectChainTree, BorderLayout.CENTER);
|
|
||||||
effectChains.add(effectDetails, BorderLayout.EAST);
|
|
||||||
|
|
||||||
tabs.add("Effects Chains", new JScrollPane(effectChains));
|
|
||||||
|
|
||||||
JPanel startScript = new JPanel();
|
JPanel startScript = new JPanel();
|
||||||
startScript.setLayout(new BorderLayout());
|
startScript.setLayout(new BorderLayout());
|
||||||
|
startScript.setBorder(new EmptyBorder(15, 15, 15, 15));
|
||||||
startupScript = new JTextArea(get("scripts.startup"));
|
startupScript = new JTextArea(get("scripts.startup"));
|
||||||
|
startupScript.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
startupScript.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
|
||||||
startScript.add(startupScript, BorderLayout.CENTER);
|
startScript.add(startupScript, BorderLayout.CENTER);
|
||||||
tabs.add("Startup Script", startScript);
|
tabs.add("Startup Script", startScript);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JPanel effects = new JPanel();
|
|
||||||
effects.setLayout(new GridBagLayout());
|
|
||||||
constraint.gridx = 0;
|
|
||||||
constraint.gridy = 0;
|
|
||||||
constraint.gridwidth = 1;
|
|
||||||
constraint.gridheight = 1;
|
|
||||||
|
|
||||||
etherealOffset = addSpinner(effects, "Ethereal Voice Offset", 0, 2000, 10, getInteger("effects.ethereal.offset"), "ms");
|
|
||||||
etherealIterations = addSpinner(effects, "Ethereal Voice Iterations", 1, 10, 1, getInteger("effects.ethereal.iterations"), "");
|
|
||||||
etherealAttenuation = addSpinner(effects, "Ethereal Voice Attenuation", 0, 100, 1, getInteger("effects.ethereal.attenuation"), "%");
|
|
||||||
|
|
||||||
tabs.add("Effects", effects);
|
|
||||||
|
|
||||||
|
|
||||||
JPanel processors = new JPanel();
|
JPanel processors = new JPanel();
|
||||||
processors.setLayout(new BorderLayout());
|
processors.setLayout(new BorderLayout());
|
||||||
@@ -406,19 +439,16 @@ public class Options extends JDialog {
|
|||||||
String command = get("editor.processor." + i + ".command");
|
String command = get("editor.processor." + i + ".command");
|
||||||
if (name == null || command == null) break;
|
if (name == null || command == null) break;
|
||||||
if (name.equals("") || command.equals("")) break;
|
if (name.equals("") || command.equals("")) break;
|
||||||
JTextField[] f = addTwoField(processorListPanel, name, command);
|
JTextField[] f = addTwoField(processorListPanel, name, command, "Specify the name of the operation (which will appear in context menus) and the command to run for that operation. The command should have parameters separated with :: and %f for the input filename and %o for the output filename.");
|
||||||
processorList.add(f);
|
processorList.add(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
JTextField[] f = addTwoField(processorListPanel, "", "");
|
JTextField[] f = addTwoField(processorListPanel, "", "", "Specify the name of the operation (which will appear in context menus) and the command to run for that operation. The command should have parameters separated with :: and %f for the input filename and %o for the output filename.");
|
||||||
processorList.add(f);
|
processorList.add(f);
|
||||||
|
|
||||||
tabs.add("Processors", processors);
|
tabs.add("Processors", processors);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add(tabs, BorderLayout.CENTER);
|
add(tabs, BorderLayout.CENTER);
|
||||||
|
|
||||||
setTitle("Options");
|
setTitle("Options");
|
||||||
@@ -594,6 +624,8 @@ public class Options extends JDialog {
|
|||||||
defaultPrefs.put("audio.export.channels", "2");
|
defaultPrefs.put("audio.export.channels", "2");
|
||||||
defaultPrefs.put("audio.export.samplerate", "44100");
|
defaultPrefs.put("audio.export.samplerate", "44100");
|
||||||
defaultPrefs.put("process.sphinx", "false");
|
defaultPrefs.put("process.sphinx", "false");
|
||||||
|
defaultPrefs.put("process.command", "speech-to-text \"%f\"");
|
||||||
|
defaultPrefs.put("process.threads", "10");
|
||||||
|
|
||||||
defaultPrefs.put("editor.external", "");
|
defaultPrefs.put("editor.external", "");
|
||||||
|
|
||||||
@@ -601,10 +633,6 @@ public class Options extends JDialog {
|
|||||||
|
|
||||||
defaultPrefs.put("scripts.startup", "");
|
defaultPrefs.put("scripts.startup", "");
|
||||||
|
|
||||||
defaultPrefs.put("effects.ethereal.offset", "50");
|
|
||||||
defaultPrefs.put("effects.ethereal.iterations", "3");
|
|
||||||
defaultPrefs.put("effects.ethereal.attenuation", "50");
|
|
||||||
|
|
||||||
if (prefs == null) {
|
if (prefs == null) {
|
||||||
prefs = Preferences.userNodeForPackage(AudiobookRecorder.class);
|
prefs = Preferences.userNodeForPackage(AudiobookRecorder.class);
|
||||||
}
|
}
|
||||||
@@ -718,6 +746,8 @@ public class Options extends JDialog {
|
|||||||
set("audio.export.channels", ((KVPair)channels.getSelectedItem()).key);
|
set("audio.export.channels", ((KVPair)channels.getSelectedItem()).key);
|
||||||
set("audio.export.samplerate", ((KVPair)exportRate.getSelectedItem()).key);
|
set("audio.export.samplerate", ((KVPair)exportRate.getSelectedItem()).key);
|
||||||
set("process.sphinx", enableParsing.isSelected());
|
set("process.sphinx", enableParsing.isSelected());
|
||||||
|
set("process.command", speechCommand.getText());
|
||||||
|
set("process.threads", workerThreads.getValue());
|
||||||
set("editor.external", externalEditor.getText());
|
set("editor.external", externalEditor.getText());
|
||||||
set("cache.size", cacheSize.getValue());
|
set("cache.size", cacheSize.getValue());
|
||||||
set("audio.recording.trim.fft", fftThreshold.getValue());
|
set("audio.recording.trim.fft", fftThreshold.getValue());
|
||||||
@@ -725,10 +755,6 @@ public class Options extends JDialog {
|
|||||||
set("audio.recording.trim.blocksize", ((KVPair)fftBlockSize.getSelectedItem()).key);
|
set("audio.recording.trim.blocksize", ((KVPair)fftBlockSize.getSelectedItem()).key);
|
||||||
set("audio.playback.blocksize", ((KVPair)playbackBlockSize.getSelectedItem()).key);
|
set("audio.playback.blocksize", ((KVPair)playbackBlockSize.getSelectedItem()).key);
|
||||||
|
|
||||||
set("effects.ethereal.offset", etherealOffset.getValue());
|
|
||||||
set("effects.ethereal.iterations", etherealIterations.getValue());
|
|
||||||
set("effects.ethereal.attenuation", etherealAttenuation.getValue());
|
|
||||||
|
|
||||||
set("scripts.startup", startupScript.getText());
|
set("scripts.startup", startupScript.getText());
|
||||||
|
|
||||||
int procNo = 0;
|
int procNo = 0;
|
||||||
@@ -823,51 +849,4 @@ public class Options extends JDialog {
|
|||||||
pairs[7] = new KVPair<String, String>("131072", "131072");
|
pairs[7] = new KVPair<String, String>("131072", "131072");
|
||||||
return pairs;
|
return pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createEffectChains() {
|
|
||||||
effectChains = new ArrayList<EffectGroup>();
|
|
||||||
|
|
||||||
for (int i = 0; i < 999999; i++) {
|
|
||||||
if (get("effects." + i + ".name") == null) {
|
|
||||||
EffectGroup e = new EffectGroup(get("effects." + i + ".name"));
|
|
||||||
for (int j = 0; i < 999999; j++) {
|
|
||||||
String type = get("effects." + i + ".children." + j + ".type");
|
|
||||||
if (type == null) break;
|
|
||||||
|
|
||||||
if (type.equals("biquad")) {
|
|
||||||
int bqt = getInteger("effects." + i + ".children." + j + ".filtertype");
|
|
||||||
double fc = getDouble("effects." + i + ".children." + j + ".fc");
|
|
||||||
double q = getDouble("effects." + i + ".children." + j + ".q");
|
|
||||||
double gain = getDouble("effects." + i + ".children." + j + ".gain");
|
|
||||||
Biquad b = new Biquad(bqt, fc, q, gain);
|
|
||||||
e.addEffect(b);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type.equals("amplifier")) {
|
|
||||||
double gain = getDouble("effects." + i + ".children." + j + ".gain");
|
|
||||||
Amplifier a = new Amplifier(gain);
|
|
||||||
e.addEffect(a);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type.equals("delayline")) {
|
|
||||||
DelayLine l = new DelayLine();
|
|
||||||
for (int c = 0; c < 999999; c++) {
|
|
||||||
if (get("effects." + i + ".children." + j + ".lines." + c + ".samples") == null) break;
|
|
||||||
int samples = getInteger("effects." + i + ".children." + j + ".lines." + c + ".samples");
|
|
||||||
double gain = getDouble("effects." + i + ".children." + j + ".lines." + c + ".gain");
|
|
||||||
l.addDelayLine(samples, gain);
|
|
||||||
}
|
|
||||||
e.addEffect(l);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
effectChains.add(e);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class Overlays {
|
public class Overlays {
|
||||||
static public final ImageIcon locked = new ImageIcon(Overlays.class.getResource("overlays/locked.png"));
|
static public final ImageIcon locked = new ImageIcon(Overlays.class.getResource("overlays/locked.png"));
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ public class Pan implements Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process(double[][] samples) {
|
public void process(double[][] samples) {
|
||||||
for (double[] sample : samples) {
|
for (int i = 0; i < samples[Sentence.LEFT].length; i++) {
|
||||||
if (pan < 0) {
|
if (pan < 0) {
|
||||||
double p = 1 + pan;
|
double p = 1 + pan;
|
||||||
sample[Sentence.RIGHT] *= p;
|
samples[Sentence.RIGHT][i] *= p;
|
||||||
} else {
|
} else {
|
||||||
double p = 1 - pan;
|
double p = 1 - pan;
|
||||||
sample[Sentence.LEFT] *= p;
|
samples[Sentence.LEFT][i] *= p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.event.*;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.border.*;
|
import javax.swing.JProgressBar;
|
||||||
import java.awt.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.*;
|
import it.sauronsoftware.jave.MultimediaInfo;
|
||||||
import java.util.*;
|
import it.sauronsoftware.jave.EncoderProgressListener;
|
||||||
import it.sauronsoftware.jave.*;
|
import java.awt.Dialog;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
public class ProgressDialog extends JDialog implements EncoderProgressListener {
|
public class ProgressDialog extends JDialog implements EncoderProgressListener {
|
||||||
JLabel message;
|
JLabel message;
|
||||||
|
|||||||
71
src/uk/co/majenko/audiobookrecorder/QueueMonitor.java
Normal file
71
src/uk/co/majenko/audiobookrecorder/QueueMonitor.java
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Color;
|
||||||
|
|
||||||
|
public class QueueMonitor extends JPanel {
|
||||||
|
|
||||||
|
ArrayList<WorkerThread> threadList = new ArrayList<WorkerThread>();
|
||||||
|
Queue queue;
|
||||||
|
|
||||||
|
public QueueMonitor(Queue q) {
|
||||||
|
super();
|
||||||
|
queue = q;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addThread(WorkerThread t) {
|
||||||
|
threadList.add(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void purgeQueue() {
|
||||||
|
synchronized (queue) {
|
||||||
|
queue.clear();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
return new Dimension(100 + (24 * threadList.size()), 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getMinimumSize() {
|
||||||
|
return getPreferredSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getMaximumSize() {
|
||||||
|
return getPreferredSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
Rectangle size = g.getClipBounds();
|
||||||
|
g.setColor(getBackground());
|
||||||
|
g.fillRect(0, 0, size.width - 1, size.height - 1);
|
||||||
|
g.setColor(new Color(10, 10, 10));
|
||||||
|
g.drawRect(0, 0, size.width - 1, size.height - 1);
|
||||||
|
g.setFont(getFont());
|
||||||
|
|
||||||
|
for (int i = 0; i < threadList.size(); i++) {
|
||||||
|
WorkerThread t = threadList.get(i);
|
||||||
|
if (t.isRunning()) {
|
||||||
|
g.setColor(new Color(50, 200, 0));
|
||||||
|
} else {
|
||||||
|
g.setColor(new Color(80, 0, 0));
|
||||||
|
}
|
||||||
|
g.fillOval(i * 24 + 4, 4, 22 - 8, 22 - 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.setColor(getForeground());
|
||||||
|
g.drawString("Queued: " + queue.size(), threadList.size() * 24 + 4, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
25
src/uk/co/majenko/audiobookrecorder/SentenceJob.java
Normal file
25
src/uk/co/majenko/audiobookrecorder/SentenceJob.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
|
import java.lang.Runnable;
|
||||||
|
|
||||||
|
public abstract class SentenceJob implements Runnable {
|
||||||
|
protected Sentence sentence;
|
||||||
|
|
||||||
|
public SentenceJob(Sentence s) {
|
||||||
|
sentence = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQueued() {
|
||||||
|
sentence.setQueued();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDequeued() {
|
||||||
|
sentence.setDequeued();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessing() {
|
||||||
|
sentence.setProcessing();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void run();
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import java.util.*;
|
import javax.swing.SpinnerModel;
|
||||||
import javax.swing.*;
|
import java.util.ArrayList;
|
||||||
import javax.swing.event.*;
|
import javax.swing.event.ChangeListener;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
|
||||||
public class SteppedNumericSpinnerModel implements SpinnerModel {
|
public class SteppedNumericSpinnerModel implements SpinnerModel {
|
||||||
int min;
|
int min;
|
||||||
|
|||||||
115
src/uk/co/majenko/audiobookrecorder/Tip.java
Normal file
115
src/uk/co/majenko/audiobookrecorder/Tip.java
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JToolTip;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.awt.font.FontRenderContext;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import org.apache.commons.text.WordUtils;
|
||||||
|
|
||||||
|
public class Tip extends JLabel implements MouseListener {
|
||||||
|
String tip = null;
|
||||||
|
|
||||||
|
public Tip(String text) {
|
||||||
|
tip = WordUtils.wrap(text, 50);
|
||||||
|
|
||||||
|
setToolTipText(text);
|
||||||
|
setIcon(Icons.tooltip);
|
||||||
|
addMouseListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JToolTip createToolTip() {
|
||||||
|
JToolTip tt = new JToolTip() {
|
||||||
|
public String getTipText() {
|
||||||
|
return "*" + tip + "*";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
|
||||||
|
Rectangle r = g.getClipBounds();
|
||||||
|
|
||||||
|
JLabel l = new JLabel();
|
||||||
|
|
||||||
|
AffineTransform affinetransform = new AffineTransform();
|
||||||
|
FontRenderContext frc = new FontRenderContext(affinetransform,true,true);
|
||||||
|
Font f = l.getFont().deriveFont(14f);
|
||||||
|
|
||||||
|
g.setColor(new Color(200, 200, 180));
|
||||||
|
g.fillRect(0, 0, r.width, r.height);
|
||||||
|
|
||||||
|
g.setColor(new Color(10, 10, 10));
|
||||||
|
g.setFont(f);
|
||||||
|
int y = 3;
|
||||||
|
String[] lines = tip.split("\n");
|
||||||
|
for (String line : lines) {
|
||||||
|
Rectangle2D bounds = f.getStringBounds(line, frc);
|
||||||
|
y += bounds.getHeight();
|
||||||
|
g.drawString(line, 5, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
|
||||||
|
JLabel l = new JLabel();
|
||||||
|
AffineTransform affinetransform = new AffineTransform();
|
||||||
|
FontRenderContext frc = new FontRenderContext(affinetransform,true,true);
|
||||||
|
Font f = l.getFont().deriveFont(14f);
|
||||||
|
|
||||||
|
String[] lines = tip.split("\n");
|
||||||
|
int w = 0;
|
||||||
|
int h = 0;
|
||||||
|
for (String line : lines) {
|
||||||
|
Rectangle2D bounds = f.getStringBounds(line, frc);
|
||||||
|
double fw = bounds.getWidth();
|
||||||
|
if (fw > w) w = (int)fw;
|
||||||
|
h += bounds.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
Dimension s = new Dimension(w + 10, h + 10);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tt.removeAll();
|
||||||
|
JPanel p = new JPanel();
|
||||||
|
tt.add(p);
|
||||||
|
JLabel l = new JLabel(tip);
|
||||||
|
l.setBackground(new Color(200, 200, 180));
|
||||||
|
l.setForeground(new Color(0, 0, 0));
|
||||||
|
p.add(l);
|
||||||
|
return tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseEntered(MouseEvent evt) {
|
||||||
|
// showTipWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseExited(MouseEvent evt) {
|
||||||
|
// hideTipWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mousePressed(MouseEvent evt) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseReleased(MouseEvent evt) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseClicked(MouseEvent evt) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
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.*;
|
|
||||||
import java.net.*;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Desktop;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
public static Image getScaledImage(Image srcImg, int w, int h){
|
public static Image getScaledImage(Image srcImg, int w, int h){
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package uk.co.majenko.audiobookrecorder;
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.*;
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.awt.event.*;
|
import javax.swing.JPanel;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import java.io.*;
|
import java.awt.Graphics;
|
||||||
import javax.sound.sampled.*;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
|
||||||
public class Waveform extends JPanel implements MouseListener, MouseMotionListener {
|
public class Waveform extends JPanel implements MouseListener, MouseMotionListener {
|
||||||
|
|
||||||
@@ -34,6 +37,8 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
int offsetFactor = 0;
|
int offsetFactor = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
|
String loadedId = null;
|
||||||
|
|
||||||
ArrayList<MarkerDragListener> markerDragListeners;
|
ArrayList<MarkerDragListener> markerDragListeners;
|
||||||
|
|
||||||
public Waveform() {
|
public Waveform() {
|
||||||
@@ -79,7 +84,7 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
|
|
||||||
if (samples != null) {
|
if (samples != null) {
|
||||||
|
|
||||||
int num = samples.length;
|
int num = samples[Sentence.LEFT].length;
|
||||||
step = num / zoomFactor / w;
|
step = num / zoomFactor / w;
|
||||||
if (step == 0) return;
|
if (step == 0) return;
|
||||||
|
|
||||||
@@ -97,8 +102,8 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
double lmax = 0;
|
double lmax = 0;
|
||||||
|
|
||||||
for (int o = 0; o < step; o++) {
|
for (int o = 0; o < step; o++) {
|
||||||
if (offset + (n * step) + o >= samples.length) break;
|
if (offset + (n * step) + o >= samples[Sentence.LEFT].length) break;
|
||||||
double sample = (samples[offset + (n * step) + o][Sentence.LEFT] + samples[offset + (n * step) + o][Sentence.RIGHT]) / 2d;
|
double sample = (samples[Sentence.LEFT][offset + (n * step) + o] + samples[Sentence.RIGHT][offset + (n * step) + o]) / 2d;
|
||||||
if (sample >= 0) {
|
if (sample >= 0) {
|
||||||
have += sample;
|
have += sample;
|
||||||
hcnt++;
|
hcnt++;
|
||||||
@@ -387,4 +392,12 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
public int getCutEnd() {
|
public int getCutEnd() {
|
||||||
return cutExit;
|
return cutExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
loadedId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return loadedId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
62
src/uk/co/majenko/audiobookrecorder/WorkerThread.java
Normal file
62
src/uk/co/majenko/audiobookrecorder/WorkerThread.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package uk.co.majenko.audiobookrecorder;
|
||||||
|
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
|
public class WorkerThread extends Thread {
|
||||||
|
private static int instance = 0;
|
||||||
|
private final Queue<Runnable> queue;
|
||||||
|
private final QueueMonitor monitor;
|
||||||
|
|
||||||
|
private boolean running = false;
|
||||||
|
|
||||||
|
public WorkerThread(Queue<Runnable> queue, QueueMonitor mon) {
|
||||||
|
this.queue = queue;
|
||||||
|
monitor = mon;
|
||||||
|
setName("Worker Thread " + (instance++));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Debug.d(getName(), "started");
|
||||||
|
while ( true ) {
|
||||||
|
try {
|
||||||
|
Runnable work = null;
|
||||||
|
|
||||||
|
synchronized ( queue ) {
|
||||||
|
while ( queue.isEmpty() ) {
|
||||||
|
Debug.d(getName(), "waiting on work");
|
||||||
|
queue.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.d(getName(), "got work");
|
||||||
|
|
||||||
|
// Get the next work item off of the queue
|
||||||
|
work = queue.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
running = true;
|
||||||
|
monitor.repaint();
|
||||||
|
if (work instanceof SentenceJob) {
|
||||||
|
SentenceJob sj = (SentenceJob)work;
|
||||||
|
sj.setProcessing();
|
||||||
|
}
|
||||||
|
work.run();
|
||||||
|
if (work instanceof SentenceJob) {
|
||||||
|
SentenceJob sj = (SentenceJob)work;
|
||||||
|
sj.setDequeued();
|
||||||
|
}
|
||||||
|
running = false;
|
||||||
|
monitor.repaint();
|
||||||
|
}
|
||||||
|
catch ( InterruptedException ie ) {
|
||||||
|
ie.printStackTrace();
|
||||||
|
break; // Terminate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Debug.d(getName(), "died");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
return running;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user