Skip to content

Commit

Permalink
make stream volume (gain) and adjustable parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Feb 20, 2022
1 parent 9172c86 commit e909711
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.widget.TextView;
import android.widget.Toast;
import static org.woheller69.audiometry.PerformTest.testFrequencies;
import static org.woheller69.audiometry.PerformTest.gain;

import androidx.appcompat.app.AppCompatActivity;

Expand Down Expand Up @@ -163,7 +164,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onResume() {
AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
am.setStreamVolume(AudioManager.STREAM_MUSIC, 9, 0);
am.setStreamVolume(AudioManager.STREAM_MUSIC, gain, 0);
testThread = new testThread();
testThread.start();
super.onResume();
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/org/woheller69/audiometry/PerformTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class PerformTest extends AppCompatActivity {
private final int sampleRate = 44100;
private final int numSamples = duration * sampleRate;
private final int volume = 32767;
static public int gain = 9;
static public final int[] testFrequencies = {125, 250, 500, 1000, 2000, 3000, 4000, 6000, 8000};
static final float[] correctiondBSPLtodBHL ={19.7f,9.0f,2.0f,0f,-3.7f,-8.1f,-7.8f, 2.1f,10.2f}; //estimated from ISO226:2003 hearing threshold. Taken from https://github.com/IoSR-Surrey/MatlabToolbox/blob/master/%2Biosr/%2Bauditory/iso226.m Corrected to value=0 @1000Hz
private boolean heard = false;
Expand Down Expand Up @@ -236,7 +237,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onResume() {
AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
am.setStreamVolume(AudioManager.STREAM_MUSIC, 9, 0);
am.setStreamVolume(AudioManager.STREAM_MUSIC, gain, 0);
testThread = new testThread();
testThread.start();
super.onResume();
Expand Down

0 comments on commit e909711

Please sign in to comment.