の nokakoi

Nostr サウンドパック仕様案Nostr Sound Pack Spec ProposalDraft 0.2

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.

1. 概要1. Overview

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).

2. サウンドパックの形式2. Sound pack format

パックは 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]

楽譜の表記Score notation

標準の音名(語彙)Standard sound names (vocabulary)

クライアント間で意味を揃えるための推奨名。パックはこの名前で音を定義し、クライアントは自分の操作に割り当てる。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
zapZap の送信・受信(コイン音)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.

更新と取り下げUpdates and withdrawal

3. スタジオ: 作曲と公開3. Studio: compose and publish

通常の作曲は、パックと曲の両方を扱えるスタジオ単独ページで。ここには仕様を試すためのパック用試作を埋め込んでいる。音符ボタンを押すと、その場で鳴りながら楽譜が組み上がる。できた楽譜を音名に割り当ててパックにまとめ、 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.

プリセット:
オクターブ: C5–C6
半音: 押してからドレミを打つと、その1音だけ半音上がる/下がる
長さ:
割り当てる音:
パック名: d = sfx-pack/my-pack(英小文字・数字・ハイフン・アンダースコア) (lowercase letters, digits, hyphens, underscores)
表示名:
波形: 音量: 0.06

  
JSON から読み込む(パックの content、またはイベント JSON 丸ごとでも可):

NIP-07 で公開

未接続
公開先:

公開する前に

リレーに公開されたサウンドパック(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.

5. 再生の2層5. Two layers of playback

第1層: ローカル割当(仕様の芯)Layer 1: local assignment (the core of 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.

第2層: 遠隔トリガー(任意・上級)Layer 2: remote triggers (optional, advanced)

投稿イベントに ["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:

6. 制約と未決事項6. Constraints and open questions

自動再生ポリシー: ブラウザではユーザー操作前に音を鳴らせない。「開いた瞬間に他人の音が鳴る」事故は構造上起きにくいが、逆にページを開いた直後の通知音も初回操作までは鳴らない。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.

7. 状態とロードマップ7. Status and roadmap