---
title: "CEL 规则示例"
description: "高采样率 PCM、DSD DoP、Exclusive 默认目标和指定输出端点的 CEL 规则示例。"
---

> Documentation Index
> Fetch the complete documentation index at: https://treble.harekaze.win/llms.txt
> Use this file to discover all available pages before exploring further.

# CEL 规则示例

## 将高于 48 kHz 的 PCM 转为 24-bit / 88.2 kHz

```text
when:
!source.is_dsd && source.sample_rate > 48000

then:
{'mode':'pcm','rate':88200,'bits':24,'channels':2,'quality':'High'}
```

## 对 DSD64 / DSD128 使用 DoP

```text
when:
source.is_dsd && source.sample_rate in [DSD64, DSD128] && device.dsd_capable

then:
{'mode':'dop'}
```

`device.dsd_capable` 只是能力假设，不代表已向驱动或 DAC 实测确认；实际打开输出时仍会验证目标格式。

## Exclusive 模式下保留默认目标

```text
when:
output.mode == 'exclusive' && playback.dsd_mode != 'pcm'

then:
{}
```

## 只匹配某个输出端点

```text
when:
device.id.contains('USB') && device.exclusive

then:
{'mode':'pcm','rate':96000,'bits':24,'channels':2}
```

这些示例仍需通过实际设备协商。字段、可用值和约束见[CEL 上下文与动作](https://treble.harekaze.win/reference/cel-context/)；常量与语法见[CEL 语法与常量](https://treble.harekaze.win/reference/cel/)。

Source: https://treble.harekaze.win/guides/cel-examples/index.mdx
