Added trim method option in preferences
This commit is contained in:
@@ -734,6 +734,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
JPopupMenu menu = new JPopupMenu();
|
JPopupMenu menu = new JPopupMenu();
|
||||||
JMenuObject peak = new JMenuObject("Auto-trim all (Peak)", c);
|
JMenuObject peak = new JMenuObject("Auto-trim all (Peak)", c);
|
||||||
|
JMenuObject fft = new JMenuObject("Auto-trim all (FFT)", c);
|
||||||
JMenuObject moveUp = new JMenuObject("Move Up", c);
|
JMenuObject moveUp = new JMenuObject("Move Up", c);
|
||||||
JMenuObject moveDown = new JMenuObject("Move Down", c);
|
JMenuObject moveDown = new JMenuObject("Move Down", c);
|
||||||
JMenu mergeWith = new JMenu("Merge chapter with");
|
JMenu mergeWith = new JMenu("Merge chapter with");
|
||||||
@@ -839,6 +840,19 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fft.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
JMenuObject o = (JMenuObject)e.getSource();
|
||||||
|
Chapter c = (Chapter)o.getObject();
|
||||||
|
for (Enumeration s = c.children(); s.hasMoreElements();) {
|
||||||
|
Sentence snt = (Sentence)s.nextElement();
|
||||||
|
if (!snt.isLocked()) {
|
||||||
|
snt.autoTrimSampleFFT();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
lockAll.addActionListener(new ActionListener() {
|
lockAll.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JMenuObject o = (JMenuObject)e.getSource();
|
JMenuObject o = (JMenuObject)e.getSource();
|
||||||
@@ -886,6 +900,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
menu.add(mergeWith);
|
menu.add(mergeWith);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.add(peak);
|
menu.add(peak);
|
||||||
|
menu.add(fft);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.add(lockAll);
|
menu.add(lockAll);
|
||||||
menu.add(unlockAll);
|
menu.add(unlockAll);
|
||||||
@@ -1431,7 +1446,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ms *= 10;
|
ms *= 10;
|
||||||
ms /= 9;
|
ms /= 7;
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class Options extends JDialog {
|
|||||||
JComboBox<KVPair> channelList;
|
JComboBox<KVPair> channelList;
|
||||||
JComboBox<KVPair> rateList;
|
JComboBox<KVPair> rateList;
|
||||||
JComboBox<KVPair> bitDepth;
|
JComboBox<KVPair> bitDepth;
|
||||||
|
JComboBox<KVPair> trimMethod;
|
||||||
JTextField storageFolder;
|
JTextField storageFolder;
|
||||||
JSpinner preChapterGap;
|
JSpinner preChapterGap;
|
||||||
JSpinner postChapterGap;
|
JSpinner postChapterGap;
|
||||||
@@ -247,6 +248,7 @@ public class Options extends JDialog {
|
|||||||
channelList = addDropdown(optionsPanel, "Channels:", getChannelCountList(), get("audio.recording.channels"));
|
channelList = addDropdown(optionsPanel, "Channels:", getChannelCountList(), get("audio.recording.channels"));
|
||||||
rateList = addDropdown(optionsPanel, "Sample rate:", getSampleRateList(), get("audio.recording.samplerate"));
|
rateList = addDropdown(optionsPanel, "Sample rate:", getSampleRateList(), get("audio.recording.samplerate"));
|
||||||
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"));
|
||||||
|
|
||||||
addSeparator(optionsPanel);
|
addSeparator(optionsPanel);
|
||||||
|
|
||||||
@@ -444,6 +446,7 @@ public class Options extends JDialog {
|
|||||||
defaultPrefs.put("audio.recording.channels", "2");
|
defaultPrefs.put("audio.recording.channels", "2");
|
||||||
defaultPrefs.put("audio.recording.samplerate", "44100");
|
defaultPrefs.put("audio.recording.samplerate", "44100");
|
||||||
defaultPrefs.put("audio.recording.resolution", "16");
|
defaultPrefs.put("audio.recording.resolution", "16");
|
||||||
|
defaultPrefs.put("audio.recording.trim", "peak");
|
||||||
if (playbackMixers.length > 0) {
|
if (playbackMixers.length > 0) {
|
||||||
defaultPrefs.put("audio.playback.device", playbackMixers[0].key);
|
defaultPrefs.put("audio.playback.device", playbackMixers[0].key);
|
||||||
} else {
|
} else {
|
||||||
@@ -589,6 +592,7 @@ public class Options extends JDialog {
|
|||||||
set("audio.recording.channels", ((KVPair)channelList.getSelectedItem()).key);
|
set("audio.recording.channels", ((KVPair)channelList.getSelectedItem()).key);
|
||||||
set("audio.recording.samplerate", ((KVPair)rateList.getSelectedItem()).key);
|
set("audio.recording.samplerate", ((KVPair)rateList.getSelectedItem()).key);
|
||||||
set("audio.recording.resolution", ((KVPair)bitDepth.getSelectedItem()).key);
|
set("audio.recording.resolution", ((KVPair)bitDepth.getSelectedItem()).key);
|
||||||
|
set("audio.recording.trim", ((KVPair)trimMethod.getSelectedItem()).key);
|
||||||
set("audio.playback.device", ((KVPair)playbackList.getSelectedItem()).key);
|
set("audio.playback.device", ((KVPair)playbackList.getSelectedItem()).key);
|
||||||
set("path.storage", storageFolder.getText());
|
set("path.storage", storageFolder.getText());
|
||||||
set("path.ffmpeg", ffmpegLocation.getText());
|
set("path.ffmpeg", ffmpegLocation.getText());
|
||||||
@@ -652,4 +656,11 @@ public class Options extends JDialog {
|
|||||||
pairs[0] = new KVPair("16", "16 Bit");
|
pairs[0] = new KVPair("16", "16 Bit");
|
||||||
return pairs;
|
return pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static KVPair[] getTrimMethods() {
|
||||||
|
KVPair[] pairs = new KVPair[2];
|
||||||
|
pairs[0] = new KVPair("peak", "Peak Amplitude");
|
||||||
|
pairs[1] = new KVPair("fft", "FFT Analysis");
|
||||||
|
return pairs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,12 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
storedAudioData = null;
|
storedAudioData = null;
|
||||||
|
|
||||||
if (!id.equals("room-noise")) {
|
if (!id.equals("room-noise")) {
|
||||||
autoTrimSamplePeak();
|
String tm = Options.get("audio.recording.trim");
|
||||||
|
if (tm.equals("peak")) {
|
||||||
|
autoTrimSamplePeak();
|
||||||
|
} else if (tm.equals("fft")) {
|
||||||
|
autoTrimSampleFFT();
|
||||||
|
}
|
||||||
if (Options.getBoolean("process.sphinx")) {
|
if (Options.getBoolean("process.sphinx")) {
|
||||||
recognise();
|
recognise();
|
||||||
}
|
}
|
||||||
@@ -256,6 +261,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
end = i;
|
end = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end++;
|
||||||
|
|
||||||
if (end <= 0) {
|
if (end <= 0) {
|
||||||
end = blocks - 1;
|
end = blocks - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,13 +185,13 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
|
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
int x = e.getX();
|
int x = e.getX();
|
||||||
if ((x >= ((leftMarker - offset)/step) - 2) && (x <= ((leftMarker - offset)/step) + 2)) {
|
if ((x >= ((leftMarker - offset)/step) - 10) && (x <= ((leftMarker - offset)/step) + 10)) {
|
||||||
leftMarkerSaved = leftMarker;
|
leftMarkerSaved = leftMarker;
|
||||||
rightMarkerSaved = rightMarker;
|
rightMarkerSaved = rightMarker;
|
||||||
dragging = 1;
|
dragging = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((x >= ((rightMarker - offset)/step) - 2) && (x <= ((rightMarker - offset)/step) + 2)) {
|
if ((x >= ((rightMarker - offset)/step) - 10) && (x <= ((rightMarker - offset)/step) + 10)) {
|
||||||
rightMarkerSaved = rightMarker;
|
rightMarkerSaved = rightMarker;
|
||||||
leftMarkerSaved = leftMarker;
|
leftMarkerSaved = leftMarker;
|
||||||
dragging = 2;
|
dragging = 2;
|
||||||
@@ -219,11 +219,11 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
int x = e.getX();
|
int x = e.getX();
|
||||||
if ((x >= ((leftMarker - offset)/step) - 2) && (x <= ((leftMarker - offset)/step) + 2)) {
|
if ((x >= ((leftMarker - offset)/step) - 10) && (x <= ((leftMarker - offset)/step) + 10)) {
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((x >= ((rightMarker - offset)/step) - 2) && (x <= ((rightMarker - offset)/step) + 2)) {
|
if ((x >= ((rightMarker - offset)/step) - 10) && (x <= ((rightMarker - offset)/step) + 10)) {
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user