2

I did not manage to find solution what to use instead of deprecated AudioTrack's method setStereoVolume.

There is info about this in reference, but I am not sure how to use setVolume for muting left/right channel.

This method was deprecated in API level 21. Applications should use setVolume(float) instead, as it more gracefully scales down to mono, and up to multi-channel content beyond stereo.

I need to play only one channel at a time, but I cannot find appropriate solution. I've already checked solution with LRLRLR samples, and playing one channel by setting every 2nd sample to 0, but did not help.

Thank you.

vanste25
  • 1,754
  • 14
  • 39
  • You should check whether you are setting the output configuration to 2 channel mode (`CHANNEL_OUT_STEREO`). If the output uses two separate channels then resetting samples in one of them *should* result in muting it. – Mikhail Naganov May 18 '16 at 21:18
  • Also, check that the output device does actually have 2 channels. Have you tried using headphones for example? – Mikhail Naganov May 18 '16 at 21:24
  • Yes, I use CHANNEL_OUT_STEREO. But how to reset samples in one channel? I have tried and currently, have desired behavior by using setStereoVolume, but it is deprecated, so I want to avoid usage of that method. – vanste25 May 18 '16 at 21:37
  • I ve tried this, but I dont hear nothing http://stackoverflow.com/a/27056765/1374065 – vanste25 May 18 '16 at 21:56
  • I would suggest revealing relevant fragments of your code. The solution you are referencing suggests correct approach, but that's in case if you use uncompressed PCM data. If you are playing a compressed file, e.g. MP3 then it will not work. – Mikhail Naganov May 19 '16 at 20:53
  • I use PCM to play sounds at different frequencies. One tone, it is not MP3 or some other compressed format. – vanste25 May 20 '16 at 07:23

0 Answers0