---
title: "withAUAudioUnit(_:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudionode/withauaudiounit(_:)"
---

# withAUAudioUnit(_:)

Provides scoped access to the node’s AUAudioUnit

## Declaration

```swift
func withAUAudioUnit<R, E>(_ body: (borrowing AUAudioUnit) throws(E) -> R) throws(E) -> R where E : Error
```

## Parameters

- `body`: A closure that receives the AUAudioUnit instance

## Return Value

Return Value The value returned by the closure

## Discussion

Discussion This method provides thread-safe, scoped access to the underlying AUAudioUnit. The audio unit reference is only valid within the closure and must not be retained or accessed outside of it. note: Rethrows any error thrown by the closure

## See Also

### Getting Audio Node Properties

- [auAudioUnit](avfaudio/avaudionode/auaudiounit-1gu8g.md)
- [latency](avfaudio/avaudionode/latency.md)
- [outputPresentationLatency](avfaudio/avaudionode/outputpresentationlatency.md)
