问题
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:
- 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?
- Is there a way to check through Android API if a certain device has stereo or mono speakers?
- Is there another way to reproduce mono audio through a single speaker only?
来源:https://stackoverflow.com/questions/36904903/how-to-manipulate-audio-channels-volume-with-audiotrack-setvolume-after-api-21