> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stmlink.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> 对外开放的服务端接口有两组前缀，都用同一套鉴权：`/server/v1/...`（SRTC 与 SMeeting 的主接口）和 `/stm/srvapi/v1/...`（SMeeting 的用户体系，服务端极简对接会用到）。鉴权是 app_id + nonce + timestamp + signature 四个请求头，用 app_key 做 HMAC-SHA256 签名，只能从业务方自己的后端调用。除这两组前缀外的接口均为内部接口，不要建议客户调用。 Public server APIs use two path prefixes with the same authentication: `/server/v1/...` (the main APIs of both SRTC and SMeeting) and `/stm/srvapi/v1/...` (the SMeeting user system, used by server-side low-code integration). Authenticate with four request headers, app_id + nonce + timestamp + signature, where signature is HMAC-SHA256 keyed with app_key; call these APIs only from the customer's own backend. Any other path is internal: never suggest calling it.
> app_key 是服务端密钥，绝不能出现在客户端代码、前端配置或移动 App 里。客户端加入频道用的 token 必须由业务方后端签发后下发（SRTC 走 `/server/v1/channel/grant`，SMeeting 走 `/stm/srvapi/v1/member/grant`）。 app_key is a server-side secret and must never appear in client code, frontend config, or a mobile app. The token a client uses to join must be issued by the customer's backend and passed down to the client (SRTC: `/server/v1/channel/grant`; SMeeting: `/stm/srvapi/v1/member/grant`).
> SRTC 与 SMeeting 是上下两层不同的产品，术语不通用：SRTC 是音视频底座，说「频道 channel」「加入 / 退出」；SMeeting 建在 SRTC 之上，说「房间 room」「会议 meeting」「进入 / 退出」。回答时按用户所在的层用对应术语，不要把「房间」「会议」安到 SRTC 的接口上，也不要用「频道」「加入 / 离开」描述 SMeeting 的概念（接口标识符原样保留）。 SRTC and SMeeting are two separate layers with different terminology. SRTC is the audio/video foundation: it has channels, and users join and leave a channel. SMeeting is built on top of SRTC: it has rooms and meetings, and members enter and exit a meeting. Answer in the terms of the layer the user is working with: never apply "room" or "meeting" to SRTC APIs, and never describe SMeeting concepts in prose with "channel", "join", or "leave" (API identifiers such as `force_join` keep their literal names).
> 同一能力在各端 SDK 里的包名、类名、方法名并不相同。写示例代码时请使用文档中该端自己的 API，不要把一个端的写法套到另一个端上。苹果平台每个产品都有两套 SDK（Swift 原生与 Objective-C），两套 API 不能混用。 Package, class, and method names differ between platform SDKs for the same capability. In sample code, use the API documented for that platform; never carry one platform's code over to another. On Apple platforms each product ships two SDKs (native Swift and Objective-C) whose APIs must not be mixed.

# AI noise suppression (DeepFilterNet)

> Enable AI noise suppression with adjustable strength on the microphone with the SRTCDeepFilterNet plugin: integration, on/off and strength control, handling unsupported devices and CPU overload, and how a custom capture processor declares that built-in noise suppression should be off.

### Overview

`SRTCDeepFilterNet` is an AI noise suppression plugin based on [DeepFilterNet3](https://github.com/Rikorose/DeepFilterNet). It uses the same algorithm, model, and parameters as the Web [DeepFilterNet noise suppression plugin](https://docs.stmlink.com/en/rtc/web/advanced/deepfilternet.md), so it sounds the same on every platform. It implements the SDK's `AudioProcessor` interface and takes effect once set on `SRTCEngine.audioCaptureProcessor`, with **suppression strength adjustable at runtime** and a **temporary bypass**.

The plugin is an **optional product** in the `srtc-swift-sdk` package, available since `1.8.0` on both iOS and macOS. Apps that don't use AI noise suppression don't need it.

***

### Integration

Add the `SRTCDeepFilterNet` product to the same app target that depends on `SRTC`:

```swift theme={null}
// Package.swift
dependencies: [
    .package(url: "https://github.com/seastart/srtc-swift-sdk.git", from: "1.8.0")
],
targets: [
    .target(
        name: "YourApp",
        dependencies: [
            .product(name: "SRTC", package: "srtc-swift-sdk"),
            .product(name: "SRTCDeepFilterNet", package: "srtc-swift-sdk")
        ]
    )
]
```

In an Xcode project, select `SRTCDeepFilterNet` under `File > Add Package Dependencies...`. The model is built into the plugin; you don't need to copy any extra resources.

> [!WARNING]
>
> Don't add `SRTCDeepFilterNet` to the Broadcast Upload Extension for screen sharing. It is for the app process only.

***

### Usage

```swift theme={null}
import SRTC
import SRTCDeepFilterNet

final class CallViewController: UIViewController {
    let srtc = SRTCEngine()
    /// Must be held by your code: the SDK keeps only a weak reference to the processor
    private var denoiser: DeepFilterNetProcessor?

    func enableDenoise() {
        // 1. Hide the noise suppression switch on unsupported devices
        guard DeepFilterNetProcessor.isSupported else { return }
        do {
            // 2. Create the plugin; strength 0–100, default 50
            let denoiser = try DeepFilterNetProcessor(suppressionLevel: 50)
            // 3. If the CPU can't keep up during a call, the plugin pauses suppression and calls back on the main thread
            denoiser.onOverload = { [weak self] in
                self?.showToast("Device too slow; AI noise suppression paused")
            }
            self.denoiser = denoiser
            // 4. Takes effect as soon as it's set; you can set it before or after joining
            srtc.audioCaptureProcessor = denoiser
        } catch {
            // Device not supported: SRTCError.featureNotSupported (032)
            print("Failed to enable AI noise suppression: \(error)")
        }
    }

    func disableDenoise() {
        srtc.audioCaptureProcessor = nil   // Detach and restore the SDK's default audio processing
        denoiser = nil
    }
}
```

Adjust the strength or bypass temporarily at runtime without detaching:

```swift theme={null}
denoiser?.setSuppressionLevel(80)  // 0–100; higher suppresses more
denoiser?.setEnabled(false)        // Bypass: audio passes through unchanged while the processor stays attached
denoiser?.setEnabled(true)         // Resume suppression and clear a pause caused by CPU overload
```

***

### API

| API | Description |
| - | - |
| `static var isSupported: Bool` | Whether the current device is supported. Check it before enabling, and hide the switch when unsupported |
| `init(suppressionLevel: Int = 50, modelURL: URL? = nil) throws` | Creates the plugin. `suppressionLevel` is the strength, 0–100; `modelURL` is normally omitted so the built-in model is used. Throws `SRTCError.featureNotSupported` on unsupported devices and `SRTCError.invalidArgument` if the model can't be found |
| `setSuppressionLevel(_:)` | Adjusts the strength (0–100) at runtime |
| `setEnabled(_:)` | Turns suppression on or off. With `false`, audio passes through unchanged; `true` resumes suppression and clears a pause caused by CPU overload |
| `var suppressionLevel: Int` | Current strength, read-only |
| `var isEnabled: Bool` | Current on/off state, read-only. An automatic overload pause doesn't change it |
| `var onOverload: (() -> Void)?` | Called when the CPU can't keep up during a call and suppression has been paused automatically. Runs on the main thread, once per pause |

***

### Unsupported devices and CPU overload

AI noise suppression needs a certain amount of CPU power. The SDK handles this in two layers:

* **Before enabling**: a device is unsupported when `isSupported` is `false`, and the initializer throws `SRTCError.featureNotSupported` (low-order code `032`; `103032` on iOS, `105032` on macOS). All current Apple devices are supported, but we still recommend checking before enabling, in line with the other platforms.
* **During a call**: if the device stays overloaded (for example, while running other heavy workloads), the plugin switches to bypass automatically so the call doesn't stutter, and calls `onOverload`. Tell the user something like "Device too slow; noise suppression paused" and let them decide whether to call `setEnabled(true)` to turn it back on.

***

### Notes

* **Your code must hold the plugin instance.** `audioCaptureProcessor` is a weak reference; if you only write `srtc.audioCaptureProcessor = try DeepFilterNetProcessor()`, the instance is released immediately and suppression has no effect.
* **When attached, the SDK turns off WebRTC's built-in software noise suppression** and restores it on detach, so two layers of suppression don't stack and muffle the voice. Echo cancellation and automatic gain control are unaffected.
* **The system's voice processing stays on.** During calls on iOS / macOS, the system's own echo cancellation and noise suppression can't be turned off separately; AI noise suppression runs on top of it. Listen on your target devices before going live.
* The model loads in the background (usually in under 1 second). Until it's loaded, audio passes through unchanged and capture isn't blocked.
* It works only with 48 kHz capture. When capture drops to 8 kHz / 16 kHz (for example, Bluetooth headsets in call mode), it bypasses automatically and resumes when capture returns to 48 kHz.
* There is only one `audioCaptureProcessor`, applied to all channels. To combine it with other processing such as voice changing, chain the calls inside your own processor.
* License: DeepFilterNet itself is Apache-2.0/MIT; verify the license of the model weights yourself before distribution.

***

### Declaring 3A requirements in a custom processor

If your own `AudioProcessor` also needs the built-in processing turned off (for example, when integrating another noise suppression algorithm), additionally conform to `AudioProcessingDeclaring` to declare its requirements for WebRTC's built-in 3A. When it's set as `audioCaptureProcessor`, the SDK applies the declaration, and restores the defaults when the processor is replaced or cleared:

```swift theme={null}
final class MyDenoiser: NSObject, AudioProcessor, AudioProcessingDeclaring {
    // false requires it off; nil leaves the SDK default unchanged
    let audioProcessing = AudioProcessingConstraints(noiseSuppression: false)

    func audioProcessingInitialize(sampleRate sampleRateHz: Int, channels: Int) {}
    func audioProcessingProcess(audioBuffer: AudioBuffer) { /* Process in place */ }
    func audioProcessingRelease() {}
}
```

`AudioProcessingConstraints` has the same meaning as the same-named type in the Web SDK; see [Types](https://docs.stmlink.com/en/rtc/swift/types.md#audioprocessingconstraints) for its fields.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.