diff --git a/build.gradle b/build.gradle index c51327f..31137c3 100644 --- a/build.gradle +++ b/build.gradle @@ -28,10 +28,10 @@ android { defaultConfig { applicationId "org.billthefarmer.siggen" - minSdkVersion 21 + minSdkVersion 23 targetSdkVersion 31 - versionName "1.35" - versionCode 135 + versionName "1.36" + versionCode 136 buildConfigField "long", "BUILT", System.currentTimeMillis() + "L" } diff --git a/fastlane/metadata/android/en-GB/changelog/136.txt b/fastlane/metadata/android/en-GB/changelog/136.txt new file mode 100644 index 0000000..173a86f --- /dev/null +++ b/fastlane/metadata/android/en-GB/changelog/136.txt @@ -0,0 +1 @@ + * Add Simplified Chinese translation diff --git a/src/main/java/org/billthefarmer/siggen/Main.java b/src/main/java/org/billthefarmer/siggen/Main.java index 62ddb86..091eb7f 100644 --- a/src/main/java/org/billthefarmer/siggen/Main.java +++ b/src/main/java/org/billthefarmer/siggen/Main.java @@ -34,6 +34,7 @@ import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; +import android.media.AudioAttributes; import android.media.AudioFormat; import android.media.AudioManager; import android.media.AudioTrack; @@ -1204,6 +1205,8 @@ protected class Audio implements Runnable protected static final int SQUARE = 1; protected static final int SAWTOOTH = 2; + protected static final int SIZE = 8192; + protected int waveform; protected boolean mute = false; @@ -1256,32 +1259,22 @@ protected void processAudio() { short buffer[]; - int rate = - AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC); - int minSize = - AudioTrack.getMinBufferSize(rate, AudioFormat.CHANNEL_OUT_MONO, - AudioFormat.ENCODING_PCM_16BIT); - - // Find a suitable buffer size - int sizes[] = {1024, 2048, 4096, 8192, 16384, 32768}; - int size = 0; - - for (int s: sizes) - { - if (s > minSize) - { - size = s; - break; - } - } - - final double K = 2.0 * Math.PI / rate; - // Create the audio track - audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, rate, - AudioFormat.CHANNEL_OUT_MONO, - AudioFormat.ENCODING_PCM_16BIT, - size, AudioTrack.MODE_STREAM); + audioTrack = new AudioTrack.Builder() + .setAudioAttributes + (new AudioAttributes.Builder() + .setUsage(AudioAttributes.USAGE_MEDIA) + .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) + .build()) + .setAudioFormat + (new AudioFormat.Builder() + .setEncoding(AudioFormat.ENCODING_PCM_16BIT) + .setChannelMask(AudioFormat.CHANNEL_OUT_MONO) + .build()) + .build(); + + int rate = audioTrack.getSampleRate(); + final double K = 2.0 * Math.PI / rate; // Check audioTrack state int state = audioTrack.getState(); @@ -1294,7 +1287,7 @@ protected void processAudio() audioTrack.play(); // Create the buffer - buffer = new short[size]; + buffer = new short[SIZE]; // Initialise the generator variables double f = frequency;