---
title: "add(_:withObserver:)"
framework: soundanalysis
role: symbol
role_heading: Instance Method
path: "soundanalysis/snaudiostreamanalyzer/add(_:withobserver:)"
---

# add(_:withObserver:)

Adds a new analysis request to the audio stream analyzer.

## Declaration

```swift
func add(_ request: any SNRequest, withObserver observer: any SNResultsObserving) throws
```

## Parameters

- `request`: A sound analysis request.
- `observer`: An doc://com.apple.soundanalysis/documentation/SoundAnalysis/SNResultsObserving instance that receives the analyzer’s results. The analyzer maintains a weak reference to the observer.

## Mentioned in

Classifying Sounds in an Audio Stream

## Discussion

Discussion You can add requests to an analyzer that’s actively analyzing an audio stream. The analyzer throws an error (Swift) or returns NO (Objective-C) if it can’t accept the new request, such as a request with an audio format that doesn’t match the analyzer’s.

## See Also

### Managing Requests

- [SNRequest](soundanalysis/snrequest.md)
- [SNResultsObserving](soundanalysis/snresultsobserving.md)
- [remove(_:)](soundanalysis/snaudiostreamanalyzer/remove(_:).md)
- [removeAllRequests()](soundanalysis/snaudiostreamanalyzer/removeallrequests().md)
