Sound pool volume level












-1















Because i had some problem playing small .wav file with MediaPlayer i switched to SoundPool. So far it seems it performing better than MediaPlayer but the problem i am having is the sound level, which should be 0.5 of system sound level.



i tried with



soundPool.play(currentSoundId, 0.5f, 0.5f, 1, 0, 1);


and it was still at the same sound level, i also tried with



int streamId = soundPool.play(currentSoundId, 1, 1, 1, 0, 1);
soundPool.setVolume(streamId, 0.5f, 0.5f);


and it was same level, any idea how to force to play it at specific volume? Its weird because it seems its not accepting any floats for sound i put in.



EDIT:



i initialize with following constructor



if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){

audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setUsage(AudioAttributes.USAGE_GAME)
.build();

soundPool = new SoundPool.Builder()
.setAudioAttributes(audioAttributes)
.setMaxStreams(2)
.build();
}else{
soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC,0);
}









share|improve this question





























    -1















    Because i had some problem playing small .wav file with MediaPlayer i switched to SoundPool. So far it seems it performing better than MediaPlayer but the problem i am having is the sound level, which should be 0.5 of system sound level.



    i tried with



    soundPool.play(currentSoundId, 0.5f, 0.5f, 1, 0, 1);


    and it was still at the same sound level, i also tried with



    int streamId = soundPool.play(currentSoundId, 1, 1, 1, 0, 1);
    soundPool.setVolume(streamId, 0.5f, 0.5f);


    and it was same level, any idea how to force to play it at specific volume? Its weird because it seems its not accepting any floats for sound i put in.



    EDIT:



    i initialize with following constructor



    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){

    audioAttributes = new AudioAttributes.Builder()
    .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
    .setUsage(AudioAttributes.USAGE_GAME)
    .build();

    soundPool = new SoundPool.Builder()
    .setAudioAttributes(audioAttributes)
    .setMaxStreams(2)
    .build();
    }else{
    soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC,0);
    }









    share|improve this question



























      -1












      -1








      -1








      Because i had some problem playing small .wav file with MediaPlayer i switched to SoundPool. So far it seems it performing better than MediaPlayer but the problem i am having is the sound level, which should be 0.5 of system sound level.



      i tried with



      soundPool.play(currentSoundId, 0.5f, 0.5f, 1, 0, 1);


      and it was still at the same sound level, i also tried with



      int streamId = soundPool.play(currentSoundId, 1, 1, 1, 0, 1);
      soundPool.setVolume(streamId, 0.5f, 0.5f);


      and it was same level, any idea how to force to play it at specific volume? Its weird because it seems its not accepting any floats for sound i put in.



      EDIT:



      i initialize with following constructor



      if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){

      audioAttributes = new AudioAttributes.Builder()
      .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
      .setUsage(AudioAttributes.USAGE_GAME)
      .build();

      soundPool = new SoundPool.Builder()
      .setAudioAttributes(audioAttributes)
      .setMaxStreams(2)
      .build();
      }else{
      soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC,0);
      }









      share|improve this question
















      Because i had some problem playing small .wav file with MediaPlayer i switched to SoundPool. So far it seems it performing better than MediaPlayer but the problem i am having is the sound level, which should be 0.5 of system sound level.



      i tried with



      soundPool.play(currentSoundId, 0.5f, 0.5f, 1, 0, 1);


      and it was still at the same sound level, i also tried with



      int streamId = soundPool.play(currentSoundId, 1, 1, 1, 0, 1);
      soundPool.setVolume(streamId, 0.5f, 0.5f);


      and it was same level, any idea how to force to play it at specific volume? Its weird because it seems its not accepting any floats for sound i put in.



      EDIT:



      i initialize with following constructor



      if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){

      audioAttributes = new AudioAttributes.Builder()
      .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
      .setUsage(AudioAttributes.USAGE_GAME)
      .build();

      soundPool = new SoundPool.Builder()
      .setAudioAttributes(audioAttributes)
      .setMaxStreams(2)
      .build();
      }else{
      soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC,0);
      }






      android soundpool






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 11:27







      HyperX

















      asked Nov 13 '18 at 10:00









      HyperXHyperX

      3932926




      3932926
























          2 Answers
          2






          active

          oldest

          votes


















          0














          You should start using ExoPlayer, it has more rigid API then MediaPlayer and SoundPool
          You can find it here, ExoPlayer.



          It has setVolume(float) api
          See more here






          share|improve this answer
























          • ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.

            – HyperX
            Nov 13 '18 at 11:05



















          -1














          Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
          If Builder using, what AudioAttributes passed into initialization ?






          share|improve this answer
























          • Using both updated my question with my constructor

            – HyperX
            Nov 13 '18 at 11:27













          • Which Android model and Android version using for testing ?

            – Onix
            Nov 13 '18 at 11:32











          • This does not answer the question.

            – greeble31
            Nov 13 '18 at 20:22











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278396%2fsound-pool-volume-level%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You should start using ExoPlayer, it has more rigid API then MediaPlayer and SoundPool
          You can find it here, ExoPlayer.



          It has setVolume(float) api
          See more here






          share|improve this answer
























          • ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.

            – HyperX
            Nov 13 '18 at 11:05
















          0














          You should start using ExoPlayer, it has more rigid API then MediaPlayer and SoundPool
          You can find it here, ExoPlayer.



          It has setVolume(float) api
          See more here






          share|improve this answer
























          • ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.

            – HyperX
            Nov 13 '18 at 11:05














          0












          0








          0







          You should start using ExoPlayer, it has more rigid API then MediaPlayer and SoundPool
          You can find it here, ExoPlayer.



          It has setVolume(float) api
          See more here






          share|improve this answer













          You should start using ExoPlayer, it has more rigid API then MediaPlayer and SoundPool
          You can find it here, ExoPlayer.



          It has setVolume(float) api
          See more here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 10:40









          Haroun HajemHaroun Hajem

          19519




          19519













          • ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.

            – HyperX
            Nov 13 '18 at 11:05



















          • ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.

            – HyperX
            Nov 13 '18 at 11:05

















          ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.

          – HyperX
          Nov 13 '18 at 11:05





          ExoPlayer is too much for what i need, because i only need to trigger sound when clicking on button.

          – HyperX
          Nov 13 '18 at 11:05













          -1














          Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
          If Builder using, what AudioAttributes passed into initialization ?






          share|improve this answer
























          • Using both updated my question with my constructor

            – HyperX
            Nov 13 '18 at 11:27













          • Which Android model and Android version using for testing ?

            – Onix
            Nov 13 '18 at 11:32











          • This does not answer the question.

            – greeble31
            Nov 13 '18 at 20:22
















          -1














          Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
          If Builder using, what AudioAttributes passed into initialization ?






          share|improve this answer
























          • Using both updated my question with my constructor

            – HyperX
            Nov 13 '18 at 11:27













          • Which Android model and Android version using for testing ?

            – Onix
            Nov 13 '18 at 11:32











          • This does not answer the question.

            – greeble31
            Nov 13 '18 at 20:22














          -1












          -1








          -1







          Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
          If Builder using, what AudioAttributes passed into initialization ?






          share|improve this answer













          Is you are using old SoundPool constructor with AudioManager.STREAM_MUSIC stream or more relevant SoundPool.Builder ?
          If Builder using, what AudioAttributes passed into initialization ?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 11:23









          OnixOnix

          4378




          4378













          • Using both updated my question with my constructor

            – HyperX
            Nov 13 '18 at 11:27













          • Which Android model and Android version using for testing ?

            – Onix
            Nov 13 '18 at 11:32











          • This does not answer the question.

            – greeble31
            Nov 13 '18 at 20:22



















          • Using both updated my question with my constructor

            – HyperX
            Nov 13 '18 at 11:27













          • Which Android model and Android version using for testing ?

            – Onix
            Nov 13 '18 at 11:32











          • This does not answer the question.

            – greeble31
            Nov 13 '18 at 20:22

















          Using both updated my question with my constructor

          – HyperX
          Nov 13 '18 at 11:27







          Using both updated my question with my constructor

          – HyperX
          Nov 13 '18 at 11:27















          Which Android model and Android version using for testing ?

          – Onix
          Nov 13 '18 at 11:32





          Which Android model and Android version using for testing ?

          – Onix
          Nov 13 '18 at 11:32













          This does not answer the question.

          – greeble31
          Nov 13 '18 at 20:22





          This does not answer the question.

          – greeble31
          Nov 13 '18 at 20:22


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278396%2fsound-pool-volume-level%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues