8-bit 効果音の「楽譜」を Nostr イベントで運び、対応クライアントが Web Audio で再生する仕様の提案。作る・公開するのはスタジオ、公開作品を聴くのはサウンドギャラリーで。このページは仕様本文が中心で、試作スタジオと検索も埋め込んでいる。
A proposal for carrying 8-bit sound-effect "scores" in Nostr events, played back by supporting clients with Web Audio. Make and publish in the studio; listen to published works in the sound gallery. This page is mainly the spec text, with a prototype studio and search embedded.
nokakoi には矩形波でその場合成する 8-bit 効果音がある。音声ファイルは使わず、楽譜は
[周波数Hz, 長さ秒] のペアの並びというテキストデータでしかない。
テキストで表せるものは Nostr イベントに載せられる — つまり効果音は「投稿できるデータ」になる。
nokakoi has 8-bit sound effects synthesized on the spot with square waves. No audio files are used: a score is just text data — a sequence of [frequency Hz, length seconds] pairs. Anything expressible as text can ride on a Nostr event — in other words, sound effects become data you can post.
設計の前例は NIP-30(カスタム絵文字)。データはイベントで運び、描画(ここでは再生)はクライアント側の仕事、 非対応クライアントはただ無視する。カラーテーマの共有と同じ感覚で、音のテーマ(サウンドパック)を公開・共有・差し替えできるのが狙い。
The design precedent is NIP-30 (custom emoji). Data travels in events; rendering (here, playback) is the client's job, and non-supporting clients simply ignore it. Like sharing a color theme, the point is that you can publish, share, and swap a "sound theme" (a sound pack).
パックは kind:30078(パラメータ化された置換可能イベント)に d = "sfx-pack/<名前>" で公開する。
内容は1つの JSON:
A pack is published as kind:30078 (a parameterized replaceable event) with d = "sfx-pack/<name>". The content is a single JSON:
{
// kind: 30078, tags: [["d", "sfx-pack/8bit-default"]]
"version": 1,
"title": "基本の 8-bit セット",
"wave": "square",
"volume": 0.06,
"sounds": {
"publish": [[523.25, 0.045], [659.25, 0.045], [783.99, 0.09]],
"zap": [[987.77, 0.07], [1318.51, 0.32]],
"notify": [[1318.51, 0.05], [1567.98, 0.09]]
}
}
| フィールドField | 意味Meaning |
|---|---|
version | 形式のバージョン(現在 1)The format version (currently 1) |
title | 表示名(任意)。言語は自由(日本語可)。d の名前は ASCII スラッグとし、クライアントは title があればそちらを優先表示してよいDisplay title (optional). Any language is fine (Japanese OK). The d name is an ASCII slug; clients may prefer the title when present |
wave | 波形。square(矩形波=ファミコンのパルス波系)/ triangle / sine / sawtoothWaveform. square (the Famicom pulse family) / triangle / sine / sawtooth |
volume | 基準音量 0〜1。クライアントは上限を設けてよいBase volume, 0–1. Clients may cap it |
sounds | 音の名前 → 楽譜。楽譜は [周波数, 秒] の配列Sound name → score. A score is an array of [frequency, seconds] |
[523.25, 0.045] — 523.25Hz(ド C5)を 0.045 秒[523.25, 0.045] — 523.25 Hz (C5) for 0.045 seconds[0, 0.09] — 休符(周波数 0)[0, 0.09] — a rest (frequency 0)["C5", 0.045](手書きのしやすさのため。内部では周波数に変換)Note names may also be accepted: ["C5", 0.045] (for hand-writing; converted to frequencies internally)クライアント間で意味を揃えるための推奨名。パックはこの名前で音を定義し、クライアントは自分の操作に割り当てる。Recommended names so clients share meanings. Packs define sounds under these names; clients map them to their own actions.
| 名前Name | 想定する場面Intended moment |
|---|---|
tab | タブ切替Tab switch |
select | 投稿の選択(キーボード/タップ)Selecting a post (keyboard / tap) |
press | 投稿ボタンを押した瞬間The moment a post button is pressed |
publish | 投稿の成功Successful post |
react | リアクション送信Sending a reaction |
zap | Zap の送信・受信(コイン音)Sending/receiving a Zap (coin sound) |
notify | 自分宛ての通知の到着A notification for you arriving |
error | 失敗・エラーFailure / error |
nokakoi には拡張音として selectDown(選択・下)、selectUp(選択・上)、toggle(トグル)もある。標準語彙ではなく、名前が一致したクライアントだけが差し替える。nokakoi also has extension sounds: selectDown, selectUp, and toggle. They are not part of the standard vocabulary; only clients that use the same names will substitute them.
d で新しい版を公開すれば置き換わる(修正はこれで)Publishing a newer version under the same d replaces it (this is how fixes are made)sounds を空にした版で上書きすると「取り下げ」。クライアントは取り下げられたパックを表示・再生しないOverwriting with empty sounds withdraws the pack. Clients do not display or play withdrawn packs通常の作曲は、パックと曲の両方を扱えるスタジオ単独ページで。ここには仕様を試すためのパック用試作を埋め込んでいる。音符ボタンを押すと、その場で鳴りながら楽譜が組み上がる。できた楽譜を音名に割り当ててパックにまとめ、 NIP-07(ブラウザ拡張の署名者)で署名すれば、そのまま kind:30078 としてリレーに公開できる。 秘密鍵がこのページに触れることはない。署名者がない環境では、パック JSON をコピーして持ち出すだけでも使える。
For regular composing, use the standalone studio, which handles both packs and songs. A pack prototype is embedded here for trying the spec. Press note buttons and the score builds up, playing as you go. Assign the finished score to sound names to form a pack, sign it with NIP-07 (a browser-extension signer), and it is published to relays as kind:30078. Your secret key never touches this page. Without a signer, you can still copy the pack JSON and carry it elsewhere.
sfx-pack/my-pack(英小文字・数字・ハイフン・アンダースコア) (lowercase letters, digits, hyphens, underscores)
公開する前に
リレーに公開されたサウンドパック(kind:30078、d="sfx-pack/...")は、聴く専用のサウンドギャラリーで探せる。単体リンクの共有、nostr:naddr... のコピー、JSON のコピー、スタジオで開いて改造することもできる。nokakoi v1.161.0 以降では、投稿内の naddr 引用がパックカードになり、その場で各音を試聴して直接適用できる。v1.162.0 以降では、適用中パックの更新確認と最新版への更新も設定画面からできる。他のクライアントで同じカード表示を実装する方法はカード実装ガイドにまとめた。
Find published sound packs (kind:30078, d="sfx-pack/...") in the listen-only sound gallery. You can share a single-item link, copy its nostr:naddr... reference or JSON, or open it in the studio to remix it. In nokakoi v1.161.0 and later, an naddr quote in a post becomes a pack card where each sound can be auditioned and the pack applied directly. In v1.162.0 and later, the settings screen can also check the applied pack for updates and update it to the latest version. The card implementation guide explains how other clients can render the same cards.
下の検索は、仕様ページ内で試すための簡易版。
The search below is a simple in-page version for trying the spec.
どの操作でどの音名を鳴らすかはクライアントの自由。パックは音の定義だけを持つ。 ユーザーは好きなパックを取り込んで、自分のクライアントの操作音を丸ごと差し替えられる。 nokakoi の現在の効果音(種類別 ON/OFF つき)はこの層の実装にあたり、設定への貼り付け取り込みと、naddr カードからの直接適用に対応している。
Which action plays which sound name is up to the client; a pack only holds sound definitions. Users can import a favorite pack and replace all of their client's UI sounds. nokakoi's current sound effects (with per-kind toggles) implement this layer, with paste-to-import in settings and direct apply from naddr cards.
投稿イベントに ["sfx", "zap"] タグを付けると、対応クライアントがその投稿の表示・到着時に著者のパックの音を鳴らす。
面白い反面、悪用の余地があるため、仕様側で次のガードを必須とする:
Putting an ["sfx", "zap"] tag on a post event lets supporting clients play the author's pack sound when the post is displayed or arrives. It is fun, but open to abuse, so the spec mandates these guards:
自動再生ポリシー: ブラウザではユーザー操作前に音を鳴らせない。「開いた瞬間に他人の音が鳴る」事故は構造上起きにくいが、逆にページを開いた直後の通知音も初回操作までは鳴らない。Autoplay policy: browsers cannot play sound before a user action. Accidents like "someone else's sound plays the moment you open the page" are structurally unlikely — but by the same token, a notification sound right after opening the page will not play until the first interaction.
iOS Safari: Web Audio の再開タイミングに癖がある。実機での確認が要る。iOS Safari: Web Audio resume timing has quirks. Needs verification on real devices.
d="sfx-pack/..."。普及したら専用 kind の NIP 化を検討Kind choice: for now, kind:30078 + d="sfx-pack/...". If it spreads, consider proposing a dedicated kind as a NIPsfx タグ)の試験導入。ガード条件の検証からPhase 3: trial introduction of remote triggers (the sfx tag), starting with verifying the guard conditions