Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fde4a597c7 | |||
| e69ae52f50 | |||
| 8bdb06749f | |||
| 0cfd066f4f | |||
| 217ccb915a | |||
| 1dd3e9d86f | |||
| d3d81d71fe | |||
| 80c110afa9 | |||
| 1c08b9a51d | |||
| 4ad30106b6 | |||
| 9100d0e35a | |||
| b8dea19c30 | |||
| 671f2b9270 | |||
| d619fb2f4d |
@@ -1,7 +1,4 @@
|
|||||||
<effect name="Alien">
|
<effect name="Alien">
|
||||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
<!--biquad type="lowpass" fc="10000" q="1" gain="-10" /-->
|
||||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
<lfo frequency="50" depth="1.0" waveform="triangle" mode="replace"/>
|
||||||
<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>
|
</effect>
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
<effect name="Big Echo">
|
<effect name="Big Echo">
|
||||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
|
||||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
|
||||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
|
||||||
<delayline>
|
<delayline>
|
||||||
<delay samples="22000" gain="0.2" pan="-0.3">
|
<delay samples="22000" gain="0.2" pan="-0.3">
|
||||||
<biquad type="highpass" fc="300" q="1" gain="0" />
|
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||||
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||||
<agc ceiling="0.666" limit="1" attack="0.1" decay="0.01" />
|
<agc ceiling="0.666" limit="1.5" attack="0.08" decay="0.01" />
|
||||||
</effect>
|
</effect>
|
||||||
|
|||||||
15
ExampleFilters/cuthumagcstereo.eff
Normal file
15
ExampleFilters/cuthumagcstereo.eff
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<effect name="Cut Computer Hum (with AGC and Stereo)">
|
||||||
|
<biquad type="notch" fc="28" q="20" gain="-50" />
|
||||||
|
<biquad type="notch" fc="91" q="20" gain="-50" />
|
||||||
|
<biquad type="notch" fc="120" q="20" gain="-50" />
|
||||||
|
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||||
|
<delayline wetonly="false">
|
||||||
|
<delay samples="-100" gain="0.1" pan="-1.0">
|
||||||
|
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||||
|
</delay>
|
||||||
|
<delay samples="100" gain="0.1" pan="1.0">
|
||||||
|
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||||
|
</delay>
|
||||||
|
</delayline>
|
||||||
|
<agc ceiling="0.666" limit="1.5" attack="0.1" decay="0.01" />
|
||||||
|
</effect>
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
<effect name="Ethereal Voice">
|
<effect name="Ethereal Voice">
|
||||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
|
||||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
|
||||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
|
||||||
<amplifier gain="0.1" />
|
<amplifier gain="0.1" />
|
||||||
<delayline>
|
<delayline>
|
||||||
<delay samples="2000" gain="1.0" pan="-0.3">
|
<delay samples="2000" gain="1.0" pan="-0.3">
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
<effect name="Large Room (quiet)">
|
<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" />
|
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||||
<delayline>
|
<delayline>
|
||||||
<delay samples="5500" gain="0.2" pan="-0.3">
|
<delay samples="5500" gain="0.2" pan="-0.3">
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
<effect name="Large Room (loud)">
|
<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" />
|
<biquad type="lowpass" fc="10000" q="1" gain="-10" />
|
||||||
<delayline>
|
<delayline>
|
||||||
<delay samples="5500" gain="0.2" pan="-0.3">
|
<delay samples="5500" gain="0.2" pan="-0.3">
|
||||||
|
|||||||
3
ExampleFilters/panleft.eff
Normal file
3
ExampleFilters/panleft.eff
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<effect name="Pan Left">
|
||||||
|
<pan pan="-0.4" />
|
||||||
|
</effect>
|
||||||
3
ExampleFilters/panright.eff
Normal file
3
ExampleFilters/panright.eff
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<effect name="Pan Right">
|
||||||
|
<pan pan="0.4" />
|
||||||
|
</effect>
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
<effect name="Telephone">
|
<effect name="Telephone">
|
||||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
|
||||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
|
||||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
|
||||||
<biquad type="lowshelf" fc="400" q="10" gain="-20" />
|
<biquad type="lowshelf" fc="400" q="10" gain="-20" />
|
||||||
<biquad type="highshelf" fc="8000" q="10" gain="-20" />
|
<biquad type="highshelf" fc="8000" q="10" gain="-20" />
|
||||||
<delayline>
|
<delayline>
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
<effect name="Radio">
|
<effect name="Radio">
|
||||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
<amplifier gain="0.5" />
|
||||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
<biquad type="peak" fc="1000" q="10" gain="25" />
|
||||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
<lfo frequency="3000" depth="0.3" waveform="sine" mode="add" />
|
||||||
<amplifier gain="0.1" />
|
<clipping clip="0.9" />
|
||||||
<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" />
|
<biquad type="highshelf" fc="8000" q="1" gain="-20" />
|
||||||
<delayline>
|
<delayline>
|
||||||
<delay samples="100" gain="0.7" />
|
<delay samples="100" gain="0.7" />
|
||||||
<delay samples="200" gain="0.5" />
|
<delay samples="200" gain="0.5" />
|
||||||
</delayline>
|
</delayline>
|
||||||
|
<amplifier gain="0.3" />
|
||||||
</effect>
|
</effect>
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
<effect name="Robotic">
|
<effect name="Robotic">
|
||||||
<biquad type="notch" fc="28" q="20" gain="-50" />
|
|
||||||
<biquad type="notch" fc="91" q="20" gain="-50" />
|
|
||||||
<biquad type="notch" fc="120" q="20" gain="-50" />
|
|
||||||
<biquad type="lowshelf" fc="100" q="2" gain="-20" />
|
<biquad type="lowshelf" fc="100" q="2" gain="-20" />
|
||||||
<delayline>
|
<delayline>
|
||||||
<delay samples="400" gain="1" pan="-0.3" />
|
<delay samples="400" gain="1" pan="-0.3" />
|
||||||
|
|||||||
10
ExampleFilters/stereochorus.eff
Normal file
10
ExampleFilters/stereochorus.eff
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<effect name="Stereo Chorus">
|
||||||
|
<delayline>
|
||||||
|
<delay samples="2000" gain="0.1" pan="-0.3">
|
||||||
|
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||||
|
</delay>
|
||||||
|
<delay samples="4000" gain="0.1" pan="0.3">
|
||||||
|
<biquad type="highpass" fc="300" q="1" gain="0" />
|
||||||
|
</delay>
|
||||||
|
</delayline>
|
||||||
|
</effect>
|
||||||
@@ -1 +1 @@
|
|||||||
version=0.2.0
|
version=0.2.2
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class AGC implements Effect {
|
|||||||
|
|
||||||
gain += factor;
|
gain += factor;
|
||||||
if (gain > limit) gain = limit;
|
if (gain > limit) gain = limit;
|
||||||
|
if (gain < 0) gain = 0;
|
||||||
|
|
||||||
samples[i][Sentence.LEFT] *= gain;
|
samples[i][Sentence.LEFT] *= gain;
|
||||||
samples[i][Sentence.RIGHT] *= gain;
|
samples[i][Sentence.RIGHT] *= gain;
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
// Settings - tweakable
|
// Settings - tweakable
|
||||||
|
|
||||||
public static final int PLAYBACK_CHUNK_SIZE = 1024;
|
|
||||||
|
|
||||||
public static final String SPHINX_MODEL = "resource:/edu/cmu/sphinx/models/en-us/en-us";
|
public static final String SPHINX_MODEL = "resource:/edu/cmu/sphinx/models/en-us/en-us";
|
||||||
|
|
||||||
static Properties config = new Properties();
|
static Properties config = new Properties();
|
||||||
@@ -60,6 +58,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
JMenuItem bookNewChapter;
|
JMenuItem bookNewChapter;
|
||||||
JMenuItem bookExportAudio;
|
JMenuItem bookExportAudio;
|
||||||
|
JMenuItem bookPurgeBackups;
|
||||||
JMenu bookVisitACX;
|
JMenu bookVisitACX;
|
||||||
JMenuItem bookVisitTitle;
|
JMenuItem bookVisitTitle;
|
||||||
JMenuItem bookVisitAudition;
|
JMenuItem bookVisitAudition;
|
||||||
@@ -214,8 +213,16 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bookPurgeBackups = new JMenuItem("Purge Backups");
|
||||||
|
bookPurgeBackups.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
book.purgeBackups();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
bookMenu.add(bookNewChapter);
|
bookMenu.add(bookNewChapter);
|
||||||
bookMenu.add(bookExportAudio);
|
bookMenu.add(bookExportAudio);
|
||||||
|
bookMenu.add(bookPurgeBackups);
|
||||||
|
|
||||||
bookVisitACX = new JMenu("Visit ACX");
|
bookVisitACX = new JMenu("Visit ACX");
|
||||||
bookMenu.add(bookVisitACX);
|
bookMenu.add(bookVisitACX);
|
||||||
@@ -1454,6 +1461,8 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
if (!(book.getName().equals(tit))) {
|
if (!(book.getName().equals(tit))) {
|
||||||
book.renameBook(tit);
|
book.renameBook(tit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CacheManager.purgeCache();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(editData);
|
menu.add(editData);
|
||||||
@@ -1814,16 +1823,10 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (Enumeration s = c.children(); s.hasMoreElements();) {
|
for (Enumeration s = c.children(); s.hasMoreElements();) {
|
||||||
Sentence snt = (Sentence)s.nextElement();
|
Sentence snt = (Sentence)s.nextElement();
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.id", keybase, i), snt.getId());
|
TreeMap<String, String> settings = snt.getSentenceData();
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.text", keybase, i), snt.getText());
|
for (String key : settings.keySet()) {
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.post-gap", keybase, i), Integer.toString(snt.getPostGap()));
|
prefs.setProperty(String.format("%s.sentence.%08d.%s", keybase, i, key), settings.get(key));
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.start-offset", keybase, i), Integer.toString(snt.getStartOffset()));
|
}
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.end-offset", keybase, i), Integer.toString(snt.getEndOffset()));
|
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.locked", keybase, i), snt.isLocked() ? "true" : "false");
|
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.attention", keybase, i), snt.getAttentionFlag() ? "true" : "false");
|
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.gain", keybase, i), String.format("%.8f", snt.getGain()));
|
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.effect", keybase, i), snt.getEffectChain());
|
|
||||||
prefs.setProperty(String.format("%s.sentence.%08d.gaptype", keybase, i), snt.getPostGapType());
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2182,8 +2185,12 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
int blockSize = Options.getInteger("audio.playback.blocksize");
|
||||||
|
|
||||||
AudioFormat sampleformat = s.getAudioFormat();
|
AudioFormat sampleformat = s.getAudioFormat();
|
||||||
AudioFormat format = new AudioFormat(sampleformat.getSampleRate(), 16, 2, true, false);
|
float sampleRate = sampleformat.getSampleRate();
|
||||||
|
// sampleRate *= toolBar.getPlaybackSpeed();
|
||||||
|
AudioFormat format = new AudioFormat(sampleRate, 16, 2, true, false);
|
||||||
|
|
||||||
play = AudioSystem.getSourceDataLine(format, Options.getPlaybackMixer());
|
play = AudioSystem.getSourceDataLine(format, Options.getPlaybackMixer());
|
||||||
play.open(format);
|
play.open(format);
|
||||||
@@ -2192,10 +2199,10 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
bookTree.scrollPathToVisible(new TreePath(s.getPath()));
|
bookTree.scrollPathToVisible(new TreePath(s.getPath()));
|
||||||
data = s.getPCMData(effectsEnabled);
|
data = s.getPCMData(effectsEnabled);
|
||||||
for (int pos = 0; pos < data.length; pos += PLAYBACK_CHUNK_SIZE) {
|
for (int pos = 0; pos < data.length; pos += blockSize) {
|
||||||
sampleWaveform.setPlayMarker(pos / format.getFrameSize());
|
sampleWaveform.setPlayMarker(pos / format.getFrameSize());
|
||||||
int l = data.length - pos;
|
int l = data.length - pos;
|
||||||
if (l > PLAYBACK_CHUNK_SIZE) l = PLAYBACK_CHUNK_SIZE;
|
if (l > blockSize) l = blockSize;
|
||||||
play.write(data, pos, l);
|
play.write(data, pos, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2344,6 +2351,8 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
int blockSize = Options.getInteger("audio.playback.blocksize");
|
||||||
|
|
||||||
AudioFormat sampleformat = s.getAudioFormat();
|
AudioFormat sampleformat = s.getAudioFormat();
|
||||||
AudioFormat format = new AudioFormat(sampleformat.getSampleRate(), 16, 2, true, false);
|
AudioFormat format = new AudioFormat(sampleformat.getSampleRate(), 16, 2, true, false);
|
||||||
|
|
||||||
@@ -2375,10 +2384,10 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
if (startPos > data.length) startPos = data.length;
|
if (startPos > data.length) startPos = data.length;
|
||||||
if (endPos > data.length) endPos = data.length;
|
if (endPos > data.length) endPos = data.length;
|
||||||
|
|
||||||
for (int pos = startPos; pos < endPos; pos += PLAYBACK_CHUNK_SIZE) {
|
for (int pos = startPos; pos < endPos; pos += blockSize) {
|
||||||
sampleWaveform.setPlayMarker(pos / format.getFrameSize());
|
sampleWaveform.setPlayMarker(pos / format.getFrameSize());
|
||||||
int l = data.length - pos;
|
int l = data.length - pos;
|
||||||
if (l > PLAYBACK_CHUNK_SIZE) l = PLAYBACK_CHUNK_SIZE;
|
if (l > blockSize) l = blockSize;
|
||||||
play.write(data, pos, l);
|
play.write(data, pos, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2420,8 +2429,12 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
int blockSize = Options.getInteger("audio.playback.blocksize");
|
||||||
|
|
||||||
AudioFormat sampleformat = s.getAudioFormat();
|
AudioFormat sampleformat = s.getAudioFormat();
|
||||||
AudioFormat format = new AudioFormat(sampleformat.getSampleRate(), 16, 2, true, false);
|
float sampleRate = sampleformat.getSampleRate();
|
||||||
|
sampleRate *= toolBar.getPlaybackSpeed();
|
||||||
|
AudioFormat format = new AudioFormat(sampleRate, 16, 2, true, false);
|
||||||
play = AudioSystem.getSourceDataLine(format, Options.getPlaybackMixer());
|
play = AudioSystem.getSourceDataLine(format, Options.getPlaybackMixer());
|
||||||
play.open(format);
|
play.open(format);
|
||||||
play.start();
|
play.start();
|
||||||
@@ -2451,10 +2464,10 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
for (int pos = 0; pos < data.length; pos += PLAYBACK_CHUNK_SIZE) {
|
for (int pos = 0; pos < data.length; pos += blockSize) {
|
||||||
sampleWaveform.setPlayMarker(pos / format.getFrameSize());
|
sampleWaveform.setPlayMarker(pos / format.getFrameSize());
|
||||||
int l = data.length - pos;
|
int l = data.length - pos;
|
||||||
if (l > PLAYBACK_CHUNK_SIZE) l = PLAYBACK_CHUNK_SIZE;
|
if (l > blockSize) l = blockSize;
|
||||||
play.write(data, pos, l);
|
play.write(data, pos, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2470,12 +2483,6 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
play.write(data, 0, data.length);
|
play.write(data, 0, data.length);
|
||||||
playing = null;
|
playing = null;
|
||||||
} else {
|
} else {
|
||||||
play.drain();
|
|
||||||
play.stop();
|
|
||||||
play.close();
|
|
||||||
play.open(format);
|
|
||||||
play.start();
|
|
||||||
play.drain();
|
|
||||||
data = getRoomNoise(s.getPostGap());
|
data = getRoomNoise(s.getPostGap());
|
||||||
play.write(data, 0, data.length);
|
play.write(data, 0, data.length);
|
||||||
}
|
}
|
||||||
@@ -3220,7 +3227,40 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
double f = Utils.s2d(root.getAttribute("frequency"));
|
double f = Utils.s2d(root.getAttribute("frequency"));
|
||||||
double d = Utils.s2d(root.getAttribute("depth"));
|
double d = Utils.s2d(root.getAttribute("depth"));
|
||||||
double p = Utils.s2d(root.getAttribute("phase"));
|
double p = Utils.s2d(root.getAttribute("phase"));
|
||||||
return new LFO(f, d, p);
|
double dty = Math.PI;
|
||||||
|
String waveform = root.getAttribute("waveform");
|
||||||
|
if (waveform == null) {
|
||||||
|
waveform = "sine";
|
||||||
|
}
|
||||||
|
|
||||||
|
int w = LFO.SINE;
|
||||||
|
|
||||||
|
switch (waveform.toLowerCase()) {
|
||||||
|
case "sine": w = LFO.SINE; break;
|
||||||
|
case "cosine": w = LFO.COSINE; break;
|
||||||
|
case "square": w = LFO.SQUARE; break;
|
||||||
|
case "triangle": w = LFO.TRIANGLE; break;
|
||||||
|
case "sawtooth": w = LFO.SAWTOOTH; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int m = LFO.ADD;
|
||||||
|
|
||||||
|
String mode = root.getAttribute("mode");
|
||||||
|
|
||||||
|
if (mode == null) {
|
||||||
|
mode = "add";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (mode.toLowerCase()) {
|
||||||
|
case "add": m = LFO.ADD; break;
|
||||||
|
case "replace": m = LFO.REPLACE; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.getAttribute("duty") != null) {
|
||||||
|
int di = Utils.s2i(root.getAttribute("duty")); // 0-100;
|
||||||
|
dty = (Math.PI * 2) * ((double)di / 100d);
|
||||||
|
}
|
||||||
|
return new LFO(f, d, p, w, dty, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AGC loadAGC(Element root) {
|
public AGC loadAGC(Element root) {
|
||||||
@@ -3369,6 +3409,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newSentence.writeAudioData(startSamples);
|
newSentence.writeAudioData(startSamples);
|
||||||
|
newSentence.setPostGapType("continuation");
|
||||||
|
newSentence.setPostGap(Options.getInteger("catenation.short-sentence"));
|
||||||
|
|
||||||
selectedSentence.writeAudioData(endSamples);
|
selectedSentence.writeAudioData(endSamples);
|
||||||
selectedSentence.autoTrimSample();
|
selectedSentence.autoTrimSample();
|
||||||
newSentence.autoTrimSample();
|
newSentence.autoTrimSample();
|
||||||
|
|||||||
@@ -206,4 +206,14 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void purgeBackups() {
|
||||||
|
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||||
|
Object ob = (Object)o.nextElement();
|
||||||
|
if (ob instanceof Chapter) {
|
||||||
|
Chapter c = (Chapter)ob;
|
||||||
|
c.purgeBackups();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
icn.add(Overlays.important, OverlayIcon.TOP_RIGHT);
|
icn.add(Overlays.important, OverlayIcon.TOP_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s.getEndOffset() == s.getSampleSize() - 1) {
|
||||||
|
icn.add(Overlays.important, OverlayIcon.TOP_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
if (s.getEffectChain() != null) {
|
if (s.getEffectChain() != null) {
|
||||||
if (!s.getEffectChain().equals("none")) {
|
if (!s.getEffectChain().equals("none")) {
|
||||||
icn.add(Overlays.filter, OverlayIcon.BOTTOM_RIGHT);
|
icn.add(Overlays.filter, OverlayIcon.BOTTOM_RIGHT);
|
||||||
|
|||||||
@@ -34,4 +34,11 @@ public class CacheManager {
|
|||||||
cache.remove(c);
|
cache.remove(c);
|
||||||
c.clearCache();
|
c.clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void purgeCache() {
|
||||||
|
for (Cacheable c : cache) {
|
||||||
|
c.clearCache();
|
||||||
|
}
|
||||||
|
cache.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class Chapter extends DefaultMutableTreeNode {
|
|||||||
audioAttributes.setCodec("libmp3lame");
|
audioAttributes.setCodec("libmp3lame");
|
||||||
audioAttributes.setBitRate(Options.getInteger("audio.export.bitrate"));
|
audioAttributes.setBitRate(Options.getInteger("audio.export.bitrate"));
|
||||||
audioAttributes.setSamplingRate(Options.getInteger("audio.export.samplerate"));
|
audioAttributes.setSamplingRate(Options.getInteger("audio.export.samplerate"));
|
||||||
audioAttributes.setChannels(2); //new Integer(2));
|
audioAttributes.setChannels(Options.getInteger("audio.export.channels")); //new Integer(2));
|
||||||
attributes.setFormat("mp3");
|
attributes.setFormat("mp3");
|
||||||
attributes.setAudioAttributes(audioAttributes);
|
attributes.setAudioAttributes(audioAttributes);
|
||||||
|
|
||||||
@@ -239,4 +239,14 @@ public class Chapter extends DefaultMutableTreeNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void purgeBackups() {
|
||||||
|
for (Enumeration o = children(); o.hasMoreElements();) {
|
||||||
|
Object ob = (Object)o.nextElement();
|
||||||
|
if (ob instanceof Sentence) {
|
||||||
|
Sentence s = (Sentence)ob;
|
||||||
|
s.purgeBackups();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,37 +9,73 @@ public class LFO implements Effect {
|
|||||||
double depth;
|
double depth;
|
||||||
double sampleRate;
|
double sampleRate;
|
||||||
double sampleStep;
|
double sampleStep;
|
||||||
|
int waveform;
|
||||||
|
double duty;
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
public static final int SINE = 0;
|
||||||
|
public static final int COSINE = 1;
|
||||||
|
public static final int SQUARE = 2;
|
||||||
|
public static final int TRIANGLE = 3;
|
||||||
|
public static final int SAWTOOTH = 4;
|
||||||
|
|
||||||
|
public static final int ADD = 0;
|
||||||
|
public static final int REPLACE = 1;
|
||||||
|
|
||||||
public LFO(double f, double d) {
|
public LFO(double f, double d) {
|
||||||
frequency = f;
|
this(f, d, 0, SINE, Math.PI, REPLACE);
|
||||||
depth = d;
|
|
||||||
phase = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LFO(double f, double d, double p) {
|
public LFO(double f, double d, double p) {
|
||||||
|
this(f, d, p, SINE, Math.PI, REPLACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LFO(double f, double d, double p, int w) {
|
||||||
|
this(f, d, p, w, Math.PI, REPLACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LFO(double f, double d, double p, int w, double dty) {
|
||||||
|
this(f, d, p, w, dty, REPLACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LFO(double f, double d, double p, int w, double dty, int m) {
|
||||||
frequency = f;
|
frequency = f;
|
||||||
depth = d;
|
depth = d;
|
||||||
phase = p;
|
phase = p;
|
||||||
|
waveform = w;
|
||||||
|
duty = dty;
|
||||||
|
mode = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(double[][] samples) {
|
public void process(double[][] samples) {
|
||||||
for (double[] sample : samples) {
|
for (double[] sample : samples) {
|
||||||
double v = Math.sin(phase);
|
double v = 0;
|
||||||
|
switch (waveform) {
|
||||||
|
case SINE: v = Math.sin(phase); break;
|
||||||
|
case COSINE: v = Math.cos(phase); break;
|
||||||
|
case SQUARE: v = (phase > duty) ? 1d : 0d; break;
|
||||||
|
case TRIANGLE: v = (phase < Math.PI) ? (phase / Math.PI) : (1d - ((phase - Math.PI) / Math.PI)); break;
|
||||||
|
case SAWTOOTH: v = (phase / (Math.PI*2d)); break;
|
||||||
|
}
|
||||||
phase += sampleStep;
|
phase += sampleStep;
|
||||||
if (phase > (Math.PI * 2d)) {
|
if (phase > (Math.PI * 2d)) {
|
||||||
phase -= (Math.PI * 2d);
|
phase -= (Math.PI * 2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Make it between 0 and 1.
|
|
||||||
// v = 1d + v;
|
|
||||||
// v /= 2d;
|
|
||||||
|
|
||||||
// Multiply it by the gain factor
|
// Multiply it by the gain factor
|
||||||
v *= depth;
|
v *= depth;
|
||||||
|
|
||||||
// Apply it to the sample
|
// Apply it to the sample
|
||||||
|
switch (mode) {
|
||||||
|
case REPLACE:
|
||||||
|
sample[Sentence.LEFT] = (sample[Sentence.LEFT] * v);
|
||||||
|
sample[Sentence.RIGHT] = (sample[Sentence.RIGHT] * v);
|
||||||
|
break;
|
||||||
|
case ADD:
|
||||||
sample[Sentence.LEFT] += (sample[Sentence.LEFT] * v);
|
sample[Sentence.LEFT] += (sample[Sentence.LEFT] * v);
|
||||||
sample[Sentence.RIGHT] += (sample[Sentence.RIGHT] * v);
|
sample[Sentence.RIGHT] += (sample[Sentence.RIGHT] * v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public class MainToolBar extends JToolBar {
|
|||||||
JButtonSpacePlay eq;
|
JButtonSpacePlay eq;
|
||||||
JToggleButtonSpacePlay mic;
|
JToggleButtonSpacePlay mic;
|
||||||
|
|
||||||
|
JComboBox<String> playbackSpeed;
|
||||||
|
|
||||||
JToggleButtonSpacePlay disableEffects;
|
JToggleButtonSpacePlay disableEffects;
|
||||||
|
|
||||||
AudiobookRecorder root;
|
AudiobookRecorder root;
|
||||||
@@ -100,6 +102,7 @@ public class MainToolBar extends JToolBar {
|
|||||||
eq = new JButtonSpacePlay(Icons.eq, "Reload Effects", new ActionListener() {
|
eq = new JButtonSpacePlay(Icons.eq, "Reload Effects", new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
root.loadEffects();
|
root.loadEffects();
|
||||||
|
CacheManager.purgeCache();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -129,6 +132,7 @@ public class MainToolBar extends JToolBar {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
add(mic);
|
add(mic);
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
@@ -152,7 +156,20 @@ public class MainToolBar extends JToolBar {
|
|||||||
|
|
||||||
add(disableEffects);
|
add(disableEffects);
|
||||||
|
|
||||||
|
addSeparator();
|
||||||
|
|
||||||
|
add(new JLabel("Playback speed: "));
|
||||||
|
playbackSpeed = new JComboBox<String>(new String[] {
|
||||||
|
"0.75x",
|
||||||
|
"1.00x",
|
||||||
|
"1.25x",
|
||||||
|
"1.50x",
|
||||||
|
"1.75x"
|
||||||
|
});
|
||||||
|
playbackSpeed.setFocusable(false);
|
||||||
|
|
||||||
|
playbackSpeed.setSelectedIndex(1);
|
||||||
|
add(playbackSpeed);
|
||||||
|
|
||||||
setFloatable(false);
|
setFloatable(false);
|
||||||
}
|
}
|
||||||
@@ -161,4 +178,9 @@ public class MainToolBar extends JToolBar {
|
|||||||
playtoSentence.setEnabled(b);
|
playtoSentence.setEnabled(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getPlaybackSpeed() {
|
||||||
|
int v = playbackSpeed.getSelectedIndex();
|
||||||
|
return 0.75f + (0.25f * v);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public class Options extends JDialog {
|
|||||||
JComboBox<KVPair> rateList;
|
JComboBox<KVPair> rateList;
|
||||||
JComboBox<KVPair> bitDepth;
|
JComboBox<KVPair> bitDepth;
|
||||||
JComboBox<KVPair> trimMethod;
|
JComboBox<KVPair> trimMethod;
|
||||||
|
JComboBox<KVPair> fftBlockSize;
|
||||||
|
JComboBox<KVPair> playbackBlockSize;
|
||||||
JTextField storageFolder;
|
JTextField storageFolder;
|
||||||
JTextField archiveFolder;
|
JTextField archiveFolder;
|
||||||
JSpinner preChapterGap;
|
JSpinner preChapterGap;
|
||||||
@@ -34,6 +36,7 @@ public class Options extends JDialog {
|
|||||||
JSpinner postSectionGap;
|
JSpinner postSectionGap;
|
||||||
JTextField ffmpegLocation;
|
JTextField ffmpegLocation;
|
||||||
JComboBox<KVPair> bitRate;
|
JComboBox<KVPair> bitRate;
|
||||||
|
JComboBox<KVPair> channels;
|
||||||
JComboBox<KVPair> exportRate;
|
JComboBox<KVPair> exportRate;
|
||||||
JCheckBox enableParsing;
|
JCheckBox enableParsing;
|
||||||
JSpinner cacheSize;
|
JSpinner cacheSize;
|
||||||
@@ -297,10 +300,12 @@ public class Options extends JDialog {
|
|||||||
bitDepth = addDropdown(optionsPanel, "Sample resolution:", getResolutionList(), get("audio.recording.resolution"));
|
bitDepth = addDropdown(optionsPanel, "Sample resolution:", getResolutionList(), get("audio.recording.resolution"));
|
||||||
trimMethod = addDropdown(optionsPanel, "Auto-trim method:", getTrimMethods(), get("audio.recording.trim"));
|
trimMethod = addDropdown(optionsPanel, "Auto-trim method:", getTrimMethods(), get("audio.recording.trim"));
|
||||||
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"), "");
|
||||||
|
fftBlockSize = addDropdown(optionsPanel, "FFT Block size:", getFFTBlockSizes(), get("audio.recording.trim.blocksize"));
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
playbackList = addDropdown(optionsPanel, "Playback device:", getPlaybackMixerList(), get("audio.playback.device"));
|
playbackList = addDropdown(optionsPanel, "Playback device:", getPlaybackMixerList(), get("audio.playback.device"));
|
||||||
|
playbackBlockSize = addDropdown(optionsPanel, "Playback Block size:", getPlaybackBlockSizes(), get("audio.playback.blocksize"));
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
storageFolder = addFilePath(optionsPanel, "Storage folder:", get("path.storage"), true);
|
storageFolder = addFilePath(optionsPanel, "Storage folder:", get("path.storage"), true);
|
||||||
archiveFolder = addFilePath(optionsPanel, "Archive folder:", get("path.archive"), true);
|
archiveFolder = addFilePath(optionsPanel, "Archive folder:", get("path.archive"), true);
|
||||||
@@ -318,6 +323,7 @@ public class Options extends JDialog {
|
|||||||
|
|
||||||
ffmpegLocation = addFilePath(optionsPanel, "FFMPEG location:", get("path.ffmpeg"), false);
|
ffmpegLocation = addFilePath(optionsPanel, "FFMPEG location:", get("path.ffmpeg"), false);
|
||||||
bitRate = addDropdown(optionsPanel, "Export bitrate:", getBitrates(), get("audio.export.bitrate"));
|
bitRate = addDropdown(optionsPanel, "Export bitrate:", getBitrates(), get("audio.export.bitrate"));
|
||||||
|
channels = addDropdown(optionsPanel, "Export channels:", getChannelCountList(), get("audio.export.channels"));
|
||||||
exportRate = addDropdown(optionsPanel, "Export sample rate:", getSampleRateList(), get("audio.export.samplerate"));
|
exportRate = addDropdown(optionsPanel, "Export sample rate:", getSampleRateList(), get("audio.export.samplerate"));
|
||||||
|
|
||||||
|
|
||||||
@@ -565,6 +571,8 @@ public class Options extends JDialog {
|
|||||||
} else {
|
} else {
|
||||||
defaultPrefs.put("audio.playback.device", "");
|
defaultPrefs.put("audio.playback.device", "");
|
||||||
}
|
}
|
||||||
|
defaultPrefs.put("audio.recording.trim.blocksize", "4096");
|
||||||
|
defaultPrefs.put("audio.playback.blocksize", "4096");
|
||||||
|
|
||||||
defaultPrefs.put("catenation.pre-chapter", "1000");
|
defaultPrefs.put("catenation.pre-chapter", "1000");
|
||||||
defaultPrefs.put("catenation.post-chapter", "1500");
|
defaultPrefs.put("catenation.post-chapter", "1500");
|
||||||
@@ -580,6 +588,7 @@ public class Options extends JDialog {
|
|||||||
defaultPrefs.put("path.ffmpeg", "");
|
defaultPrefs.put("path.ffmpeg", "");
|
||||||
|
|
||||||
defaultPrefs.put("audio.export.bitrate", "256000");
|
defaultPrefs.put("audio.export.bitrate", "256000");
|
||||||
|
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");
|
||||||
|
|
||||||
@@ -703,11 +712,14 @@ public class Options extends JDialog {
|
|||||||
set("catenation.post-paragraph", postParagraphGap.getValue());
|
set("catenation.post-paragraph", postParagraphGap.getValue());
|
||||||
set("catenation.post-section", postSectionGap.getValue());
|
set("catenation.post-section", postSectionGap.getValue());
|
||||||
set("audio.export.bitrate", ((KVPair)bitRate.getSelectedItem()).key);
|
set("audio.export.bitrate", ((KVPair)bitRate.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("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());
|
||||||
|
set("audio.recording.trim.blocksize", ((KVPair)fftBlockSize.getSelectedItem()).key);
|
||||||
|
set("audio.playback.blocksize", ((KVPair)playbackBlockSize.getSelectedItem()).key);
|
||||||
|
|
||||||
set("effects.ethereal.offset", etherealOffset.getValue());
|
set("effects.ethereal.offset", etherealOffset.getValue());
|
||||||
set("effects.ethereal.iterations", etherealIterations.getValue());
|
set("effects.ethereal.iterations", etherealIterations.getValue());
|
||||||
@@ -782,6 +794,31 @@ public class Options extends JDialog {
|
|||||||
return pairs;
|
return pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static KVPair[] getFFTBlockSizes() {
|
||||||
|
KVPair[] pairs = new KVPair[8];
|
||||||
|
pairs[0] = new KVPair<String, String>("1024", "1024");
|
||||||
|
pairs[1] = new KVPair<String, String>("2048", "2048");
|
||||||
|
pairs[2] = new KVPair<String, String>("4096", "4096");
|
||||||
|
pairs[3] = new KVPair<String, String>("8192", "8192");
|
||||||
|
pairs[4] = new KVPair<String, String>("16384", "16384");
|
||||||
|
pairs[5] = new KVPair<String, String>("32768", "32768");
|
||||||
|
pairs[6] = new KVPair<String, String>("65536", "65537");
|
||||||
|
pairs[7] = new KVPair<String, String>("131072", "131072");
|
||||||
|
return pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KVPair[] getPlaybackBlockSizes() {
|
||||||
|
KVPair[] pairs = new KVPair[8];
|
||||||
|
pairs[0] = new KVPair<String, String>("1024", "1024");
|
||||||
|
pairs[1] = new KVPair<String, String>("2048", "2048");
|
||||||
|
pairs[2] = new KVPair<String, String>("4096", "4096");
|
||||||
|
pairs[3] = new KVPair<String, String>("8192", "8192");
|
||||||
|
pairs[4] = new KVPair<String, String>("16384", "16384");
|
||||||
|
pairs[5] = new KVPair<String, String>("32768", "32768");
|
||||||
|
pairs[6] = new KVPair<String, String>("65536", "65537");
|
||||||
|
pairs[7] = new KVPair<String, String>("131072", "131072");
|
||||||
|
return pairs;
|
||||||
|
}
|
||||||
|
|
||||||
public static void createEffectChains() {
|
public static void createEffectChains() {
|
||||||
effectChains = new ArrayList<EffectGroup>();
|
effectChains = new ArrayList<EffectGroup>();
|
||||||
|
|||||||
@@ -225,17 +225,18 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fftSize = Options.getInteger("audio.recording.trim.blocksize");
|
||||||
|
|
||||||
int blocks = samples.length / 4096 + 1;
|
int blocks = samples.length / fftSize + 1;
|
||||||
|
|
||||||
int[] intens = new int[blocks];
|
int[] intens = new int[blocks];
|
||||||
int block = 0;
|
int block = 0;
|
||||||
|
|
||||||
for (int i = 0; i < samples.length; i+= 4096) {
|
for (int i = 0; i < samples.length; i+= fftSize) {
|
||||||
double[] real = new double[4096];
|
double[] real = new double[fftSize];
|
||||||
double[] imag = new double[4096];
|
double[] imag = new double[fftSize];
|
||||||
|
|
||||||
for (int j = 0; j < 4096; j++) {
|
for (int j = 0; j < fftSize; j++) {
|
||||||
if (i + j < samples.length) {
|
if (i + j < samples.length) {
|
||||||
real[j] = (samples[i+j][LEFT] + samples[i+j][RIGHT]) / 2d;
|
real[j] = (samples[i+j][LEFT] + samples[i+j][RIGHT]) / 2d;
|
||||||
imag[j] = 0;
|
imag[j] = 0;
|
||||||
@@ -247,14 +248,14 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
double[] buckets = FFT.fft(real, imag, true);
|
double[] buckets = FFT.fft(real, imag, true);
|
||||||
double av = 0;
|
double av = 0;
|
||||||
for (int j = 1; j < 2048; j++) {
|
for (int j = 1; j < fftSize/2; j++) {
|
||||||
av += Math.abs(buckets[j]);
|
av += Math.abs(buckets[j]);
|
||||||
}
|
}
|
||||||
av /= 2047d;
|
av /= (fftSize / 2);
|
||||||
|
|
||||||
intens[block] = 0;
|
intens[block] = 0;
|
||||||
|
|
||||||
for (int j = 2; j < 4096; j += 2) {
|
for (int j = 2; j < fftSize; j += 2) {
|
||||||
double d = Math.abs(av - buckets[j]);
|
double d = Math.abs(av - buckets[j]);
|
||||||
if (d > 0.05) {
|
if (d > 0.05) {
|
||||||
intens[block]++;
|
intens[block]++;
|
||||||
@@ -278,7 +279,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
startOffset = start * 4096;
|
startOffset = start * fftSize;
|
||||||
if (startOffset < 0) startOffset = 0;
|
if (startOffset < 0) startOffset = 0;
|
||||||
if (startOffset >= samples.length) startOffset = samples.length;
|
if (startOffset >= samples.length) startOffset = samples.length;
|
||||||
|
|
||||||
@@ -295,9 +296,9 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
end = blocks - 1;
|
end = blocks - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
endOffset = end * 4096;
|
endOffset = (end+1) * fftSize;
|
||||||
|
|
||||||
if (endOffset <= startOffset) endOffset = startOffset + 4096;
|
if (endOffset <= startOffset) endOffset = startOffset + fftSize;
|
||||||
if (endOffset < 0) endOffset = 0;
|
if (endOffset < 0) endOffset = 0;
|
||||||
if (endOffset >= samples.length) endOffset = samples.length;
|
if (endOffset >= samples.length) endOffset = samples.length;
|
||||||
updateCrossings(useRaw);
|
updateCrossings(useRaw);
|
||||||
@@ -337,7 +338,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
startOffset = 0;
|
startOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
startOffset -= 4096;
|
int fftSize = Options.getInteger("audio.recording.trim.blocksize");
|
||||||
|
startOffset -= fftSize;
|
||||||
|
|
||||||
for (int i = samples.length-1; i >= 0; i--) {
|
for (int i = samples.length-1; i >= 0; i--) {
|
||||||
endOffset = i;
|
endOffset = i;
|
||||||
@@ -348,9 +350,9 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endOffset += 4096;
|
endOffset += fftSize;
|
||||||
|
|
||||||
if (endOffset <= startOffset) endOffset = startOffset + 4096;
|
if (endOffset <= startOffset) endOffset = startOffset + fftSize;
|
||||||
if (endOffset <= 0) {
|
if (endOffset <= 0) {
|
||||||
endOffset = samples.length-1;
|
endOffset = samples.length-1;
|
||||||
}
|
}
|
||||||
@@ -1308,4 +1310,35 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
public void debug(String txt) {
|
public void debug(String txt) {
|
||||||
Debug.debug(String.format("%s: %s", id, txt));
|
Debug.debug(String.format("%s: %s", id, txt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TreeMap<String, String> getSentenceData() {
|
||||||
|
|
||||||
|
TreeMap<String, String> out = new TreeMap<String, String>();
|
||||||
|
|
||||||
|
out.put("id", getId());
|
||||||
|
out.put("text", getText());
|
||||||
|
out.put("post-gap", Integer.toString(getPostGap()));
|
||||||
|
out.put("start-offset", Integer.toString(getStartOffset()));
|
||||||
|
out.put("end-offset", Integer.toString(getEndOffset()));
|
||||||
|
out.put("locked", isLocked() ? "true" : "false");
|
||||||
|
out.put("attention", getAttentionFlag() ? "true" : "false");
|
||||||
|
out.put("gain", String.format("%.8f", getGain()));
|
||||||
|
out.put("effect", getEffectChain());
|
||||||
|
out.put("gaptype", getPostGapType());
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void purgeBackups() {
|
||||||
|
File whereto = getFile().getParentFile();
|
||||||
|
String name = getFile().getName();
|
||||||
|
|
||||||
|
File[] files = whereto.listFiles();
|
||||||
|
for (File f : files) {
|
||||||
|
String fn = f.getName();
|
||||||
|
if (fn.startsWith("backup-") && fn.endsWith("-" + name)) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ 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;
|
||||||
double sample = (samples[offset + (n * step) + o][Sentence.LEFT] + samples[offset + (n * step) + o][Sentence.RIGHT]) / 2d;
|
double sample = (samples[offset + (n * step) + o][Sentence.LEFT] + samples[offset + (n * step) + o][Sentence.RIGHT]) / 2d;
|
||||||
if (sample >= 0) {
|
if (sample >= 0) {
|
||||||
have += sample;
|
have += sample;
|
||||||
|
|||||||
Reference in New Issue
Block a user