immamdouhaboammar/motion-graphics-skills

tonejs

Use when adding audio, sound design, music sequencing, or audio-reactive animation to a project.

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/immamdouhaboammar/motion-graphics-skills --skill tonejs

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

Tone.js

When to Use This Skill

Apply when any of the following are needed:

  • Playing audio files (SFX, VO, music) alongside GSAP animations
  • Beat-synchronized or BPM-locked animation (e.g. scene cuts on the beat)
  • Audio-reactive visuals: DOM/SVG elements animated by waveform or frequency data
  • Programmatic sound generation (synths, oscillators, UI sounds)
  • Adding audio effects (reverb, delay, distortion) to any source

Related skills: For timeline sequencing use gsap-timeline, for performance use gsap-performance, and for scroll-sync use gsap-scrolltrigger.

⚠️ Browser Autoplay Policy: Tone.start() MUST be called inside a user-gesture handler (click, keydown, etc.). Audio context will not resume otherwise. Always gate initialization behind an interaction.

Setup

CDN (vanilla HTML projects):

html
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.8.49/Tone.js"></script>

npm / bun:

bash
bun add tone
js
import * as Tone from 'tone';

Required initialization (always wrap in user gesture):

js
document.getElementById('start-btn').addEventListener('click', async () => {
  await Tone.start();           // Resume AudioContext
  Tone.getTransport().start();  // Start master clock
}, { once: true });

Core Architecture

Tone.js signal graph
  Source  →  Effect(s)  →  Destination
  Synth       Reverb        toDestination()
  Player      Delay
  Analyser    Distortion

All nodes connect via .connect() or .toDestination() shorthand.


Quick Reference

TaskAPI
Play a tonenew Tone.Synth().toDestination().triggerAttackRelease("C4", "8n")
Load + play filenew Tone.Player(url).toDestination(); player.start()
Add reverbconst rev = new Tone.Reverb(2).toDestination(); synth.connect(rev)
Schedule on beatTone.getTransport().scheduleRepeat(cb, "4n")
Read waveformnew Tone.Analyser("waveform", 64).getValue()
Read frequencynew Tone.Analyser("fft", 32).getValue()
Set BPMTone.getTransport().bpm.value = 120
Sync visual to audioTone.getDraw().schedule(() => { /* gsap here */ }, time)
Stop everythingTone.getTransport().stop(); Tone.getTransport().cancel()

GSAP Sync: The Right Way

Problem: Tone callbacks run on the audio thread. Calling gsap.to() directly inside them causes jitter.

Solution: Always use Tone.getDraw().schedule() to bridge audio events to the visual frame.

js
// Correct: no jitter
Tone.getTransport().scheduleRepeat((time) => {
  Tone.getDraw().schedule(() => {
    gsap.fromTo('#element', { scale: 1 }, { scale: 1.2, duration: 0.1 });
  }, time);
}, '4n');

// Wrong: triggers on audio thread, causes jitter
Tone.getTransport().scheduleRepeat((time) => {
  gsap.to('#element', { scale: 1.2 }); // DO NOT do this
}, '4n');

Audio-Reactive Animation

Wire a Tone.Analyser into the GSAP ticker to drive DOM elements in real time:

js
const analyser = new Tone.Analyser('waveform', 64);
const synth    = new Tone.Synth().connect(analyser).toDestination();

// Pull audio data every animation frame via GSAP ticker
gsap.ticker.add(() => {
  const waveform = analyser.getValue(); // Float32Array, values in [-1, 1]
  const bars = document.querySelectorAll('.bar');

  bars.forEach((bar, i) => {
    const amp = Math.abs(waveform[i] ?? 0);
    gsap.set(bar, { scaleY: 1 + amp * 15 }); // gsap.set: no tween overhead
  });
});

synth.triggerAttackRelease('C3', '1n');
Use gsap.set() (not gsap.to()) inside ticker.add() because creating new tweens every frame is expensive.

BPM-Locked Scene Cuts

js
Tone.getTransport().bpm.value = 120;

// Fire visual on every measure
Tone.getTransport().scheduleRepeat((time) => {
  Tone.getDraw().schedule(() => {
    gsap.fromTo('#scene', { autoAlpha: 0 }, { autoAlpha: 1, duration: 0.3 });
  }, time);
}, '1m'); // 1m = 1 measure

Tone.getTransport().start();

Playing Audio Files (SFX / VO)

js
const player = new Tone.Player({
  url:       'assets/audio/whoosh.mp3',
  autostart: false,
}).toDestination();

// Trigger on a GSAP event
gsap.to('#card', {
  y: -200,
  onStart: () => player.start(),
});

Effects Chain

js
const reverb = new Tone.Reverb({ decay: 3, wet: 0.4 }).toDestination();
const delay  = new Tone.FeedbackDelay('8n', 0.3).connect(reverb);
const synth  = new Tone.Synth().connect(delay);

synth.triggerAttackRelease('A3', '4n');

Common Mistakes

MistakeFix
Audio does not startCall await Tone.start() inside a click or keydown handler first
Jittery visualsNever call gsap.to() directly in Tone callbacks. Use Tone.getDraw().schedule()
gsap.to() inside tickerUse gsap.set() inside gsap.ticker.add() instead of creating tweens per frame
Transport events fire twiceCall Tone.getTransport().cancel() before re-scheduling
Player not readyWrap player.start() in the player.load() promise or use onsuccess
High CPU from analyserUse a small buffer size (32 to 64) and avoid FFT when waveform is enough

Minimal Working Example (vanilla HTML)

html
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.8.49/Tone.js"></script>
<script src="assets/vendor/gsap.min.js"></script>
<script>
  document.body.addEventListener('click', async () => {
    await Tone.start();

    const analyser = new Tone.Analyser('waveform', 32);
    const synth    = new Tone.Synth().connect(analyser).toDestination();

    gsap.ticker.add(() => {
      const data = analyser.getValue();
      document.querySelectorAll('.bar').forEach((bar, i) => {
        gsap.set(bar, { scaleY: 1 + Math.abs(data[i] ?? 0) * 10 });
      });
    });

    synth.triggerAttackRelease('C2', '2n');
  }, { once: true });
</script>
같은 저장소의 Skills

더 많은 Skills

모든 Skills
immamdouhaboammar
커뮤니티

animated-chart

Make a looping animated chart for LinkedIn or a newsletter in code with Claude Code. Bars that become a line, a number that counts up, a before and after. Every value stays exactly as given. Use when someone says "animate my chart", "animated graph", "make my results move", "stat animation" or wants a data graphic that loops.

1시간 설치 수
1
GitHub Stars
45
업데이트
11월 1일
immamdouhaboammar
커뮤니티

apple-launch-film

Rebuild an Apple-style Mac launch film entirely in code with Claude Code. A thin menu bar, the black notch growing into widgets one scene at a time, full-screen gradient wallpapers and one short caption per scene. No screen recording, no After Effects. Use when someone says "Apple-style launch", "Mac launch video", "notch animation", "make it look like an Apple keynote", "macOS UI launch film" or wants a product launch that looks like native Mac interface.

1시간 설치 수
1
GitHub Stars
45
업데이트
11월 1일
immamdouhaboammar
커뮤니티

assetseeker

Search free commercial-use creative assets across multiple online sources - photos, illustrations, icons, video footage, music, sound effects, and fonts. Use when the user needs to find assets for videos, PPTs, articles, or any content creation. Trigger on phrases like "find me a photo of", "search for icons", "I need background music", "find video footage", "search fonts", "找一张图片", "搜素材", "帮我找图标/视频/音乐/字体". Covers Pexels, Unsplash, Pixabay, Iconify, Freesound, Google Fonts and more - with API-ba

1시간 설치 수
1
GitHub Stars
45
업데이트
11월 1일
immamdouhaboammar
커뮤니티

audio-mastering-mixer

Mix and master voiceover, sound effects, and music stems to professional broadcast loudness standards. Use when adding SFX cues, balancing audio stems, mastering to minus 14 LUFS, ducking music under voice, or eliminating harsh whooshes.

1시간 설치 수
1
GitHub Stars
45
업데이트
11월 1일