Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3eb6704f2f | |||
| cd24beb8a6 | |||
| fa287305eb | |||
| 3fb656b693 | |||
| f514993525 | |||
| 81787260c9 | |||
| f9ad396228 | |||
| 8976f2e359 | |||
| 187c3edaf6 | |||
| 02e85fb354 | |||
| 289834021f | |||
| 04fea4acb2 | |||
| 54739b0a75 | |||
| ea5520a729 | |||
| 0a19d8d308 | |||
| 4dbe3e23b7 | |||
| c43cfc3b69 | |||
| babd3d2052 | |||
| 9464839b4d | |||
| bcf7875414 | |||
| 732894a0fb | |||
| 146bf5a3c2 | |||
| b05bfde094 | |||
| 37d372b8f5 | |||
| c01fee3b73 | |||
| c907e735c6 | |||
| 7545e33d2f | |||
| ebf961449a | |||
| 45d6882527 | |||
| 2ec370ad61 | |||
| 63d5c4af8e | |||
| 9619fd574e | |||
| adeb42070d | |||
| d207d246bf |
7
ExampleFilters/alien.eff
Normal file
7
ExampleFilters/alien.eff
Normal file
@@ -0,0 +1,7 @@
|
||||
<effect name="Alien">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<lfo frequency="100" depth="0.5" />
|
||||
</effect>
|
||||
@@ -1,5 +1,7 @@
|
||||
<effect name="Big Echo">
|
||||
<biquad type="notch" fc="140" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<delayline>
|
||||
<delay samples="22000" gain="0.2" pan="-0.3">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<effect name="Cut Computer Hum">
|
||||
<biquad type="notch" fc="140" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
</effect>
|
||||
|
||||
7
ExampleFilters/cuthumagc.eff
Normal file
7
ExampleFilters/cuthumagc.eff
Normal file
@@ -0,0 +1,7 @@
|
||||
<effect name="Cut Computer Hum (with AGC)">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<agc ceiling="0.666" limit="1" attack="0.1" decay="0.01" />
|
||||
</effect>
|
||||
@@ -1,21 +1,23 @@
|
||||
<effect name="Ethereal Voice">
|
||||
<biquad type="notch" fc="140" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<amplifier gain="0.1" />
|
||||
<delayline>
|
||||
<delay samples="4000" gain="1.0" pan="-0.3">
|
||||
<delay samples="2000" gain="1.0" pan="-0.3">
|
||||
<biquad type="highpass" fc="400" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="8000" gain="1.5" pan="0.3">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
<delay samples="4000" gain="1.1" pan="0.3">
|
||||
<biquad type="highpass" fc="800" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="12000" gain="2.0" pan="-0.5">
|
||||
<biquad type="highpass" fc="200" q="1" gain="0" />
|
||||
<delay samples="8000" gain="1.2" pan="-0.5">
|
||||
<biquad type="highpass" fc="1000" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="16000" gain="3.0" pan="0.5">
|
||||
<biquad type="highpass" fc="100" q="1" gain="0" />
|
||||
<delay samples="10000" gain="1.3" pan="0.5">
|
||||
<biquad type="highpass" fc="1500" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="20000" gain="15.0" pan="0" />
|
||||
<delay samples="12000" gain="15.0" pan="0" />
|
||||
</delayline>
|
||||
<biquad type="lowshelf" fc="1000" q="2.2" gain="-10" />
|
||||
<biquad type="lowshelf" fc="2000" q="2.2" gain="-10" />
|
||||
<amplifier gain="1.5" />
|
||||
</effect>
|
||||
|
||||
18
ExampleFilters/largeroom.eff
Normal file
18
ExampleFilters/largeroom.eff
Normal file
@@ -0,0 +1,18 @@
|
||||
<effect name="Large Room (quiet)">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<delayline>
|
||||
<delay samples="5500" gain="0.2" pan="-0.3">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="11000" gain="0.05" pan="0.3">
|
||||
<biquad type="highpass" fc="600" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="16500" gain="0.01" pan="0.0">
|
||||
<biquad type="highpass" fc="600" q="1" gain="0" />
|
||||
</delay>
|
||||
</delayline>
|
||||
<amplifier gain="0.3" />
|
||||
</effect>
|
||||
18
ExampleFilters/largeroomloud.eff
Normal file
18
ExampleFilters/largeroomloud.eff
Normal file
@@ -0,0 +1,18 @@
|
||||
<effect name="Large Room (loud)">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||
<delayline>
|
||||
<delay samples="5500" gain="0.2" pan="-0.3">
|
||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="11000" gain="0.05" pan="0.3">
|
||||
<biquad type="highpass" fc="600" q="1" gain="0" />
|
||||
</delay>
|
||||
<delay samples="16500" gain="0.01" pan="0.0">
|
||||
<biquad type="highpass" fc="600" q="1" gain="0" />
|
||||
</delay>
|
||||
</delayline>
|
||||
<amplifier gain="0.9" />
|
||||
</effect>
|
||||
@@ -1,5 +1,7 @@
|
||||
<effect name="Telephone">
|
||||
<biquad type="notch" fc="140" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowshelf" fc="400" q="10" gain="-20" />
|
||||
<biquad type="highshelf" fc="8000" q="10" gain="-20" />
|
||||
<delayline>
|
||||
|
||||
14
ExampleFilters/radio.eff
Normal file
14
ExampleFilters/radio.eff
Normal file
@@ -0,0 +1,14 @@
|
||||
<effect name="Radio">
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<amplifier gain="0.1" />
|
||||
<biquad type="peak" fc="1000" q="10" gain="45" />
|
||||
<lfo frequency="5000" depth="0.3" />
|
||||
<clipping clip="0.3" />
|
||||
<biquad type="highshelf" fc="8000" q="1" gain="-20" />
|
||||
<delayline>
|
||||
<delay samples="100" gain="0.7" />
|
||||
<delay samples="200" gain="0.5" />
|
||||
</delayline>
|
||||
</effect>
|
||||
@@ -1,5 +1,7 @@
|
||||
<effect name="Robotic">
|
||||
<biquad type="notch" fc="140" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||
<biquad type="lowshelf" fc="100" q="2" gain="-20" />
|
||||
<delayline>
|
||||
<delay samples="400" gain="1" pan="-0.3" />
|
||||
|
||||
BIN
deps/sphinx4-core-5prealpha-SNAPSHOT.jar
LFS
vendored
Normal file
BIN
deps/sphinx4-core-5prealpha-SNAPSHOT.jar
LFS
vendored
Normal file
Binary file not shown.
BIN
deps/sphinx4-data-5prealpha-SNAPSHOT.jar
LFS
vendored
Normal file
BIN
deps/sphinx4-data-5prealpha-SNAPSHOT.jar
LFS
vendored
Normal file
Binary file not shown.
@@ -1 +1 @@
|
||||
version=0.1.5
|
||||
version=0.2.0
|
||||
|
||||
BIN
resources/uk/co/majenko/audiobookrecorder/icons/cut.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/cut.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 674 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/uk/co/majenko/audiobookrecorder/icons/do-cut.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/do-cut.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 576 B |
BIN
resources/uk/co/majenko/audiobookrecorder/icons/play-to.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/play-to.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 752 B |
BIN
resources/uk/co/majenko/audiobookrecorder/icons/split.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/split.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 409 B |
@@ -795,7 +795,7 @@ public abstract class AbstractTheme extends MetalTheme {
|
||||
public FontUIResource getControlTextFont() {
|
||||
if (controlFont == null) {
|
||||
if (JTattooUtilities.isLinux() && JTattooUtilities.isHiresScreen()) {
|
||||
controlFont = new FontUIResource(DIALOG, Font.BOLD, 14);
|
||||
controlFont = new FontUIResource(DIALOG, Font.PLAIN, 14); // bold
|
||||
} else {
|
||||
controlFont = new FontUIResource(DIALOG, Font.PLAIN, 12);
|
||||
}
|
||||
@@ -806,7 +806,7 @@ public abstract class AbstractTheme extends MetalTheme {
|
||||
public FontUIResource getSystemTextFont() {
|
||||
if (systemFont == null) {
|
||||
if (JTattooUtilities.isLinux() && JTattooUtilities.isHiresScreen()) {
|
||||
systemFont = new FontUIResource(DIALOG, Font.BOLD, 14);
|
||||
systemFont = new FontUIResource(DIALOG, Font.PLAIN, 14); // bold
|
||||
} else {
|
||||
systemFont = new FontUIResource(DIALOG, Font.PLAIN, 12);
|
||||
}
|
||||
@@ -817,7 +817,7 @@ public abstract class AbstractTheme extends MetalTheme {
|
||||
public FontUIResource getUserTextFont() {
|
||||
if (userFont == null) {
|
||||
if (JTattooUtilities.isLinux() && JTattooUtilities.isHiresScreen()) {
|
||||
userFont = new FontUIResource(DIALOG, Font.BOLD, 14);
|
||||
userFont = new FontUIResource(DIALOG, Font.PLAIN, 14); // bold
|
||||
} else {
|
||||
userFont = new FontUIResource(DIALOG, Font.PLAIN, 12);
|
||||
}
|
||||
@@ -828,7 +828,7 @@ public abstract class AbstractTheme extends MetalTheme {
|
||||
public FontUIResource getMenuTextFont() {
|
||||
if (menuFont == null) {
|
||||
if (JTattooUtilities.isLinux() && JTattooUtilities.isHiresScreen()) {
|
||||
menuFont = new FontUIResource(DIALOG, Font.BOLD, 14);
|
||||
menuFont = new FontUIResource(DIALOG, Font.PLAIN, 14); // bold
|
||||
} else {
|
||||
menuFont = new FontUIResource(DIALOG, Font.PLAIN, 12);
|
||||
}
|
||||
@@ -839,9 +839,9 @@ public abstract class AbstractTheme extends MetalTheme {
|
||||
public FontUIResource getWindowTitleFont() {
|
||||
if (windowTitleFont == null) {
|
||||
if (JTattooUtilities.isLinux() && JTattooUtilities.isHiresScreen()) {
|
||||
windowTitleFont = new FontUIResource(DIALOG, Font.BOLD, 14);
|
||||
windowTitleFont = new FontUIResource(DIALOG, Font.PLAIN, 14); // bold
|
||||
} else {
|
||||
windowTitleFont = new FontUIResource(DIALOG, Font.BOLD, 12);
|
||||
windowTitleFont = new FontUIResource(DIALOG, Font.PLAIN, 12); // bold
|
||||
}
|
||||
}
|
||||
return windowTitleFont;
|
||||
@@ -850,7 +850,7 @@ public abstract class AbstractTheme extends MetalTheme {
|
||||
public FontUIResource getSubTextFont() {
|
||||
if (smallFont == null) {
|
||||
if (JTattooUtilities.isLinux() && JTattooUtilities.isHiresScreen()) {
|
||||
smallFont = new FontUIResource(DIALOG, Font.BOLD, 12);
|
||||
smallFont = new FontUIResource(DIALOG, Font.PLAIN, 12); // bold
|
||||
} else {
|
||||
smallFont = new FontUIResource(DIALOG, Font.PLAIN, 10);
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ public class HiFiDefaultTheme extends AbstractTheme {
|
||||
tooltipForegroundColor = white;
|
||||
tooltipBackgroundColor = new ColorUIResource(24, 24, 24);
|
||||
|
||||
controlFont = new FontUIResource("Dialog", Font.BOLD, 12);
|
||||
systemFont = new FontUIResource("Dialog", Font.BOLD, 12);
|
||||
userFont = new FontUIResource("Dialog", Font.BOLD, 12);
|
||||
menuFont = new FontUIResource("Dialog", Font.BOLD, 12);
|
||||
windowTitleFont = new FontUIResource("Dialog", Font.BOLD, 12);
|
||||
controlFont = new FontUIResource("Dialog", Font.PLAIN, 12); // bold
|
||||
systemFont = new FontUIResource("Dialog", Font.PLAIN, 12); // bold
|
||||
userFont = new FontUIResource("Dialog", Font.PLAIN, 12); // bold
|
||||
menuFont = new FontUIResource("Dialog", Font.PLAIN, 12); // bold
|
||||
windowTitleFont = new FontUIResource("Dialog", Font.PLAIN, 12); // bold
|
||||
smallFont = new FontUIResource("Dialog", Font.PLAIN, 10);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,18 +42,18 @@ public class HiFiLookAndFeel extends AbstractLookAndFeel {
|
||||
private static final Properties giantFontProps = new Properties();
|
||||
|
||||
static {
|
||||
smallFontProps.setProperty("controlTextFont", "Dialog bold 10");
|
||||
smallFontProps.setProperty("systemTextFont", "Dialog bold 10");
|
||||
smallFontProps.setProperty("controlTextFont", "Dialog 10"); // bold
|
||||
smallFontProps.setProperty("systemTextFont", "Dialog 10"); // bold
|
||||
smallFontProps.setProperty("userTextFont", "Dialog 10");
|
||||
smallFontProps.setProperty("menuTextFont", "Dialog bold 10");
|
||||
smallFontProps.setProperty("windowTitleFont", "Dialog bold 10");
|
||||
smallFontProps.setProperty("menuTextFont", "Dialog 10"); // bold
|
||||
smallFontProps.setProperty("windowTitleFont", "Dialog 10"); // bold
|
||||
smallFontProps.setProperty("subTextFont", "Dialog 8");
|
||||
|
||||
largeFontProps.setProperty("controlTextFont", "Dialog bold 14");
|
||||
largeFontProps.setProperty("systemTextFont", "Dialog bold 14");
|
||||
largeFontProps.setProperty("userTextFont", "Dialog bold 14");
|
||||
largeFontProps.setProperty("menuTextFont", "Dialog bold 14");
|
||||
largeFontProps.setProperty("windowTitleFont", "Dialog bold 14");
|
||||
largeFontProps.setProperty("controlTextFont", "Dialog 14"); // bold
|
||||
largeFontProps.setProperty("systemTextFont", "Dialog 14"); // bold
|
||||
largeFontProps.setProperty("userTextFont", "Dialog 14"); // bold
|
||||
largeFontProps.setProperty("menuTextFont", "Dialog 14"); // bold
|
||||
largeFontProps.setProperty("windowTitleFont", "Dialog 14"); // bold
|
||||
largeFontProps.setProperty("subTextFont", "Dialog 12");
|
||||
|
||||
giantFontProps.setProperty("controlTextFont", "Dialog 18");
|
||||
|
||||
@@ -14,6 +14,7 @@ public class AGC implements Effect {
|
||||
attack = a;
|
||||
decay = d;
|
||||
limit = l;
|
||||
gain = 1d;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -24,27 +25,36 @@ public class AGC implements Effect {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public double process(double sample) {
|
||||
double absSample = Math.abs(sample) * gain;
|
||||
public void process(double[][] samples) {
|
||||
gain = 1d;
|
||||
for (int i = 0; i < samples.length; i++) {
|
||||
double absSampleLeft = Math.abs(samples[i][Sentence.LEFT]) * gain;
|
||||
double absSampleRight = Math.abs(samples[i][Sentence.RIGHT]) * gain;
|
||||
|
||||
if (absSample > ceiling) {
|
||||
gain -= attack;
|
||||
if (gain < 0) gain = 0;
|
||||
double factor = 0.0d;
|
||||
|
||||
if (absSampleLeft > ceiling) {
|
||||
factor = -attack;
|
||||
}
|
||||
|
||||
if (absSample < ceiling) {
|
||||
gain += decay;
|
||||
if (gain > limit) {
|
||||
gain = limit;
|
||||
}
|
||||
if (absSampleRight > ceiling) {
|
||||
factor = -attack;
|
||||
}
|
||||
|
||||
sample *= gain;
|
||||
if ((absSampleLeft < ceiling) && (absSampleRight < ceiling)) {
|
||||
factor = decay;
|
||||
}
|
||||
|
||||
return sample;
|
||||
gain += factor;
|
||||
if (gain > limit) gain = limit;
|
||||
|
||||
samples[i][Sentence.LEFT] *= gain;
|
||||
samples[i][Sentence.RIGHT] *= gain;
|
||||
}
|
||||
}
|
||||
|
||||
public void init(double sr) {
|
||||
gain = 1d;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
|
||||
@@ -19,8 +19,11 @@ public class Amplifier implements Effect {
|
||||
return null;
|
||||
}
|
||||
|
||||
public double process(double sample) {
|
||||
return sample * gain;
|
||||
public void process(double[][] samples) {
|
||||
for (int i = 0; i < samples.length; i++) {
|
||||
samples[i][Sentence.LEFT] *= gain;
|
||||
samples[i][Sentence.RIGHT] *= gain;
|
||||
}
|
||||
}
|
||||
|
||||
public double getGain() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,8 @@ public class Biquad implements Effect {
|
||||
int type;
|
||||
double a0, a1, a2, b1, b2;
|
||||
double Fc, Q, peakGain;
|
||||
double z1, z2;
|
||||
double lz1, lz2;
|
||||
double rz1, rz2;
|
||||
double sampleFrequency;
|
||||
|
||||
public Biquad() {
|
||||
@@ -45,15 +46,19 @@ public class Biquad implements Effect {
|
||||
Fc = 440d;
|
||||
Q = 0.707d;
|
||||
peakGain = 0.0d;
|
||||
z1 = 0.0d;
|
||||
z2 = 0.0d;
|
||||
lz1 = 0.0d;
|
||||
lz2 = 0.0d;
|
||||
rz1 = 0.0d;
|
||||
rz2 = 0.0d;
|
||||
sampleFrequency = 44100d;
|
||||
}
|
||||
|
||||
public Biquad(int type, double Fc, double Q, double peakGainDB) {
|
||||
setBiquad(type, Fc, Q, peakGainDB);
|
||||
z1 = 0.0;
|
||||
z2 = 0.0;
|
||||
lz1 = 0.0;
|
||||
lz2 = 0.0;
|
||||
rz1 = 0.0;
|
||||
rz2 = 0.0;
|
||||
sampleFrequency = 44100d;
|
||||
}
|
||||
|
||||
@@ -84,17 +89,33 @@ public class Biquad implements Effect {
|
||||
setPeakGain(peakGainDB);
|
||||
}
|
||||
|
||||
public double process(double in) {
|
||||
double out = in * a0 + z1;
|
||||
z1 = in * a1 + z2 - b1 * out;
|
||||
z2 = in * a2 - b2 * out;
|
||||
return out;
|
||||
public void process(double[][] samples) {
|
||||
lz1 = 0d;
|
||||
lz2 = 0d;
|
||||
rz1 = 0d;
|
||||
rz2 = 0d;
|
||||
for (double[] in : samples) {
|
||||
double lout = in[Sentence.LEFT] * a0 + lz1;
|
||||
|
||||
lz1 = in[Sentence.LEFT] * a1 + lz2 - b1 * lout;
|
||||
lz2 = in[Sentence.LEFT] * a2 - b2 * lout;
|
||||
|
||||
double rout = in[Sentence.RIGHT] * a0 + rz1;
|
||||
|
||||
rz1 = in[Sentence.RIGHT] * a1 + rz2 - b1 * rout;
|
||||
rz2 = in[Sentence.RIGHT] * a2 - b2 * rout;
|
||||
|
||||
in[Sentence.LEFT] = lout;
|
||||
in[Sentence.RIGHT] = rout;
|
||||
}
|
||||
}
|
||||
|
||||
public void init(double sf) {
|
||||
sampleFrequency = sf;
|
||||
z1 = 0d;
|
||||
z2 = 0d;
|
||||
lz1 = 0d;
|
||||
lz2 = 0d;
|
||||
rz1 = 0d;
|
||||
rz2 = 0d;
|
||||
calcBiquad();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,14 @@ package uk.co.majenko.audiobookrecorder;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.border.*;
|
||||
|
||||
public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
|
||||
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
|
||||
JLabel ret = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
|
||||
ret.setIconTextGap(0);
|
||||
ret.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
if (value instanceof Sentence) {
|
||||
Sentence s = (Sentence)value;
|
||||
|
||||
@@ -31,8 +34,36 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
icn.add(Overlays.important, OverlayIcon.TOP_RIGHT);
|
||||
}
|
||||
|
||||
if (s.getEffectChain() != null) {
|
||||
if (!s.getEffectChain().equals("none")) {
|
||||
icn.add(Overlays.filter, OverlayIcon.BOTTOM_RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
ret.setIcon(icn);
|
||||
|
||||
String gaptype = s.getPostGapType();
|
||||
DefaultMutableTreeNode prev = s.getPreviousSibling();
|
||||
String prevtype = "sentence";
|
||||
if (prev instanceof Sentence) {
|
||||
Sentence s2 = (Sentence)prev;
|
||||
prevtype = s2.getPostGapType();
|
||||
}
|
||||
|
||||
if (prevtype.equals("continuation")) {
|
||||
ret.setIconTextGap(20);
|
||||
}
|
||||
|
||||
if (gaptype.equals("sentence")) {
|
||||
ret.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
} else if (gaptype.equals("continuation")) {
|
||||
ret.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
} else if (gaptype.equals("paragraph")) {
|
||||
ret.setBorder(new EmptyBorder(0, 0, 7, 0));
|
||||
} else if (gaptype.equals("section")) {
|
||||
ret.setBorder(new EmptyBorder(0, 0, 15, 0));
|
||||
}
|
||||
|
||||
} else if (value instanceof Chapter) {
|
||||
ret.setIcon(Icons.chapter);
|
||||
} else if (value instanceof Book) {
|
||||
|
||||
@@ -13,6 +13,9 @@ public class CacheManager {
|
||||
if (ob.lockedInCache()) {
|
||||
cache.add(ob);
|
||||
} else {
|
||||
if (ob instanceof Sentence) {
|
||||
Sentence s = (Sentence)ob;
|
||||
}
|
||||
ob.clearCache();
|
||||
}
|
||||
}
|
||||
@@ -23,4 +26,12 @@ public class CacheManager {
|
||||
public static void setCacheSize(int c) {
|
||||
cacheSize = c;
|
||||
}
|
||||
|
||||
public static void removeFromCache(Cacheable c) {
|
||||
if (c instanceof Sentence) {
|
||||
Sentence s = (Sentence)c;
|
||||
}
|
||||
cache.remove(c);
|
||||
c.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
58
src/uk/co/majenko/audiobookrecorder/Chain.java
Normal file
58
src/uk/co/majenko/audiobookrecorder/Chain.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Chain implements Effect {
|
||||
String target;
|
||||
|
||||
public Chain(String t) {
|
||||
target = t;
|
||||
}
|
||||
|
||||
public Chain() {
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void process(double[][] samples) {
|
||||
if (target != null) {
|
||||
Effect t = AudiobookRecorder.window.effects.get(target);
|
||||
if (t != null) {
|
||||
t.process(samples);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTarget(String t) {
|
||||
target = t;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Chain to " + target;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
System.out.println(toString());
|
||||
}
|
||||
|
||||
public void init(double sf) {
|
||||
if (target != null) {
|
||||
Effect t = AudiobookRecorder.window.effects.get(target);
|
||||
if (t != null) {
|
||||
t.init(sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Effect> getChildEffects() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class Chapter extends DefaultMutableTreeNode {
|
||||
|
||||
|
||||
AudioFormat sampleformat = AudiobookRecorder.window.roomNoise.getAudioFormat();
|
||||
AudioFormat format = new AudioFormat(sampleformat.getSampleRate(), 16, 1, true, false);
|
||||
AudioFormat format = new AudioFormat(sampleformat.getSampleRate(), 16, 2, true, false);
|
||||
byte[] data;
|
||||
|
||||
int fullLength = 0;
|
||||
@@ -232,5 +232,11 @@ public class Chapter extends DefaultMutableTreeNode {
|
||||
return out;
|
||||
}
|
||||
|
||||
public void resetPostGaps() {
|
||||
for (Enumeration s = children(); s.hasMoreElements();) {
|
||||
Sentence snt = (Sentence)s.nextElement();
|
||||
snt.resetPostGap();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
49
src/uk/co/majenko/audiobookrecorder/Clipping.java
Normal file
49
src/uk/co/majenko/audiobookrecorder/Clipping.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Clipping implements Effect {
|
||||
double clip;
|
||||
public Clipping() {
|
||||
clip = 1.0d;
|
||||
}
|
||||
public Clipping(double g) {
|
||||
clip = g;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "Clipping (" + clip + ")";
|
||||
}
|
||||
|
||||
public ArrayList<Effect> getChildEffects() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void process(double[][] samples) {
|
||||
for (double[] sample : samples) {
|
||||
if (sample[Sentence.LEFT] > clip) sample[Sentence.LEFT] = clip;
|
||||
if (sample[Sentence.LEFT] < -clip) sample[Sentence.LEFT] = -clip;
|
||||
if (sample[Sentence.RIGHT] > clip) sample[Sentence.RIGHT] = clip;
|
||||
if (sample[Sentence.RIGHT] < -clip) sample[Sentence.RIGHT] = -clip;
|
||||
}
|
||||
}
|
||||
|
||||
public double getClip() {
|
||||
return clip;
|
||||
}
|
||||
|
||||
public void setClip(double g) {
|
||||
clip = g;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
System.out.println(toString());
|
||||
}
|
||||
|
||||
public void init(double sf) {
|
||||
}
|
||||
}
|
||||
12
src/uk/co/majenko/audiobookrecorder/Debug.java
Normal file
12
src/uk/co/majenko/audiobookrecorder/Debug.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
public class Debug {
|
||||
static long timestamp;
|
||||
|
||||
static void debug(String msg) {
|
||||
long now = System.currentTimeMillis();
|
||||
long diff = now - timestamp;
|
||||
timestamp = now;
|
||||
System.err.println(String.format("%8d - %s", diff, msg));
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ public class DelayLine implements Effect {
|
||||
|
||||
ArrayList<DelayLineStore> delayLines;
|
||||
|
||||
boolean wetOnly = false;
|
||||
|
||||
public DelayLine() {
|
||||
delayLines = new ArrayList<DelayLineStore>();
|
||||
}
|
||||
@@ -14,23 +16,70 @@ public class DelayLine implements Effect {
|
||||
return "Delay Line (" + delayLines.size() + " lines)";
|
||||
}
|
||||
|
||||
public double process(double sample) {
|
||||
double s = sample;
|
||||
for (DelayLineStore d : delayLines) {
|
||||
double echo = d.pass(sample);
|
||||
s = mix(s, echo);
|
||||
public void process(double[][] samples) {
|
||||
double[][] savedSamples = new double[samples.length][2];
|
||||
for (int i = 0; i < samples.length; i++) {
|
||||
savedSamples[i][Sentence.LEFT] = samples[i][Sentence.LEFT];
|
||||
savedSamples[i][Sentence.RIGHT] = samples[i][Sentence.RIGHT];
|
||||
}
|
||||
if (wetOnly) {
|
||||
for (int i = 0; i < samples.length; i++) {
|
||||
samples[i][Sentence.LEFT] = 0d;
|
||||
samples[i][Sentence.RIGHT] = 0d;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
double mix(double a, double b) {
|
||||
if ((a < 0) && (b < 0)) {
|
||||
return (a + b) - (a * b);
|
||||
double[][] subSamples = new double[samples.length][2];
|
||||
for (int i = 0; i < samples.length; i++) {
|
||||
subSamples[i][Sentence.LEFT] = savedSamples[i][Sentence.LEFT];
|
||||
subSamples[i][Sentence.RIGHT] = savedSamples[i][Sentence.RIGHT];
|
||||
}
|
||||
if ((a > 0) && (b > 0)) {
|
||||
return (a + b) - (a * b);
|
||||
for (DelayLineStore d : delayLines) {
|
||||
for (int i = 0; i < samples.length; i++) {
|
||||
subSamples[i][Sentence.LEFT] = savedSamples[i][Sentence.LEFT];
|
||||
subSamples[i][Sentence.RIGHT] = savedSamples[i][Sentence.RIGHT];
|
||||
}
|
||||
return a + b;
|
||||
|
||||
d.process(subSamples);
|
||||
|
||||
for (int i = 0; i < subSamples.length; i++) {
|
||||
int off = i + d.getSamples();
|
||||
if ((off < samples.length) && (off > 0)) {
|
||||
|
||||
double[] ns = mix(samples[off], subSamples[i]);
|
||||
samples[off][Sentence.LEFT] = ns[Sentence.LEFT];
|
||||
samples[off][Sentence.RIGHT] = ns[Sentence.RIGHT];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double[] mix(double[] a, double[] b) {
|
||||
double[] out = new double[2];
|
||||
|
||||
if ((a[Sentence.LEFT] < 0) && (b[Sentence.LEFT] < 0)) {
|
||||
out[Sentence.LEFT] = (a[Sentence.LEFT] + b[Sentence.LEFT]) - (a[Sentence.LEFT] * b[Sentence.LEFT]);
|
||||
} else if ((a[Sentence.LEFT] > 0) && (b[Sentence.LEFT] > 0)) {
|
||||
out[Sentence.LEFT] = (a[Sentence.LEFT] + b[Sentence.LEFT]) - (a[Sentence.LEFT] * b[Sentence.LEFT]);
|
||||
} else {
|
||||
out[Sentence.LEFT] = a[Sentence.LEFT] + b[Sentence.LEFT];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public DelayLineStore addDelayLine(int samples, double gain, double pan) {
|
||||
DelayLineStore s = new DelayLineStore(samples, gain, pan);
|
||||
delayLines.add(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
public DelayLineStore addDelayLine(int samples, double gain) {
|
||||
@@ -60,5 +109,7 @@ public class DelayLine implements Effect {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setWetOnly(boolean b) {
|
||||
wetOnly = b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,42 +4,46 @@ import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DelayLineStore {
|
||||
ArrayBlockingQueue<Double> fifo;
|
||||
double gain;
|
||||
int numSamples;
|
||||
double pan;
|
||||
|
||||
ArrayList<Effect> effects;
|
||||
|
||||
public DelayLineStore(int s, double g) {
|
||||
fifo = new ArrayBlockingQueue<Double>(s);
|
||||
for (int i = 0; i < s; i++) {
|
||||
fifo.add(0d);
|
||||
}
|
||||
public DelayLineStore(int s, double g, double p) {
|
||||
numSamples = s;
|
||||
gain = g;
|
||||
pan = p;
|
||||
effects = new ArrayList<Effect>();
|
||||
}
|
||||
|
||||
public double pass(double s) {
|
||||
try {
|
||||
public DelayLineStore(int s, double g) {
|
||||
numSamples = s;
|
||||
gain = g;
|
||||
pan = 0d;
|
||||
effects = new ArrayList<Effect>();
|
||||
}
|
||||
|
||||
public void process(double[][] samples) {
|
||||
for (Effect e : effects) {
|
||||
s = e.process(s);
|
||||
e.process(samples);
|
||||
}
|
||||
|
||||
for (double[] sample : samples) {
|
||||
sample[Sentence.LEFT] *= gain;
|
||||
sample[Sentence.RIGHT] *= gain;
|
||||
|
||||
if (pan < 0) {
|
||||
double p = 1 + pan;
|
||||
sample[Sentence.RIGHT] *= p;
|
||||
} else {
|
||||
double p = 1 - pan;
|
||||
sample[Sentence.LEFT] *= p;
|
||||
}
|
||||
double v = s * gain;
|
||||
double t = fifo.poll();
|
||||
fifo.add(v);
|
||||
return t;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0d;
|
||||
}
|
||||
|
||||
public void setSamples(int s) {
|
||||
fifo = new ArrayBlockingQueue<Double>(s);
|
||||
for (int i = 0; i < s; i++) {
|
||||
fifo.add(0d);
|
||||
}
|
||||
numSamples = s;
|
||||
}
|
||||
|
||||
@@ -55,13 +59,6 @@ public class DelayLineStore {
|
||||
return gain;
|
||||
}
|
||||
|
||||
public void purge() {
|
||||
fifo.clear();
|
||||
for (int i = 0; i < numSamples; i++) {
|
||||
fifo.add(0d);
|
||||
}
|
||||
}
|
||||
|
||||
public void addEffect(Effect e) {
|
||||
effects.add(e);
|
||||
}
|
||||
@@ -70,7 +67,6 @@ public class DelayLineStore {
|
||||
for (Effect e : effects) {
|
||||
e.init(sf);
|
||||
}
|
||||
purge();
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
|
||||
@@ -3,7 +3,7 @@ package uk.co.majenko.audiobookrecorder;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface Effect {
|
||||
public double process(double sample);
|
||||
public void process(double[][] samples);
|
||||
public String getName();
|
||||
public ArrayList<Effect> getChildEffects();
|
||||
public void dump();
|
||||
|
||||
@@ -16,12 +16,10 @@ public class EffectGroup implements Effect {
|
||||
effects = new ArrayList<Effect>();
|
||||
}
|
||||
|
||||
public double process(double sample) {
|
||||
double out = sample;
|
||||
public void process(double[][] samples) {
|
||||
for (Effect e : effects) {
|
||||
out = e.process(out);
|
||||
e.process(samples);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public void setName(String n) {
|
||||
|
||||
@@ -27,6 +27,8 @@ public class FlashPanel extends JPanel {
|
||||
public void setFlash(boolean f) {
|
||||
flash = f;
|
||||
|
||||
col = true;
|
||||
|
||||
for (Component o : getComponents()) {
|
||||
((JComponent)o).setVisible(!f);
|
||||
}
|
||||
@@ -42,7 +44,7 @@ public class FlashPanel extends JPanel {
|
||||
if (col) {
|
||||
g.setColor(Color.RED);
|
||||
} else {
|
||||
g.setColor(Color.BLACK);
|
||||
g.setColor(Color.GREEN);
|
||||
}
|
||||
Dimension d = getSize();
|
||||
g.fillRect(0, 0, d.width, d.height);
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Timer;
|
||||
|
||||
public class HavenQueue extends JPanel {
|
||||
ConcurrentLinkedQueue<Sentence> sentenceList = new ConcurrentLinkedQueue<Sentence>();
|
||||
|
||||
Timer timer = new Timer();
|
||||
|
||||
Sentence currentSentence = null;
|
||||
|
||||
JLabel count;
|
||||
|
||||
public HavenQueue() {
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
|
||||
count = new JLabel("Haven queue: 0");
|
||||
setLayout(new BorderLayout());
|
||||
add(count, BorderLayout.CENTER);
|
||||
|
||||
count.setOpaque(false);
|
||||
setOpaque(false);
|
||||
count.setForeground(Color.WHITE);
|
||||
}
|
||||
|
||||
public void processQueue() {
|
||||
|
||||
count.setText("Haven queue: " + sentenceList.size());
|
||||
|
||||
if (currentSentence == null) {
|
||||
// Grab a new sentence to process.
|
||||
currentSentence = sentenceList.poll();
|
||||
|
||||
if (currentSentence != null) {
|
||||
if (!currentSentence.postHavenData()) { // Failed. Add to the end of the queue and wait a bit
|
||||
submit(currentSentence);
|
||||
currentSentence = null;
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
|
||||
return;
|
||||
}
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentSentence != null) {
|
||||
currentSentence.processPendingHaven();
|
||||
int status = currentSentence.getHavenStatus();
|
||||
switch (status) {
|
||||
case 0: // Um... not running...?
|
||||
currentSentence = null;
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
|
||||
return;
|
||||
case 1: // Still processing...
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 5000);
|
||||
return;
|
||||
case 2: // Finished
|
||||
currentSentence = null;
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
|
||||
return;
|
||||
case 3: // Failed
|
||||
currentSentence = null;
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
|
||||
}
|
||||
|
||||
public void submit(Sentence s) {
|
||||
s.setOverrideText("[queued...]");
|
||||
AudiobookRecorder.window.bookTreeModel.reload(s);
|
||||
sentenceList.add(s);
|
||||
count.setText("Haven queue: " + sentenceList.size());
|
||||
}
|
||||
}
|
||||
@@ -33,4 +33,9 @@ public class Icons {
|
||||
static public final ImageIcon dollar = new ImageIcon(Icons.class.getResource("icons/dollar.png"));
|
||||
static public final ImageIcon attention = new ImageIcon(Icons.class.getResource("icons/attention.png"));
|
||||
static public final ImageIcon normalize = new ImageIcon(Icons.class.getResource("icons/normalize.png"));
|
||||
static public final ImageIcon split = new ImageIcon(Icons.class.getResource("icons/split.png"));
|
||||
static public final ImageIcon cut = new ImageIcon(Icons.class.getResource("icons/cut.png"));
|
||||
static public final ImageIcon docut = new ImageIcon(Icons.class.getResource("icons/do-cut.png"));
|
||||
static public final ImageIcon playto = new ImageIcon(Icons.class.getResource("icons/play-to.png"));
|
||||
static public final ImageIcon disable = new ImageIcon(Icons.class.getResource("icons/disable-effects.png"));
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ public class LFO implements Effect {
|
||||
phase = p;
|
||||
}
|
||||
|
||||
public double process(double sample) {
|
||||
public void process(double[][] samples) {
|
||||
for (double[] sample : samples) {
|
||||
double v = Math.sin(phase);
|
||||
phase += sampleStep;
|
||||
if (phase > (Math.PI * 2d)) {
|
||||
@@ -37,9 +38,9 @@ public class LFO implements Effect {
|
||||
v *= depth;
|
||||
|
||||
// Apply it to the sample
|
||||
sample += (sample * v);
|
||||
|
||||
return sample;
|
||||
sample[Sentence.LEFT] += (sample[Sentence.LEFT] * v);
|
||||
sample[Sentence.RIGHT] += (sample[Sentence.RIGHT] * v);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() { return "Low Frequency Oscillator (" + frequency + " Hz, " + (depth * 100d) + "%)"; }
|
||||
|
||||
@@ -14,9 +14,12 @@ public class MainToolBar extends JToolBar {
|
||||
JButtonSpacePlay recordRoomNoise;
|
||||
JButtonSpacePlay playSentence;
|
||||
JButtonSpacePlay playonSentence;
|
||||
JButtonSpacePlay playtoSentence;
|
||||
JButtonSpacePlay stopPlaying;
|
||||
JButtonSpacePlay eq;
|
||||
JToggleButton mic;
|
||||
JToggleButtonSpacePlay mic;
|
||||
|
||||
JToggleButtonSpacePlay disableEffects;
|
||||
|
||||
AudiobookRecorder root;
|
||||
|
||||
@@ -78,6 +81,14 @@ public class MainToolBar extends JToolBar {
|
||||
});
|
||||
add(playonSentence);
|
||||
|
||||
playtoSentence = new JButtonSpacePlay(Icons.playto, "Play sentence to cut", new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
root.playToSelectedSentence();
|
||||
}
|
||||
});
|
||||
add(playtoSentence);
|
||||
playtoSentence.setEnabled(false);
|
||||
|
||||
stopPlaying = new JButtonSpacePlay(Icons.stop, "Stop playing", new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
root.stopPlaying();
|
||||
@@ -120,8 +131,34 @@ public class MainToolBar extends JToolBar {
|
||||
|
||||
add(mic);
|
||||
|
||||
addSeparator();
|
||||
|
||||
disableEffects = new JToggleButtonSpacePlay(Icons.disable, "Disable effects", new ActionListener() {
|
||||
Color bgCol = null;
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JToggleButton b = (JToggleButton)e.getSource();
|
||||
if (b.isSelected()) {
|
||||
root.setEffectsEnabled(false);
|
||||
bgCol = b.getBackground();
|
||||
b.setBackground(Color.RED);
|
||||
} else {
|
||||
root.setEffectsEnabled(true);
|
||||
if (bgCol != null) {
|
||||
b.setBackground(bgCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add(disableEffects);
|
||||
|
||||
|
||||
|
||||
setFloatable(false);
|
||||
}
|
||||
|
||||
public void enablePlayTo(boolean b) {
|
||||
playtoSentence.setEnabled(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,8 +44,6 @@ public class Options extends JDialog {
|
||||
JSpinner etherealAttenuation;
|
||||
JSpinner etherealOffset;
|
||||
|
||||
JTextField havenApiKey;
|
||||
|
||||
JTextField externalEditor;
|
||||
|
||||
JTextArea startupScript;
|
||||
@@ -325,8 +323,7 @@ public class Options extends JDialog {
|
||||
|
||||
addSeparator(optionsPanel);
|
||||
|
||||
enableParsing = addCheckBox(optionsPanel, "Enable automatic speech-to-text submission", getBoolean("process.haven.auto"));
|
||||
havenApiKey = addTextField(optionsPanel, "Haven OnDemand API Key", get("process.haven.apikey"));
|
||||
enableParsing = addCheckBox(optionsPanel, "Enable automatic sphinx speech-to-text (**SLOW**)", getBoolean("process.sphinx"));
|
||||
|
||||
addSeparator(optionsPanel);
|
||||
|
||||
@@ -334,7 +331,7 @@ public class Options extends JDialog {
|
||||
|
||||
addSeparator(optionsPanel);
|
||||
|
||||
cacheSize = addSpinner(optionsPanel, "Cache size:", 0, 5000, 1, getInteger("cache.size"), "");
|
||||
cacheSize = addSpinner(optionsPanel, "Cache size:", 2, 100, 1, getInteger("cache.size"), "");
|
||||
|
||||
addSeparator(optionsPanel);
|
||||
tabs.add("Options", new JScrollPane(optionsPanel));
|
||||
@@ -584,9 +581,7 @@ public class Options extends JDialog {
|
||||
|
||||
defaultPrefs.put("audio.export.bitrate", "256000");
|
||||
defaultPrefs.put("audio.export.samplerate", "44100");
|
||||
|
||||
defaultPrefs.put("process.sphinx", "false");
|
||||
defaultPrefs.put("process.haven.apikey", "");
|
||||
|
||||
defaultPrefs.put("editor.external", "");
|
||||
|
||||
@@ -710,7 +705,6 @@ public class Options extends JDialog {
|
||||
set("audio.export.bitrate", ((KVPair)bitRate.getSelectedItem()).key);
|
||||
set("audio.export.samplerate", ((KVPair)exportRate.getSelectedItem()).key);
|
||||
set("process.sphinx", enableParsing.isSelected());
|
||||
set("process.haven.apikey", havenApiKey.getText());
|
||||
set("editor.external", externalEditor.getText());
|
||||
set("cache.size", cacheSize.getValue());
|
||||
set("audio.recording.trim.fft", fftThreshold.getValue());
|
||||
@@ -781,9 +775,10 @@ public class Options extends JDialog {
|
||||
}
|
||||
|
||||
public static KVPair[] getTrimMethods() {
|
||||
KVPair[] pairs = new KVPair[2];
|
||||
pairs[0] = new KVPair<String, String>("peak", "Peak Amplitude");
|
||||
pairs[1] = new KVPair<String, String>("fft", "FFT Analysis");
|
||||
KVPair[] pairs = new KVPair[3];
|
||||
pairs[0] = new KVPair<String, String>("none", "None");
|
||||
pairs[1] = new KVPair<String, String>("peak", "Peak Amplitude");
|
||||
pairs[2] = new KVPair<String, String>("fft", "FFT Analysis");
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
||||
52
src/uk/co/majenko/audiobookrecorder/Pan.java
Normal file
52
src/uk/co/majenko/audiobookrecorder/Pan.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Pan implements Effect {
|
||||
double pan;
|
||||
public Pan() {
|
||||
pan = 0.0d;
|
||||
}
|
||||
public Pan(double p) {
|
||||
pan = p;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "Pan (" + pan + ")";
|
||||
}
|
||||
|
||||
public ArrayList<Effect> getChildEffects() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void process(double[][] samples) {
|
||||
for (double[] sample : samples) {
|
||||
if (pan < 0) {
|
||||
double p = 1 + pan;
|
||||
sample[Sentence.RIGHT] *= p;
|
||||
} else {
|
||||
double p = 1 - pan;
|
||||
sample[Sentence.LEFT] *= p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getPan() {
|
||||
return pan;
|
||||
}
|
||||
|
||||
public void setPan(double p) {
|
||||
pan = p;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
System.out.println(toString());
|
||||
}
|
||||
|
||||
public void init(double sf) {
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package uk.co.majenko.audiobookrecorder;
|
||||
|
||||
public class Sample {
|
||||
double left;
|
||||
double right;
|
||||
|
||||
public Sample(double m) {
|
||||
left = m;
|
||||
right = m;
|
||||
}
|
||||
|
||||
public Sample(double l, double r) {
|
||||
left = l;
|
||||
right = r;
|
||||
}
|
||||
|
||||
public double getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public double getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public double getMono() {
|
||||
return (left + right) / 2.0;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -63,4 +63,17 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static long millis = System.currentTimeMillis();
|
||||
|
||||
public static void report(String tag) {
|
||||
long t = System.currentTimeMillis();
|
||||
long d = t - millis;
|
||||
millis = t;
|
||||
System.err.println(String.format("%10d - %10s : %8d | %8d | %8d", d, tag,
|
||||
Runtime.getRuntime().totalMemory(),
|
||||
Runtime.getRuntime().maxMemory(),
|
||||
Runtime.getRuntime().freeMemory()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import javax.sound.sampled.*;
|
||||
|
||||
public class Waveform extends JPanel implements MouseListener, MouseMotionListener {
|
||||
|
||||
double[] samples = null;
|
||||
double[][] samples = null;
|
||||
|
||||
int leftMarker = 0;
|
||||
int rightMarker = 0;
|
||||
@@ -21,6 +21,11 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
int leftAltMarker = 0;
|
||||
int rightAltMarker = 0;
|
||||
|
||||
int cutEntry = 0;
|
||||
int cutExit = 0;
|
||||
boolean displayCut = false;
|
||||
boolean displaySplit = false;
|
||||
|
||||
int dragging = 0;
|
||||
|
||||
int step = 1;
|
||||
@@ -92,7 +97,7 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
double lmax = 0;
|
||||
|
||||
for (int o = 0; o < step; o++) {
|
||||
double sample = samples[offset + (n * step) + o];
|
||||
double sample = (samples[offset + (n * step) + o][Sentence.LEFT] + samples[offset + (n * step) + o][Sentence.RIGHT]) / 2d;
|
||||
if (sample >= 0) {
|
||||
have += sample;
|
||||
hcnt++;
|
||||
@@ -133,7 +138,7 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
g.drawLine(n, (int)(h/2 + lave), n, (int)(h/2 - have));
|
||||
}
|
||||
|
||||
g.setColor(new Color(255, 0, 0, 32));
|
||||
g.setColor(new Color(255, 0, 0, 64));
|
||||
g.fillRect(0, 0, (leftAltMarker - offset)/step, h);
|
||||
g.fillRect((rightAltMarker - offset)/step, 0, (num - rightAltMarker) / step , h);
|
||||
|
||||
@@ -145,6 +150,19 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
g.drawLine((leftMarker - offset)/step, 0, (leftMarker - offset)/step, h);
|
||||
g.drawLine((rightMarker - offset)/step, 0, (rightMarker - offset)/step, h);
|
||||
|
||||
if (displayCut || displaySplit) {
|
||||
g.setColor(new Color(0, 255, 255));
|
||||
g.drawLine((cutEntry - offset)/step, 0, (cutEntry - offset)/step, h);
|
||||
}
|
||||
|
||||
if (displayCut) {
|
||||
g.setColor(new Color(0, 255, 255));
|
||||
g.drawLine((cutExit - offset)/step, 0, (cutExit - offset)/step, h);
|
||||
|
||||
g.setColor(new Color(0, 255, 255, 80));
|
||||
g.fillRect((cutEntry - offset)/step, 0, ((cutExit - offset) - (cutEntry - offset))/step , h);
|
||||
}
|
||||
|
||||
g.setColor(new Color(0, 255, 255));
|
||||
for (int i = 0; i < h; i += 2) {
|
||||
g.drawLine((playMarker - offset) / step, i, (playMarker - offset) / step, i);
|
||||
@@ -189,9 +207,11 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setData(double[] s) {
|
||||
public void setData(double[][] s) {
|
||||
samples = s;
|
||||
playMarker = 0;
|
||||
displayCut = false;
|
||||
displaySplit = false;
|
||||
repaint();
|
||||
}
|
||||
|
||||
@@ -221,6 +241,19 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
dragging = 2;
|
||||
return;
|
||||
}
|
||||
if (displayCut || displaySplit) {
|
||||
if ((x >= ((cutEntry - offset)/step) - 10) && (x <= ((cutEntry - offset)/step) + 10)) {
|
||||
dragging = 3;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (displayCut) {
|
||||
if ((x >= ((cutExit - offset)/step) - 10) && (x <= ((cutExit - offset)/step) + 10)) {
|
||||
dragging = 4;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
@@ -251,6 +284,19 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
|
||||
return;
|
||||
}
|
||||
if (displayCut || displaySplit) {
|
||||
if ((x >= ((cutEntry - offset)/step) - 10) && (x <= ((cutEntry - offset)/step) + 10)) {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayCut) {
|
||||
if ((x >= ((cutExit - offset)/step) - 10) && (x <= ((cutExit - offset)/step) + 10)) {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
|
||||
@@ -270,6 +316,18 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
if (rightMarker < leftMarker) {
|
||||
rightMarker = leftMarker;
|
||||
}
|
||||
} else if (dragging == 3) {
|
||||
cutEntry = (x * step) + offset;
|
||||
if (displayCut) {
|
||||
if (cutEntry > cutExit) {
|
||||
cutEntry = cutExit;
|
||||
}
|
||||
}
|
||||
} else if (dragging == 4) {
|
||||
cutExit = (x * step) + offset;
|
||||
if (cutExit < cutEntry) {
|
||||
cutExit = cutEntry;
|
||||
}
|
||||
}
|
||||
|
||||
repaint();
|
||||
@@ -299,4 +357,33 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
||||
playMarker = leftAltMarker + m;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setDisplayCut(boolean c) {
|
||||
displayCut = c;
|
||||
displaySplit = false;
|
||||
if (displayCut) {
|
||||
int d = rightMarker - leftMarker;
|
||||
cutEntry = leftMarker + (d / 3);
|
||||
cutExit = leftMarker + (d / 3 * 2);
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void setDisplaySplit(boolean c) {
|
||||
displayCut = false;
|
||||
displaySplit = c;
|
||||
if (displaySplit) {
|
||||
int d = rightMarker - leftMarker;
|
||||
cutEntry = leftMarker + (d / 2);
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public int getCutStart() {
|
||||
return cutEntry;
|
||||
}
|
||||
|
||||
public int getCutEnd() {
|
||||
return cutExit;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user