How to manipulate audio channels volume with Audio

2019-06-21 20:16发布

I'm trying to reproduce a mono wav file over just one of the stereo channels (speakers) that my smartphone has. I used to control this with

AudioTrack.setStereoVolume (float leftGain, float rightGain)

by setting one of these gains to zero. Reviewing an old code I got a deprecated method warning and after checking Android SDK documentation I've found it is now done by :

public int setVolume (float gain)

Added in API level 21. This API is preferred over setStereoVolume(float, float), as it more gracefully scales down to mono, and up to multi-channel content beyond stereo.

My questions are:

  1. How would I control the channels volume individually so that only one channel reproduces at a given time now that I'm supposed to control both channels at the same time with the new version of the method?
  2. Is there a way to check through Android API if a certain device has stereo or mono speakers?
  3. Is there another way to reproduce mono audio through a single speaker only?

0条回答
登录 后发表回答