Remove audio stability toggle

pull/67/head
James Ball 2022-05-14 15:41:14 +01:00 zatwierdzone przez James H Ball
rodzic 3089cd2b15
commit 8cd3377343
8 zmienionych plików z 2 dodań i 52 usunięć

Wyświetl plik

@ -13,8 +13,6 @@ public interface AudioPlayer<S> extends Runnable, MidiListener {
void stop();
void setAudioStability(boolean stable);
boolean isPlaying();
void setOctave(int octave);

Wyświetl plik

@ -365,11 +365,6 @@ public class ShapeAudioPlayer implements AudioPlayer<List<Shape>> {
audioEngine.stop();
}
@Override
public void setAudioStability(boolean stable) {
audioEngine.setAudioStability(stable);
}
@Override
public boolean isPlaying() {
return audioEngine.isPlaying();

Wyświetl plik

@ -12,8 +12,6 @@ public interface AudioEngine {
void stop();
void setAudioStability(boolean stable);
List<AudioDevice> devices();
AudioDevice getDefaultDevice();

Wyświetl plik

@ -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<AudioDevice> devices() {
List<AudioDevice> devices = new ArrayList<>();

Wyświetl plik

@ -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<AudioDevice> devices() {
return Stream.of(44100, 48000, 96000, 192000).map(rate ->

Wyświetl plik

@ -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<AudioDevice> devices() {

Wyświetl plik

@ -165,8 +165,6 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
private Spinner<Double> 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);

Wyświetl plik

@ -67,7 +67,6 @@
</AnchorPane>
</content>
</CustomMenuItem>
<CheckMenuItem fx:id="audioStabilityCheckMenuItem" mnemonicParsing="false" text="High Audio Stability" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="MIDI">