kopia lustrzana https://github.com/jameshball/osci-render
Revert removal of microphone.available
rodzic
9537bb2312
commit
7fcd1995f0
|
@ -51,11 +51,13 @@ public class JavaAudioInput implements AudioInput {
|
||||||
byte[] data = new byte[CHUNK_SIZE];
|
byte[] data = new byte[CHUNK_SIZE];
|
||||||
microphone.start();
|
microphone.start();
|
||||||
while (!stopped) {
|
while (!stopped) {
|
||||||
microphone.read(data, 0, CHUNK_SIZE);
|
if (microphone.available() >= CHUNK_SIZE) {
|
||||||
for (int i = 0; i < CHUNK_SIZE / 2; i += 2 * STEP_SIZE) {
|
microphone.read(data, 0, CHUNK_SIZE);
|
||||||
short sample = (short) ((data[2 * i + 1] << 8) + data[2 * i]);
|
for (int i = 0; i < CHUNK_SIZE / 2; i += 2 * STEP_SIZE) {
|
||||||
for (AudioInputListener listener : listeners) {
|
short sample = (short) ((data[2 * i + 1] << 8) + data[2 * i]);
|
||||||
listener.transmit((double) sample / Short.MAX_VALUE);
|
for (AudioInputListener listener : listeners) {
|
||||||
|
listener.transmit((double) sample / Short.MAX_VALUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue