From e9097114bb9fb531393c1cc91bfca258f1347fc4 Mon Sep 17 00:00:00 2001 From: woheller69 Date: Sun, 20 Feb 2022 16:14:26 +0100 Subject: [PATCH] make stream volume (gain) and adjustable parameter --- .../main/java/org/woheller69/audiometry/PerformSingleTest.java | 3 ++- app/src/main/java/org/woheller69/audiometry/PerformTest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/woheller69/audiometry/PerformSingleTest.java b/app/src/main/java/org/woheller69/audiometry/PerformSingleTest.java index 7bd4c8d..38e3bdb 100644 --- a/app/src/main/java/org/woheller69/audiometry/PerformSingleTest.java +++ b/app/src/main/java/org/woheller69/audiometry/PerformSingleTest.java @@ -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; @@ -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(); diff --git a/app/src/main/java/org/woheller69/audiometry/PerformTest.java b/app/src/main/java/org/woheller69/audiometry/PerformTest.java index 6029cbf..e793e5d 100644 --- a/app/src/main/java/org/woheller69/audiometry/PerformTest.java +++ b/app/src/main/java/org/woheller69/audiometry/PerformTest.java @@ -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; @@ -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();