add-sfx

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prerequisites

前提条件

Sound effects must first be added to the remotion.media repository. The source of truth is
generate.ts
in that repo. A sound effect must exist there before it can be added to
@remotion/sfx
.
Sound effects must be:
  • WAV format
  • CC0 (Creative Commons 0) licensed
  • Normalized to peak at -3dB
音效必须先添加到remotion.media仓库。该仓库中的
generate.ts
是信息的权威来源。只有在该仓库中存在的音效,才能被添加到
@remotion/sfx
中。
音效必须满足以下要求:
  • WAV格式
  • CC0(知识共享零许可协议)授权
  • 归一化处理,峰值为-3dB

Steps

步骤

1. Add to
remotion.media
repo (must be done first)

1. 先添加到remotion.media仓库(必须优先完成)

In the
remotion-dev/remotion.media
repo:
  1. Add the WAV file to the root of the repo
  2. Add an entry to the
    soundEffects
    array in
    generate.ts
    :
    ts
    {
      fileName: "my-sound.wav",
      attribution:
        "Description by Author -- https://source-url -- License: Creative Commons 0",
    },
  3. Run
    bun generate.ts
    to copy it to
    files/
    and regenerate
    variants.json
  4. Deploy
remotion-dev/remotion.media
仓库中:
  1. 将WAV文件添加到仓库根目录
  2. generate.ts
    soundEffects
    数组中添加一条条目:
    ts
    {
      fileName: "my-sound.wav",
      attribution:
        "Description by Author -- https://source-url -- License: Creative Commons 0",
    },
  3. 运行
    bun generate.ts
    将文件复制到
    files/
    目录并重新生成
    variants.json
  4. 部署

2. Add the export to
packages/sfx/src/index.ts

2. 将导出添加到
packages/sfx/src/index.ts

Use camelCase for the variable name. Avoid JavaScript reserved words (e.g. use
uiSwitch
not
switch
).
ts
export const mySound = 'https://remotion.media/my-sound.wav';
变量名使用小驼峰命名法。避免使用JavaScript保留字(例如,使用
uiSwitch
而非
switch
)。
ts
export const mySound = 'https://remotion.media/my-sound.wav';

3. Create a doc page at
packages/docs/docs/sfx/<name>.mdx

3. 在
packages/docs/docs/sfx/<name>.mdx
创建文档页面

Follow the pattern of existing pages (e.g.
whip.mdx
). Include:
  • Frontmatter with
    image
    ,
    title
    (camelCase export name),
    crumb: '@remotion/sfx'
  • <AvailableFrom>
    tag with the next release version
  • <PlayButton>
    import and usage
  • Description
  • Example code using
    @remotion/media
    's
    <Audio>
    component
  • Value section with the URL in a fenced code block
  • Duration section (fetch the file and use
    afinfo
    on macOS to get duration/format)
  • Attribution section with source link and license
  • See also section linking to related sound effects
遵循现有页面的格式(例如
whip.mdx
),内容应包含:
  • 带有
    image
    title
    (小驼峰导出名称)、
    crumb: '@remotion/sfx'
    的前置元数据
  • 包含下一个发布版本号的
    <AvailableFrom>
    标签
  • <PlayButton>
    的导入与使用示例
  • 描述信息
  • 使用
    @remotion/media
    <Audio>
    组件的示例代码
  • 包含URL的代码块(值部分)
  • 时长部分(获取文件后,在macOS上使用
    afinfo
    获取时长/格式)
  • 包含来源链接和许可证的署名部分
  • 链接到相关音效的“另请参阅”部分

4. Register in sidebar and table of contents

4. 在侧边栏和目录中注册

  • packages/docs/sidebars.ts
    — add
    'sfx/<name>'
    to the
    @remotion/sfx
    category items
  • packages/docs/docs/sfx/table-of-contents.tsx
    — add a
    <TOCItem>
    with a
    <PlayButton size={32}>
  • packages/docs/sidebars.ts
    — 将
    'sfx/<name>'
    添加到
    @remotion/sfx
    分类的项目中
  • packages/docs/docs/sfx/table-of-contents.tsx
    — 添加一个包含
    <PlayButton size={32}>
    <TOCItem>

5. Update the skills rule file

5. 更新技能规则文件

Add the new URL to the list in
packages/skills/skills/remotion/rules/sfx.md
.
packages/skills/skills/remotion/rules/sfx.md
的列表中添加新URL。

6. Build

6. 构建

bash
cd packages/sfx && bun run make
bash
cd packages/sfx && bun run make

Naming conventions

命名规范

File nameExport name
my-sound.wav
mySound
switch.wav
uiSwitch
(reserved word)
page-turn.wav
pageTurn
文件名导出名
my-sound.wav
mySound
switch.wav
uiSwitch
(避免保留字)
page-turn.wav
pageTurn

Version

版本

Use the current version from
packages/core/src/version.ts
. For docs
<AvailableFrom>
, increment the patch version by 1.
使用
packages/core/src/version.ts
中的当前版本。 对于文档中的
<AvailableFrom>
,将补丁版本号加1。