Spatializer | Android Developers
source link: https://developer.android.com/reference/android/media/Spatializer
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
- Android API Reference
- Overview
- Android Platform
- Packages
- API level
- Class Index
- Package Index
- android
- android.accessibilityservice
- android.accounts
- android.animation
- android.annotation
- android.app
- android.app.admin
- android.app.appsearch
- android.app.appsearch.exceptions
- android.app.assist
- android.app.backup
- android.app.blob
- android.app.job
- android.app.people
- android.app.role
- android.app.slice
- android.app.usage
- android.appwidget
- android.bluetooth
- android.bluetooth.le
- android.companion
- android.content
- android.content.pm
- android.content.pm.verify.domain
- android.content.res
- android.content.res.loader
- android.database
- android.database.sqlite
- android.drm
- android.gesture
- android.graphics
- android.graphics.drawable
- android.graphics.drawable.shapes
- android.graphics.fonts
- android.graphics.pdf
- android.graphics.text
- android.hardware
- android.hardware.biometrics
- android.hardware.camera2
- android.hardware.camera2.params
- android.hardware.display
- android.hardware.fingerprint
- android.hardware.input
- android.hardware.lights
- android.hardware.usb
- android.icu.lang
- android.icu.math
- android.icu.number
- android.icu.text
- android.icu.util
- android.inputmethodservice
- android.location
- android.location.provider
- android.media
- android.media.audiofx
- android.media.browse
- android.media.effect
- android.media.metrics
- android.media.midi
- android.media.projection
- android.media.session
- android.media.tv
- android.mtp
- android.net
- android.net.eap
- android.net.http
- android.net.ipsec.ike
- android.net.ipsec.ike.exceptions
- android.net.nsd
- android.net.rtp
- android.net.sip
- android.net.ssl
- android.net.vcn
- android.net.wifi
- android.net.wifi.aware
- android.net.wifi.hotspot2
- android.net.wifi.hotspot2.omadm
- android.net.wifi.hotspot2.pps
- android.net.wifi.p2p
- android.net.wifi.p2p.nsd
- android.net.wifi.rtt
- android.nfc
- android.nfc.cardemulation
- android.nfc.tech
- android.opengl
- android.os
- android.os.health
- android.os.storage
- android.os.strictmode
- android.preference
- android.print
- android.print.pdf
- android.printservice
- android.provider
- android.renderscript
- android.sax
- android.se.omapi
- android.security
- android.security.identity
- android.security.keystore
- android.service.autofill
- android.service.carrier
- android.service.chooser
- android.service.controls
- android.service.controls.actions
- android.service.controls.templates
- android.service.dreams
- android.service.media
- android.service.notification
- android.service.quickaccesswallet
- android.service.quicksettings
- android.service.restrictions
- android.service.textservice
- android.service.voice
- android.service.vr
- android.service.wallpaper
- android.speech
- android.speech.tts
- android.system
- android.telecom
- android.telephony
- android.telephony.cdma
- android.telephony.data
- android.telephony.emergency
- android.telephony.euicc
- android.telephony.gsm
- android.telephony.ims
- android.telephony.ims.feature
- android.telephony.mbms
- android.test
- android.test.mock
- android.test.suitebuilder
- android.test.suitebuilder.annotation
- android.text
- android.text.format
- android.text.method
- android.text.style
- android.text.util
- android.transition
- android.util
- android.util.proto
- android.view
- android.view.accessibility
- android.view.animation
- android.view.autofill
- android.view.contentcapture
- android.view.displayhash
- android.view.inputmethod
- android.view.inspector
- android.view.textclassifier
- android.view.textservice
- android.view.translation
- android.webkit
- android.widget
- android.widget.inline
- android.window
- dalvik.annotation
- dalvik.bytecode
- dalvik.system
- java.awt.font
- java.beans
- java.io
- java.lang
- java.lang.annotation
- java.lang.invoke
- java.lang.ref
- java.lang.reflect
- java.math
- java.net
- java.nio
- java.nio.channels
- java.nio.channels.spi
- java.nio.charset
- java.nio.charset.spi
- java.nio.file
- java.nio.file.attribute
- java.nio.file.spi
- java.security
- java.security.acl
- java.security.cert
- java.security.interfaces
- java.security.spec
- java.sql
- java.text
- java.time
- java.time.chrono
- java.time.format
- java.time.temporal
- java.time.zone
- java.util
- java.util.concurrent
- java.util.concurrent.atomic
- java.util.concurrent.locks
- java.util.function
- java.util.jar
- java.util.logging
- java.util.prefs
- java.util.regex
- java.util.stream
- java.util.zip
- javax.crypto
- javax.crypto.interfaces
- javax.crypto.spec
- javax.microedition.khronos.egl
- javax.microedition.khronos.opengles
- javax.net
- javax.net.ssl
- javax.security.auth
- javax.security.auth.callback
- javax.security.auth.login
- javax.security.auth.x500
- javax.security.cert
- javax.sql
- javax.xml
- javax.xml.datatype
- javax.xml.namespace
- javax.xml.parsers
- javax.xml.transform
- javax.xml.transform.dom
- javax.xml.transform.sax
- javax.xml.transform.stream
- javax.xml.validation
- javax.xml.xpath
- junit.framework
- junit.runner
- org.apache.http.conn
- org.apache.http.conn.scheme
- org.apache.http.conn.ssl
- org.apache.http.params
- org.json
- org.w3c.dom
- org.w3c.dom.ls
- org.xml.sax
- org.xml.sax.ext
- org.xml.sax.helpers
- org.xmlpull.v1
- org.xmlpull.v1.sax2
Spatializer
public
class
Spatializer
extends Object
Spatializer provides access to querying capabilities and behavior of sound spatialization
on the device.
Sound spatialization simulates sounds originating around the listener as if they were coming
from virtual speakers placed around the listener.
Support for spatialization is optional, use AudioManager#getSpatializer()
to obtain an
instance of this class if the feature is supported.
Summary
Nested classes
interface
Spatializer.OnSpatializerStateChangedListener
An interface to be notified of changes to the state of the spatializer effect.
Constants
int
SPATIALIZER_IMMERSIVE_LEVEL_MULTICHANNEL
Constant indicating the Spatializer
on this device supports multichannel
spatialization.
int
SPATIALIZER_IMMERSIVE_LEVEL_NONE
Constant indicating there are no spatialization capabilities supported on this device.
int
SPATIALIZER_IMMERSIVE_LEVEL_OTHER
Constant indicating the Spatializer
on this device supports a spatialization
mode that differs from the ones available at this SDK level.
Public methods
void
addOnSpatializerStateChangedListener(Executor executor, Spatializer.OnSpatializerStateChangedListener listener)
Adds a listener to be notified of changes to the enabled state of the
Spatializer
.
boolean
canBeSpatialized(AudioAttributes attributes, AudioFormat format)
Returns whether audio of the given AudioFormat
, played with the given
AudioAttributes
can be spatialized.
int
getImmersiveAudioLevel()
Return the level of support for the spatialization feature on this device.
boolean
isAvailable()
Returns whether spatialization is available.
boolean
isEnabled()
Returns whether spatialization is enabled or not.
void
removeOnSpatializerStateChangedListener(Spatializer.OnSpatializerStateChangedListener listener)
Removes a previously added listener for changes to the enabled state of the
Spatializer
.
Inherited methods
From class
java.lang.Object
Constants
SPATIALIZER_IMMERSIVE_LEVEL_MULTICHANNEL
public static final int SPATIALIZER_IMMERSIVE_LEVEL_MULTICHANNEL
Constant indicating the Spatializer
on this device supports multichannel
spatialization.
See also:
Constant Value: 1 (0x00000001)
SPATIALIZER_IMMERSIVE_LEVEL_NONE
public static final int SPATIALIZER_IMMERSIVE_LEVEL_NONE
Constant indicating there are no spatialization capabilities supported on this device.
See also:
Constant Value: 0 (0x00000000)
SPATIALIZER_IMMERSIVE_LEVEL_OTHER
public static final int SPATIALIZER_IMMERSIVE_LEVEL_OTHER
Constant indicating the Spatializer
on this device supports a spatialization
mode that differs from the ones available at this SDK level.
See also:
Constant Value: -1 (0xffffffff)
Public methods
addOnSpatializerStateChangedListener
public void addOnSpatializerStateChangedListener (Executor executor, Spatializer.OnSpatializerStateChangedListener listener)
Adds a listener to be notified of changes to the enabled state of the
Spatializer
.
executor
Executor
: the Executor
handling the callback
This value cannot be null
.
Callback and listener events are dispatched through this
Executor
, providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor()
.
To dispatch events through a shared thread pool, you can use
AsyncTask#THREAD_POOL_EXECUTOR
.
listener
Spatializer.OnSpatializerStateChangedListener
: the listener to receive enabled state updates
This value cannot be null
.
See also:
canBeSpatialized
public boolean canBeSpatialized (AudioAttributes attributes, AudioFormat format)
Returns whether audio of the given AudioFormat
, played with the given
AudioAttributes
can be spatialized.
Note that the result reflects the capabilities of the device and may change when
audio accessories are connected/disconnected (e.g. wired headphones plugged in or not).
The result is independent from whether spatialization processing is enabled or not.
attributes
AudioAttributes
: the AudioAttributes
of the content as used for playback
This value cannot be null
.
format
AudioFormat
: the AudioFormat
of the content as used for playback
This value cannot be null
.
boolean
true
if the device is capable of spatializing the combination of audio format
and attributes, false
otherwise.
getImmersiveAudioLevel
public int getImmersiveAudioLevel ()
Return the level of support for the spatialization feature on this device.
This level of support is independent of whether the Spatializer
is currently
enabled or available and will not change over time.
isAvailable
public boolean isAvailable ()
Returns whether spatialization is available.
Reasons for spatialization being unavailable include situations where audio output is
incompatible with sound spatialization, such as playback on a monophonic speaker.
Note that spatialization can be available, but disabled by the user, in which case this
method would still return true
, whereas isEnabled()
would return false
.
boolean
true
if the spatializer effect is available and capable
of processing the audio for the current configuration of the device,
false
otherwise.
See also:
isEnabled
public boolean isEnabled ()
Returns whether spatialization is enabled or not.
A false value can originate for instance from the user electing to
disable the feature.
Note that this state reflects a platform-wide state of the "desire" to use spatialization,
but availability of the audio processing is still dictated by the compatibility between
the effect and the hardware configuration, as indicated by isAvailable()
.
boolean
true
if spatialization is enabled
See also:
removeOnSpatializerStateChangedListener
public void removeOnSpatializerStateChangedListener (Spatializer.OnSpatializerStateChangedListener listener)
Removes a previously added listener for changes to the enabled state of the
Spatializer
.
listener
Spatializer.OnSpatializerStateChangedListener
: the listener to receive enabled state updates
This value cannot be null
.
See also:
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-10-27 UTC.
-
Follow @AndroidDev on Twitter
-
Check out Android Developers on YouTube
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK