How to set sample rate as 100KHz using AudioTrack in Android?
<p>I'm developing an Android app that will play a specific audio. This audio is generated by code. My problem is that I need the sample rate up to 100KHz, but I got the error message as below. Could anyone know how to set sample rate as 100KHz with <code>AudioTrack</code>. Thanks.</p>

<p><strong>PS:</strong> As I know, only <code>AudioTrack</code> could modify audio data, that's why I use <code>AudioTrack</code></p>

<p>---------------code start-------------------</p>

<pre><code>audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
                            100000,
                            AudioFormat.ENCODING_PCM_16BIT,
                            (int)minSize,
                            AudioTrack.MODE_STREAM);
</code></pre>

<hr>

<p>---------------log start--------------------</p>

<pre><code>&gt; D/AndroidRuntime( 7952): Shutting down VM E/AndroidRuntime( 7952):
&gt; FATAL EXCEPTION: main E/AndroidRuntime( 7952):
&gt; java.lang.RuntimeException: Unable to start activity
&gt; ComponentInfo{com.examples.audiotracktest/com.examples.audiotracktest.AudioTrackTest}:
&gt; java.lang.IllegalArgumentException: 100000Hz is not a supported sample
&gt; rate. E/AndroidRuntime( 7952):    at
&gt; android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1830)
&gt; E/AndroidRuntime( 7952):  at
&gt; android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
&gt; E/AndroidRuntime( 7952):  at
&gt; android.app.ActivityThread.access$1500(ActivityThread.java:132)
&gt; E/AndroidRuntime( 7952):  at
&gt; android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
&gt; E/AndroidRuntime( 7952):  at
&gt; android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(
&gt; 7952):    at android.os.Looper.loop(Looper.java:150) E/AndroidRuntime(
&gt; 7952):    at android.app.ActivityThread.main(ActivityThread.java:4293)
&gt; E/AndroidRuntime( 7952):  at
&gt; java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(
&gt; 7952):    at java.lang.reflect.Method.invoke(Method.java:507)
&gt; E/AndroidRuntime( 7952):  at
&gt; com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
&gt; E/AndroidRuntime( 7952):  at
&gt; com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
&gt; E/AndroidRuntime( 7952):  at dalvik.system.NativeStart.main(Native
&gt; Method) E/AndroidRuntime( 7952): Caused by:
&gt; java.lang.IllegalArgumentException: 100000Hz is not a supported sample
&gt; rate. E/AndroidRuntime( 7952):    at
&gt; android.media.AudioTrack.audioParamCheck(AudioTrack.java:369)
&gt; E/AndroidRuntime( 7952):  at
&gt; android.media.AudioTrack.&lt;init&gt;(AudioTrack.java:312) E/AndroidRuntime(
&gt; 7952):    at android.media.AudioTrack.&lt;init&gt;(AudioTrack.java:265)
&gt; E/AndroidRuntime( 7952):  at
&gt; com.examples.audiotracktest.AndroidAudioDevice.&lt;init&gt;(AndroidAudioDevice.java:21)
&gt; E/AndroidRuntime( 7952):  at
&gt; com.examples.audiotracktest.AudioThread.&lt;init&gt;(AudioThread.java:11)
&gt; E/AndroidRuntime( 7952):  at
&gt; com.examples.audiotracktest.AudioTrackTest.onCreate(AudioTrackTest.java:29)
&gt; E/AndroidRuntime( 7952):  at
&gt; android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
&gt; E/AndroidRuntime( 7952):  at
&gt; android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794)
&gt; E/AndroidRuntime( 7952):  ... 11 more
</code></pre>
