Added playback speed option

This commit is contained in:
2019-09-07 20:34:02 +01:00
parent 3eb6704f2f
commit d619fb2f4d
2 changed files with 26 additions and 2 deletions

View File

@@ -2183,7 +2183,9 @@ public class AudiobookRecorder extends JFrame {
try {
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.open(format);
@@ -2421,7 +2423,9 @@ public class AudiobookRecorder extends JFrame {
try {
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.open(format);
play.start();

View File

@@ -19,6 +19,8 @@ public class MainToolBar extends JToolBar {
JButtonSpacePlay eq;
JToggleButtonSpacePlay mic;
JComboBox<String> playbackSpeed;
JToggleButtonSpacePlay disableEffects;
AudiobookRecorder root;
@@ -128,6 +130,7 @@ public class MainToolBar extends JToolBar {
}
}
});
add(mic);
@@ -152,7 +155,19 @@ public class MainToolBar extends JToolBar {
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.setSelectedIndex(1);
add(playbackSpeed);
setFloatable(false);
}
@@ -161,4 +176,9 @@ public class MainToolBar extends JToolBar {
playtoSentence.setEnabled(b);
}
public float getPlaybackSpeed() {
int v = playbackSpeed.getSelectedIndex();
return 0.75f + (0.25f * v);
}
}