初めに
音ゲーでは譜面データの作成が必須になっています。このときに使われる susの形式では、人が見るのには厳しいため別の形に変換する必要があります。今回は sus-ioを使ってsusファイルからjson形式に変換してみます
開発環境
- python 3.11
- sus-io 0.2.1
セットアップ
python 3.11の環境を構築します。
次にライブラリをインストールします
pip install sus-io
譜面データの作成
今回は、テストデータの譜面作成にはPaletteWorks Editorを使用しました。
以下のような譜面を作成して、出力します。

jsonに変換
作成したsusファイルを使ってjsonに変換する処理を書きます。
import sus from sus import Score with open("score.sus", "r") as fi, open("score.json", "w") as fo: score = sus.load(fi) json = score.to_json(indent=4) fo.write(json) print(Score.from_json(json))
実行すると以下のようなjsonが作成されます。
{ "metadata": { "title": "", "artist": "", "designer": "", "waveoffset": 0.0, "requests": [ "ticks_per_beat 480" ] }, "taps": [ { "tick": 480, "lane": 6, "width": 3, "type": 1 }, { "tick": 1440, "lane": 6, "width": 3, "type": 1 }, { "tick": 2400, "lane": 6, "width": 3, "type": 1 }, { "tick": 2880, "lane": 6, "width": 3, "type": 1 } ], "directionals": [], "slides": [], "bpms": [ [ 0, 120.0 ] ], "barLengths": [ [ 0, 4.0 ] ] }