Token导航 LogoToken导航

Agent Skill · 开发

audio-and-sound(音频和声音)

用于辅助音频、音乐、语音转写、语音合成或声音素材处理。它适合让 Agent 生成配乐说明、整理音频流程、调用语音工具或处理播客和视频配音素材。使用时需要确认输入音频来源、输出格式、时长和模型限制;涉及人声克隆、版权音乐或公开发布时,应先核对授权和合规边界。

audio-and-sound 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 12,831。

总安装 1,115周安装 46GitHub Stars 39,472下载 364核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:audio-and-sound(音频和声音)
来源仓库:https://github.com/phaserjs/phaser
仓库路径:skills/audio-and-sound
安装命令:
npx skills add https://github.com/phaserjs/phaser --skill audio-and-sound
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/phaserjs/phaser --skill audio-and-sound

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

audio-and-sound 统一管理 Phaser 游戏引擎内的音频播放与声音管理。适用于需要加载、播放、混音与空间音效处理的网页游戏开发。抽象 Web Audio API 与 HTML5 Audio,支持音量、声像、循环与音频精灵。

使用时应通过 this.sound 访问 SoundManager,配置加载路径与播放策略。集成自动播放策略解锁与事件监听机制,提升用户体验一致性。

来源仓库内路径:skills/audio-and-sound

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/phaserjs/phaser --skill audio-and-sound;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

audio-and-sound 怎么安装?

在终端执行 npx skills add https://github.com/phaserjs/phaser --skill audio-and-sound。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

audio-and-sound 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

audio-and-sound 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

audio-and-sound 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

audio-and-sound 用的人多吗?

公开数据是累计安装 1,115 次,近一周安装 46 次,下载 364 次,GitHub 39,472 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

audio-and-sound 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 来源仓库有 39,472 星,维护活跃度相对可查。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
audio-and-sound

音频和声音 · 本页

1,11539,472操作浏览器未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Audio and Sound

Phaser provides a unified Sound system via this.sound (a SoundManager) that abstracts over Web Audio API and HTML5 Audio. It handles loading, playback, volume, panning, looping, markers, audio sprites, spatial audio, and browser autoplay-policy unlocking.

Key source paths: src/sound/BaseSoundManager.js, src/sound/BaseSound.js, src/sound/webaudio/, src/sound/html5/, src/sound/SoundManagerCreator.js, src/sound/events/, src/sound/typedefs/ Related skills:../loading-assets/SKILL.md,../game-setup-and-config/SKILL.md

Quick Start

class GameScene extends Phaser.Scene {
    preload() {
        this.load.audio('bgm', 'assets/music.mp3');
        this.load.audio('coin', ['assets/coin.ogg', 'assets/coin.mp3']);
    }

    create() {
        // Fire-and-forget (auto-destroys when complete)
        this.sound.play('coin');

        // Retained reference for ongoing control
        this.music = this.sound.add('bgm', { loop: true, volume: 0.5 });
        this.music.play();
    }
}

Assets loaded via this.load.audio() in preload() are ready by the time create() runs. Provide an array of URLs for cross-browser format fallback.

Core Concepts

WebAudio vs HTML5 Audio

Phaser auto-selects the best backend via SoundManagerCreator.create():

  1. If config.audio.noAudio is true, or the device supports neither Web Audio nor HTML5 Audio, a NoAudioSoundManager is created (all calls are no-ops).
  2. If the device supports Web Audio and config.audio.disableWebAudio is not true, a WebAudioSoundManager is created (preferred).
  3. Otherwise, an HTML5AudioSoundManager is created as fallback.

WebAudio advantages: precise timing, gapless looping, stereo panning (StereoPannerNode), spatial audio (PannerNode), per-sound gain nodes, decodeAudio() for runtime decoding.

HTML5 Audio limitations: no spatial audio, no real stereo panning (pan fires events but no audible effect), less precise looping, requires instances count at load time for simultaneous playback.

Force HTML5 or disable audio via game config: audio: {disableWebAudio: true} or audio: {noAudio: true}. Pass audio: {context: existingAudioContext} to reuse a WebAudio context in SPAs.

The SoundManager (this.sound)

Accessed via this.sound in any Scene. It is a single shared instance across the entire game. Key responsibilities:

  • Adding, playing, and removing sound instances
  • Global volume, mute, rate, and detune
  • Automatic pause/resume when the browser tab loses/gains focus (pauseOnBlur, default true)
  • Audio unlock handling for mobile browsers
  • Spatial audio listener position (WebAudio only)

Sound Instances

Created via this.sound.add(key, config). Each instance has its own playback state, volume, rate, detune, loop, pan, and seek properties. A sound must exist in the audio cache (loaded via the Loader) before it can be added.

State flags: isPlaying (boolean), isPaused (boolean).

const sfx = this.sound.add('explosion', { volume: 0.8 });
sfx.play();        // returns boolean
sfx.pause();       // only works if isPlaying
sfx.resume();      // only works if isPaused
sfx.stop();        // resets to stopped state
sfx.destroy();     // marks for removal from manager

Common Patterns

Playing Sounds

Fire-and-forget -- this.sound.play(key, config?) adds, plays, and auto-destroys the sound on completion:

this.sound.play('explosion');
this.sound.play('powerup', { volume: 0.5, rate: 1.2 });

Retained reference -- this.sound.add(key, config?) then call play() on the instance:

const laser = this.sound.add('laser');
laser.play();
// Later: laser.stop(), laser.volume = 0.3, etc.

Volume, Rate, and Detune

Each property can be set per-sound or globally on the manager. Global and per-sound values combine (for rate/detune, they multiply via calculateRate()).

// Per-sound
sound.volume = 0.5;          // 0 to 1
sound.setVolume(0.5);        // chainable alternative
sound.rate = 1.5;            // 0.5 = half speed, 2.0 = double speed
sound.setRate(1.5);
sound.detune = 200;          // cents, -1200 to 1200
sound.setDetune(200);

// Global (affects all sounds)
this.sound.volume = 0.8;
this.sound.setVolume(0.8);
this.sound.rate = 1.0;
this.sound.setRate(1.0);
this.sound.detune = 0;
this.sound.setDetune(0);

The effective playback rate is: sound.rate * manager.rate * detuneRate where detuneRate = Math.pow(1.0005777895065548, sound.detune + manager.detune).

Looping

// Via config at creation
const bgm = this.sound.add('music', { loop: true });
bgm.play();

// Toggle during playback
bgm.loop = false;
bgm.setLoop(false);  // chainable

The LOOPED event fires each time the sound loops back to the start. The LOOP event fires when the loop property changes.

Seeking

sound.seek = 5.0;        // jump to 5 seconds in
sound.setSeek(5.0);      // chainable
console.log(sound.seek);  // current playback position in seconds

Setting seek on a stopped sound has no effect.

Stereo Panning

sound.pan = -1;   // full left
sound.pan = 0;    // center
sound.pan = 1;    // full right
sound.setPan(0.5); // chainable

Uses StereoPannerNode, if it exists, on WebAudio. On HTML5 Audio, the pan property fires events but has no audible effect.

Audio Sprites and Markers

Audio sprites combine multiple sounds into a single audio file with a JSON config (generated by the audiosprite tool). The JSON must be loaded separately.

// In preload
this.load.audioSprite('sfx', 'assets/sfx.json', ['assets/sfx.ogg', 'assets/sfx.mp3']);

// In create
this.sound.playAudioSprite('sfx', 'explosion');
this.sound.playAudioSprite('sfx', 'coin', { volume: 0.5 });

// Or add for retained control
const sprite = this.sound.addAudioSprite('sfx');
sprite.play('explosion');

The JSON spritemap entries are automatically converted to markers with name, start, duration, and optional loop.

Manual markers -- you can also add markers to any sound:

const sound = this.sound.add('longtrack');

sound.addMarker({ name: 'intro', start: 0, duration: 5 });
sound.addMarker({ name: 'loop', start: 5, duration: 20, config: { loop: true } });
sound.addMarker({ name: 'outro', start: 25, duration: 3 });

sound.play('intro');
// Later
sound.play('loop');

Marker API on BaseSound: addMarker(marker), updateMarker(marker), removeMarker(markerName).

Background Music Pattern

this.bgm = this.sound.add('theme', { loop: true, volume: 0.4 });
this.bgm.play();
// Stop on scene shutdown: this.bgm.stop();

The manager's pauseOnBlur (default true) automatically pauses all sounds when the tab loses focus.

Spatial Audio (WebAudio Only)

Spatial audio uses the Web Audio PannerNode to position sounds in 2D/3D space relative to a listener.

// Set the listener position (typically your camera or player)
this.sound.setListenerPosition(400, 300);
// Or update directly: this.sound.listenerPosition.set(x, y);

// Create a spatialized sound with a source config
const enemy = this.sound.add('roar', {
    source: {
        x: 800,
        y: 300,
        refDistance: 50,
        maxDistance: 2000,
        rolloffFactor: 1,
        distanceModel: 'inverse',
        panningModel: 'equalpower',
        follow: enemySprite  // auto-track a Game Object's x/y
    }
});
enemy.play();

You can set sound.x and sound.y directly on a WebAudioSound to reposition it at any time. If follow is set to an object with x/y properties, the spatial position updates automatically each frame.

setListenerPosition() defaults to the center of the game canvas if called with no arguments.

Muting

// Per-sound
sound.mute = true;
sound.setMute(true);

// Global
this.sound.mute = true;
this.sound.setMute(true);

Querying Sounds

this.sound.get('coin');          // first sound with key, or null
this.sound.getAll('coin');       // all sounds with key
this.sound.getAll();             // every sound in the manager
this.sound.getAllPlaying();      // all currently playing sounds
this.sound.isPlaying('coin');    // true if any 'coin' sound is playing
this.sound.isPlaying();          // true if any sound is playing

Removing and Stopping

this.sound.stopAll();            // stop all sounds, fires STOP_ALL
this.sound.stopByKey('coin');    // stop all sounds with key, returns count
this.sound.pauseAll();           // pause all, fires PAUSE_ALL
this.sound.resumeAll();          // resume all, fires RESUME_ALL

this.sound.remove(soundInstance);  // destroy + remove specific sound
this.sound.removeByKey('coin');    // destroy + remove all with key, returns count
this.sound.removeAll();            // destroy + remove everything

Decoding Audio at Runtime (WebAudio Only)

this.sound.decodeAudio('key', base64StringOrArrayBuffer);
// Or batch: this.sound.decodeAudio([{ key: 'sfx1', data: buf1 }, { key: 'sfx2', data: buf2 }]);
this.sound.on('decoded', (key) => { /* one done */ });
this.sound.on('decodedall', () => { /* all done */ });

Configuration Reference

SoundConfig

PropertyTypeDefaultDescription
mutebooleanfalseWhether the sound is muted
volumenumber1Volume, 0 (silence) to 1 (full)
ratenumber1Playback speed (0.5 = half, 2.0 = double)
detunenumber0Detuning in cents (-1200 to 1200)
seeknumber0Start playback position in seconds
loopbooleanfalseWhether the sound should loop
delaynumber0Delay before playback starts, in seconds
pannumber0Stereo pan, -1 (left) to 1 (right)
sourceSpatialSoundConfignullSpatial audio configuration (WebAudio only)

SpatialSoundConfig

Position: x (0), y (0), z (0) -- source position in world space. Orientation: orientationX (0), orientationY (0), orientationZ (-1) -- source direction vector. Models: panningModel ('equalpower' or 'HRTF'), distanceModel ('linear', 'inverse', 'exponential'). Distance: refDistance (1), maxDistance (10000), rolloffFactor (1). Cone: coneInnerAngle (360), coneOuterAngle (0), coneOuterGain (0). Tracking: follow (null) -- a Vector2Like object whose x/y is auto-tracked each frame.

SoundMarker

PropertyTypeDefaultDescription
namestring(required)Unique identifier for the marker
startnumber0Start position in seconds
durationnumber(remaining)Playback duration in seconds
configSoundConfig{}Default settings for this marker

Events

Sound Instance Events (emitted on a Sound object)

Event ConstantString ValueCallback ArgsWhen
Events.PLAY'play'(sound)Sound starts playing
Events.PAUSE'pause'(sound)Sound is paused
Events.RESUME'resume'(sound)Sound resumes from pause
Events.STOP'stop'(sound)Sound is stopped
Events.COMPLETE'complete'(sound)Sound finishes (non-looping)
Events.LOOPED'looped'(sound)Sound loops back to start
Events.LOOP'loop'(sound, value)Loop property changes
Events.MUTE'mute'(sound, value)Mute state changes
Events.VOLUME'volume'(sound, value)Volume changes
Events.RATE'rate'(sound, value)Rate changes
Events.DETUNE'detune'(sound, value)Detune changes
Events.SEEK'seek'(sound, value)Seek position changes
Events.PAN'pan'(sound, value)Pan value changes
Events.DESTROY'destroy'(sound)Sound is destroyed

SoundManager Events (emitted on this.sound)

Event ConstantString ValueCallback ArgsWhen
Events.PAUSE_ALL'pauseall'(manager)pauseAll() called
Events.RESUME_ALL'resumeall'(manager)resumeAll() called
Events.STOP_ALL'stopall'(manager)stopAll() called
Events.GLOBAL_MUTE'globalmute'(manager, value)Global mute changes
Events.GLOBAL_VOLUME'globalvolume'(manager, value)Global volume changes
Events.GLOBAL_RATE'globalrate'(manager, value)Global rate changes
Events.GLOBAL_DETUNE'globaldetune'(manager, value)Global detune changes
Events.UNLOCKED'unlocked'(manager)Audio system unlocked after user interaction
Events.DECODED'decoded'(key)Single audio key decoded (WebAudio)
Events.DECODED_ALL'decodedall'()All queued audio decoded (WebAudio)
// Example: listen for completion
const sfx = this.sound.add('bang');
sfx.on('complete', (sound) => {
    console.log(sound.key, 'finished');
});
sfx.play();

API Quick Reference

BaseSoundManager (this.sound)

Methods: add(key, config?), addAudioSprite(key, config?), play(key, extra?), playAudioSprite(key, spriteName, config?), get(key), getAll(key?), getAllPlaying(), isPlaying(key?), remove(sound), removeByKey(key), removeAll(), stopAll(), stopByKey(key), pauseAll(), resumeAll(), setListenerPosition(x?, y?), setMute(value), setVolume(value), setRate(value), setDetune(value).

Properties: volume (0-1), mute (boolean), rate (number), detune (-1200 to 1200), pauseOnBlur (boolean, default true), locked (boolean, read-only), listenerPosition (Vector2), sounds (array, private).

BaseSound (sound instance)

Methods: play(markerName?, config?), pause(), resume(), stop(), destroy(), addMarker(marker), updateMarker(marker), removeMarker(name), setMute(value), setVolume(value), setRate(value), setDetune(value), setSeek(value), setLoop(value), setPan(value).

Properties: volume (0-1), mute (boolean), rate (number), detune (number), seek (seconds), loop (boolean), pan (-1 to 1), isPlaying (read-only), isPaused (read-only), duration (seconds), totalDuration (seconds), key (string), x / y (spatial position, WebAudio only).

All set* methods return this for chaining.

Gotchas

Browser Autoplay Policy

Browsers block audio until user interaction. Phaser handles this automatically:

  • WebAudio: AudioContext starts suspended. Phaser listens for touchstart/touchend/mousedown/mouseup/keydown on document.body to call context.resume(). The locked property is true until unlocked; UNLOCKED event fires once resolved.
  • HTML5 Audio: Locked audio tags queue all actions until the first touch replays them.

You do not need to handle unlocking manually. To know when ready, listen for UNLOCKED:

if (this.sound.locked) {
    this.sound.once('unlocked', () => {
        this.sound.play('bgm');
    });
} else {
    this.sound.play('bgm');
}

Audio Format Support

No single format works everywhere. Provide multiple formats: this.load.audio('bgm', ['assets/bgm.ogg', 'assets/bgm.mp3']). MP3 has broadest support. OGG Vorbis lacks Safari support. AAC/M4A works well on Safari/iOS. WebM/Opus has excellent quality but limited older browser support.

HTML5 Audio Simultaneous Playback

HTML5 Audio uses a pool of <audio> tags. Specify instances when loading for simultaneous playback: this.load.audio('shot', 'assets/shot.mp3', {instances: 4}). Default is 1. If all tags are in use and manager.override is true (default), the sound with the most progress is hijacked. WebAudio has no such limitation.

iOS/Safari Specifics

  • StereoPannerNode not supported on iOS/Safari, so pan has no audible effect (events still fire).
  • iOS 17/18+ can interrupt audio on background. Phaser handles this via context.suspend()/context.resume() on the VISIBLE game event.
  • setListenerPosition() and spatial audio are WebAudio-only.

WebAudio Context Reuse

For SPAs that recreate the game without a full page reload, pass audio: {context: existingAudioContext} in the game config. You can also swap contexts at runtime via this.sound.setAudioContext(newContext) (WebAudio only).

Sound Manager is Shared (Global)

There is one SoundManager per game, not per scene. this.sound in every scene references the same manager. Sounds are not automatically cleaned up on scene shutdown -- you must stop/remove them yourself if needed. Looping sounds will continue playing across scene changes unless explicitly stopped.

Fire-and-Forget vs Persistent Sounds

this.sound.play(key) creates a sound that auto-destroys on completion -- you cannot control it after calling play. Use this.sound.add(key) when you need a persistent reference to pause, stop, adjust volume, or listen for events.

Spatial Audio is WebAudio Only

The source config for spatial audio is silently ignored when using HTML5 Audio. If your game must support HTML5 Audio fallback, do not rely on spatial positioning for gameplay-critical audio cues.

Web Audio Analyser (WebAudio Only)

Access the underlying AudioContext to create an AnalyserNode for frequency/waveform visualization:

const analyser = this.sound.context.createAnalyser();
analyser.fftSize = 256;
this.sound.masterVolumeNode.connect(analyser);
analyser.connect(this.sound.context.destination);

const dataArray = new Uint8Array(analyser.frequencyBinCount);

// In update loop
analyser.getByteFrequencyData(dataArray);
// Use dataArray values to drive visual effects

This only works with the WebAudioSoundManager. Check this.sound.context exists before using.

Source File Map

FilePurpose
src/sound/SoundManagerCreator.jsFactory: picks WebAudio, HTML5, or NoAudio manager
src/sound/BaseSoundManager.jsBase manager: add, play, get, stop/pause/resume all, global volume/rate/detune
src/sound/BaseSound.jsBase sound: play/pause/resume/stop, markers, config, calculateRate
src/sound/webaudio/WebAudioSoundManager.jsWebAudio manager: AudioContext, gain nodes, unlock, spatial listener, decodeAudio
src/sound/webaudio/WebAudioSound.jsWebAudio sound: buffer sources, spatial/panner nodes, seek, all properties
src/sound/html5/HTML5AudioSoundManager.jsHTML5 manager: audio tag pooling, locked queue, override
src/sound/html5/HTML5AudioSound.jsHTML5 sound: tag-based playback, limited feature set
src/sound/noaudio/NoAudioSoundManager.jsNo-op manager for environments without audio
src/sound/events/All sound event constants (PLAY, STOP, COMPLETE, etc.)
src/sound/typedefs/SoundConfig.jsSoundConfig type definition
src/sound/typedefs/SoundMarker.jsSoundMarker type definition
src/sound/typedefs/SpatialSoundConfig.jsSpatialSoundConfig type definition
src/sound/typedefs/AudioSpriteSound.jsAudioSpriteSound type definition

平台分布

Codex

34.88%
按下载量换算127

Claude

31.18%
按下载量换算113

Cursor

19.96%
按下载量换算73

Gemini CLI

9.56%
按下载量换算35

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills