Skip to content

Commit

Permalink
Update version, changelog, audio track
Browse files Browse the repository at this point in the history
  • Loading branch information
billthefarmer committed Nov 22, 2023
1 parent 7b6cdd6 commit 25f1756
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-GB/changelog/136.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add Simplified Chinese translation
45 changes: 19 additions & 26 deletions src/main/java/org/billthefarmer/siggen/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down

0 comments on commit 25f1756

Please sign in to comment.