Use device microphones and speakers

Updated: Oct 12, 2026

Overview

Device audio uses two Bluetooth profiles:
ProfileDirectionQualityUse case
A2DP (Advanced Audio Distribution Profile)
Output only
High quality (44.1/48 kHz stereo)
Music, media playback, TTS
HFP (Hands-Free Profile)
Bidirectional
Mono voice, 16 kHz or 8 kHz (negotiated by the phone and glasses)
Voice capture from the glasses microphone
In HFP mode, the wearable’s microphones use beamforming to isolate the wearer’s voice, which significantly reduces the volume of ambient sounds and other speakers. This is expected behavior, not a bug.
A camera stream can also deliver audio from the glasses microphones in-band with video, without using either Bluetooth profile for capture. See Capture audio while streaming from the camera. In this case, audio is not beamformed down to the wearer’s voice, so ambient sounds and noise are present at their natural levels.

Use this page with AI

Copy this prompt into your AI coding tool to add or debug Device Access Toolkit audio routing:

Use https://wearables.developer.meta.com/docs/develop/dat/microphones-and-speakers/, then use the Wearables MCP endpoint https://mcp.developer.meta.com/wearables to call search_dat_docs for current Device Access Toolkit microphone and speaker guidance. Inspect my audio code first, then make the smallest fix for the selected profile: A2DP for output or HFP for microphone input. Preserve the ordering constraints with Device Access Toolkit camera streaming, verify route selection, and run the relevant local checks.
To add in-stream audio capture instead of an HFP route, use this prompt:
Use https://wearables.developer.meta.com/docs/develop/dat/microphones-and-speakers/, then use the Wearables MCP endpoint https://mcp.developer.meta.com/wearables to call search_dat_docs for current Device Access Toolkit in-stream audio guidance. Inspect my streaming code first, then add the smallest working slice: set an audio codec on the stream configuration before starting the stream, consume audio frames alongside video, and align them using each frame's presentation timestamp. Pick the lowest sample rate my feature needs, handle the paused state as a gap rather than an end, keep per-frame work small, and release listeners during teardown.

Choose a profile

Use A2DP when you only need to play audio to the glasses, since it provides significantly higher fidelity than HFP. Use HFP when you need microphone input from the wearer. The two profiles are mutually exclusive: activating HFP switches the glasses away from A2DP, and audio output drops to mono voice quality (16 kHz or 8 kHz) for the duration of the session.

Capture audio while streaming from the camera

Beta: In-stream audio capture is available in the development and beta release channels only. It is not supported in production release channels, and the API may change before general availability.
A camera stream can deliver audio from the glasses microphones alongside video, without putting the glasses into HFP for capture. Because this path does not use HFP, output stays on A2DP, so you do not trade output quality for microphone input the way the two profiles otherwise force you to. Use it when you want audio that matches the video you are already receiving.
Audio is off by default, and is enabled when you set an audio codec on the stream configuration. Your app receives uncompressed 16-bit PCM at the sample rate and channel count you choose when you configure the codec. To save bandwidth on the link to the phone and battery on the glasses, pick the lowest rate and channel count that satisfy your feature.
Sample rateTypical use
16,000 Hz
Speech and voice, including passing audio to a transcription service.
44,100 Hz
General-purpose recording.
48,000 Hz
Highest fidelity.
The provided audio frames arrive with a timestamp that can be used for synchronization.

Android

Set an audio codec on the stream configuration, then collect audioStream alongside the video stream.
import com.meta.wearable.dat.camera.types.AudioCodec
import com.meta.wearable.dat.camera.types.AudioSampleRate
import com.meta.wearable.dat.camera.types.StreamConfiguration
import com.meta.wearable.dat.camera.types.VideoQuality

val configuration =
  StreamConfiguration(
    audioCodec =
      AudioCodec.PCM(
        sampleRate = AudioSampleRate.RATE_16000,
        numberOfChannels = 1,
      ),
    videoQuality = VideoQuality.MEDIUM,
    frameRate = 24
  )
Leaving audioCodec unset, or setting it to null, streams video only.
scope.launch {
  stream.audioStream.collect { frame ->
    // frame.buffer holds the PCM bytes; presentationTimeUs is in microseconds.
    handleAudio(frame.buffer, frame.presentationTimeUs)
  }
}

stream.start()
You can watch StreamState to know when audio data will be started or stopped.

iOS

Use the StreamConfiguration initializer that takes an audio codec, then listen on audioFramePublisher.
import MWDATCamera

let configuration = StreamConfiguration(
    videoCodec: .raw,
    audioCodec: .pcm(sampleRate: .rate16000, numberOfChannels: 1),
    resolution: .medium,
    frameRate: 24
)
The initializers that do not take an audio codec will stream video only.
let audioToken = stream.audioFramePublisher.listen { frame in
    // frame.pcmBuffer holds Float32 samples; presentationTimeStamp aligns with video.
    handleAudio(frame.pcmBuffer, frame.presentationTimeStamp)
}

stream.start()
Retain the token for as long as you want frames and release it during teardown.

Android

HFP (bidirectional) — Capture audio from the glasses microphone

Select the glasses as the communication device, then switch the audio manager into communication mode.
import android.content.Context
import android.media.AudioDeviceInfo
import android.media.AudioManager
import android.os.Build

private fun routeAudioToBluetooth(context: Context): Boolean {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
    return false
  }

  val audioManager = context.getSystemService(AudioManager::class.java)
  val bluetoothDevice =
    audioManager.availableCommunicationDevices.firstOrNull { device ->
      device.type == AudioDeviceInfo.TYPE_BLUETOOTH_SCO
    } ?: return false

  audioManager.mode = AudioManager.MODE_IN_COMMUNICATION
  return audioManager.setCommunicationDevice(bluetoothDevice)
}

iOS

A2DP (output only) — Play audio to the glasses

A2DP is the high-quality Bluetooth media route on iOS. Configure your app for playback, and the system can route output to paired glasses automatically.
import AVFoundation

let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(.playback, mode: .default, options: [])
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
Use AVAudioPlayer, AVSpeechSynthesizer, or any standard audio API to play audio, then verify the active route before assuming output is on the glasses.
let player = try AVAudioPlayer(contentsOf: audioFileURL)
player.play()

Verify the route

let hasA2DPOutput = audioSession.currentRoute.outputs.contains {
    $0.portType == .bluetoothA2DP
}

HFP (bidirectional) — Capture audio from the glasses microphone

Use .allowBluetoothHFP for microphone capture; A2DP output options do not provide microphone access. If your SDK only exposes the older .allowBluetooth option, use that option for HFP.
Ordering constraint: When using HFP with a Device Access Toolkit camera stream, the HFP route must be settled before the stream starts. The correct ordering is:
  1. Configure and start the HFP microphone. Wait for the route to settle.
  2. Start the Device Access Toolkit camera stream.
You can add the camera stream to the session before or after the HFP setup. Starting the Device Access Toolkit stream before HFP is ready can cause the audio route to fail silently.

Configure the audio session

import AVFoundation

// Request microphone permission
let granted = await withCheckedContinuation { continuation in
    AVAudioApplication.requestRecordPermission { granted in
        continuation.resume(returning: granted)
    }
}
guard granted else { return }

// Configure the session for HFP
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetoothHFP])
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)

Select glasses as the preferred input

The system may have multiple Bluetooth inputs available. Find the HFP port that corresponds to the glasses and set it as the preferred input.
if let hfpInput = audioSession.availableInputs?.first(where: { $0.portType == .bluetoothHFP }) {
    try audioSession.setPreferredInput(hfpInput)
}

Capture audio with AVAudioEngine

Install a tap on the audio engine’s input node to receive raw PCM buffers from the glasses microphone.
let audioEngine = AVAudioEngine()
let inputNode = audioEngine.inputNode
let format = inputNode.outputFormat(forBus: 0)

inputNode.installTap(onBus: 0, bufferSize: 1024, format: format) { buffer, _ in
    // Forward the buffer to your audio pipeline (e.g., LiveKit, a file writer, etc.)
    handleAudioBuffer(buffer)
}

audioEngine.prepare()
try audioEngine.start()
If the route changes, the HFP sample rate can change and the engine stops. Observe AVAudioEngineConfigurationChange, then reinstall the tap with the new outputFormat(forBus: 0) and restart the engine.

Play audio over HFP while capturing

Use HFP when your app needs to capture the glasses microphone and play audio through the glasses at the same time. HFP playback uses mono voice quality; if your app only needs playback, use A2DP for higher-quality audio.
To play audio while capturing, attach the player to the same AVAudioEngine before starting it:
let file = try AVAudioFile(forReading: audioFileURL)
let player = AVAudioPlayerNode()
audioEngine.attach(player)
audioEngine.connect(player, to: audioEngine.mainMixerNode, format: file.processingFormat)

player.scheduleFile(file, at: nil)
player.play()
After the route settles, verify that audioSession.currentRoute.outputs contains a .bluetoothHFP port before relying on playback through the glasses.

Wait for the route to settle

After starting the audio engine, the Bluetooth HFP route needs time to stabilize. After waiting, verify the route is active before starting the Device Access Toolkit stream.
// Allow the Bluetooth HFP route to settle
try await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC)

// Verify HFP is actually routed
let hasHFPRoute = audioSession.currentRoute.inputs.contains { $0.portType == .bluetoothHFP }
guard hasHFPRoute else {
    audioEngine.stop()
    try audioSession.setActive(false, options: .notifyOthersOnDeactivation)
    throw MyError.hfpRouteUnavailable
}

Teardown

When you’re done capturing, call removeTap(onBus:) to stop receiving input buffers, then deactivate the session. If you need to return to A2DP playback, reconfigure the audio session with .playback category after deactivation.
inputNode.removeTap(onBus: 0)
audioEngine.stop()
try audioSession.setActive(false, options: .notifyOthersOnDeactivation)

Next steps