lovr.audio
EditThe lovr.audio
module is responsible for playing sound effects and music. To play a sound, create a Source
object and call Source:play
on it. Currently ogg, wav, and mp3 audio formats are supported.
Sources
Sources are objects that represent a single sound instance.
lovr.audio.newSource | Create a new Source. |
Listener
The listener is a virtual object in 3D space that "hears" all the sounds that are playing. It can be positioned and oriented in 3D space, which controls how Sources in the world are heard. Usually this would be locked to the headset pose.
lovr.audio.getAbsorption | Get the absorption coefficients. |
lovr.audio.getOrientation | Get the orientation of the listener. |
lovr.audio.getPose | Get the pose of the listener. |
lovr.audio.getPosition | Get the position of the listener. |
lovr.audio.getSpatializer | Get the name of the active spatializer |
lovr.audio.getVolume | Get the master volume. |
lovr.audio.setAbsorption | Set the absorption coefficients. |
lovr.audio.setGeometry | Set the geometry for audio effects. |
lovr.audio.setOrientation | Set the orientation of the listener. |
lovr.audio.setPose | Set the pose of the listener. |
lovr.audio.setPosition | Set the position of the listener. |
lovr.audio.setVolume | Set the master volume. |
Devices
It's possible to list the available audio devices on the system, and pick a specific device to use for either playback or capture. Devices can also be manually started and stopped. Other useful features of lovr.audio.setDevice
include the ability to stream all audio data to a custom sink and the option to create a device in exclusive mode for higher performance. By default, the default playback device is automatically initialized and started, but this can be configured using lovr.conf
.
lovr.audio.getDevice | Get the current audio device. |
lovr.audio.getDevices | Get a list of audio devices. |
lovr.audio.getSampleRate | Get the playback device sample rate. |
lovr.audio.isStarted | Check if an audio device is started. |
lovr.audio.setDevice | Switch audio devices. |
lovr.audio.start | Start an audio device. |
lovr.audio.stop | Stop an audio device. |