diff --git a/src/main/java/sh/ball/audio/AudioPlayer.java b/src/main/java/sh/ball/audio/AudioPlayer.java index 1c70bed..90208cc 100644 --- a/src/main/java/sh/ball/audio/AudioPlayer.java +++ b/src/main/java/sh/ball/audio/AudioPlayer.java @@ -13,8 +13,6 @@ public interface AudioPlayer extends Runnable, MidiListener { void stop(); - void setAudioStability(boolean stable); - boolean isPlaying(); void setOctave(int octave); diff --git a/src/main/java/sh/ball/audio/ShapeAudioPlayer.java b/src/main/java/sh/ball/audio/ShapeAudioPlayer.java index 4413482..9613767 100644 --- a/src/main/java/sh/ball/audio/ShapeAudioPlayer.java +++ b/src/main/java/sh/ball/audio/ShapeAudioPlayer.java @@ -365,11 +365,6 @@ public class ShapeAudioPlayer implements AudioPlayer> { audioEngine.stop(); } - @Override - public void setAudioStability(boolean stable) { - audioEngine.setAudioStability(stable); - } - @Override public boolean isPlaying() { return audioEngine.isPlaying(); diff --git a/src/main/java/sh/ball/audio/engine/AudioEngine.java b/src/main/java/sh/ball/audio/engine/AudioEngine.java index b23bb30..1714e31 100644 --- a/src/main/java/sh/ball/audio/engine/AudioEngine.java +++ b/src/main/java/sh/ball/audio/engine/AudioEngine.java @@ -12,8 +12,6 @@ public interface AudioEngine { void stop(); - void setAudioStability(boolean stable); - List devices(); AudioDevice getDefaultDevice(); diff --git a/src/main/java/sh/ball/audio/engine/ConglomerateAudioEngine.java b/src/main/java/sh/ball/audio/engine/ConglomerateAudioEngine.java index 76c905a..62f46f7 100644 --- a/src/main/java/sh/ball/audio/engine/ConglomerateAudioEngine.java +++ b/src/main/java/sh/ball/audio/engine/ConglomerateAudioEngine.java @@ -58,12 +58,6 @@ public class ConglomerateAudioEngine implements AudioEngine { bufferedChannelGenerator.stop(); } - @Override - public void setAudioStability(boolean stable) { - xtEngine.setAudioStability(stable); - javaEngine.setAudioStability(stable); - } - @Override public List devices() { List devices = new ArrayList<>(); diff --git a/src/main/java/sh/ball/audio/engine/JavaAudioEngine.java b/src/main/java/sh/ball/audio/engine/JavaAudioEngine.java index 8e43e71..d4077a1 100644 --- a/src/main/java/sh/ball/audio/engine/JavaAudioEngine.java +++ b/src/main/java/sh/ball/audio/engine/JavaAudioEngine.java @@ -12,8 +12,7 @@ public class JavaAudioEngine implements AudioEngine { private static final int DEFAULT_SAMPLE_RATE = 192000; // stereo audio private static final int NUM_CHANNELS = 2; - private static final int UNSTABLE_LATENCY_MS = 30; - private static final int STABLE_LATENCY_MS = 100; + private static final int LATENCY_MS = 30; private static final int MAX_FRAME_LATENCY = 512; // java sound doesn't support anything more than 16 bit :( private static final int BIT_DEPTH = 16; @@ -25,9 +24,6 @@ public class JavaAudioEngine implements AudioEngine { private SourceDataLine source; private AudioDevice device; - private boolean makeMoreStable = false; - private boolean makeLessStable = false; - private boolean isStable = false; @Override public boolean isPlaying() { @@ -48,7 +44,7 @@ public class JavaAudioEngine implements AudioEngine { // connects to a device that can support the format above (i.e. default audio device) this.source = AudioSystem.getSourceDataLine(format); - int bufferSize = calculateBufferSize(device, UNSTABLE_LATENCY_MS); + int bufferSize = calculateBufferSize(device, LATENCY_MS); byte[] buffer = new byte[bufferSize * 2]; @@ -56,16 +52,6 @@ public class JavaAudioEngine implements AudioEngine { source.start(); while (!stopped) { - if (makeMoreStable || makeLessStable) { - int newLatency = makeMoreStable ? STABLE_LATENCY_MS : UNSTABLE_LATENCY_MS; - bufferSize = calculateBufferSize(device, newLatency); - - buffer = new byte[bufferSize * 2]; - isStable = makeMoreStable; - makeMoreStable = false; - makeLessStable = false; - } - int requiredSamples = bufferSize / FRAME_SIZE; if (requiredSamples * NUM_CHANNELS > buffer.length / 2) { @@ -99,15 +85,6 @@ public class JavaAudioEngine implements AudioEngine { stopped = true; } - @Override - public void setAudioStability(boolean stable) { - if (stable && !isStable) { - this.makeMoreStable = true; - } else if (!stable && isStable) { - this.makeLessStable = true; - } - } - @Override public List devices() { return Stream.of(44100, 48000, 96000, 192000).map(rate -> diff --git a/src/main/java/sh/ball/audio/engine/XtAudioEngine.java b/src/main/java/sh/ball/audio/engine/XtAudioEngine.java index 0275586..8428e29 100644 --- a/src/main/java/sh/ball/audio/engine/XtAudioEngine.java +++ b/src/main/java/sh/ball/audio/engine/XtAudioEngine.java @@ -134,11 +134,6 @@ public class XtAudioEngine implements AudioEngine { stopped = true; } - @Override - public void setAudioStability(boolean stable) { - // TODO: unimplemented - } - // XtAudio boilerplate for getting a list of connected audio devices @Override public List devices() { diff --git a/src/main/java/sh/ball/gui/controller/MainController.java b/src/main/java/sh/ball/gui/controller/MainController.java index 5e1b779..20b9a15 100644 --- a/src/main/java/sh/ball/gui/controller/MainController.java +++ b/src/main/java/sh/ball/gui/controller/MainController.java @@ -165,8 +165,6 @@ public class MainController implements Initializable, FrequencyListener, MidiLis private Spinner recordLengthSpinner; @FXML private MenuItem softwareOscilloscopeMenuItem; - @FXML - private CheckMenuItem audioStabilityCheckMenuItem; public MainController() throws Exception { // Clone DEFAULT_OBJ InputStream using a ByteArrayOutputStream @@ -462,10 +460,6 @@ public class MainController implements Initializable, FrequencyListener, MidiLis objController.updateObjectRotateSpeed(); - audioStabilityCheckMenuItem.selectedProperty().addListener((o, old, selected) -> { - audioPlayer.setAudioStability(selected); - }); - switchAudioDevice(defaultDevice, false); executor.submit(producer); Gui.midiCommunicator.addListener(this); diff --git a/src/main/resources/fxml/main.fxml b/src/main/resources/fxml/main.fxml index e9fc826..1627dc8 100644 --- a/src/main/resources/fxml/main.fxml +++ b/src/main/resources/fxml/main.fxml @@ -67,7 +67,6 @@ -