Skip to content

feat: implement music extension with sample-based audio playback#402

Merged
takaokouji merged 1 commit into
developfrom
feature/smalruby3-music-extension
Mar 27, 2026
Merged

feat: implement music extension with sample-based audio playback#402
takaokouji merged 1 commit into
developfrom
feature/smalruby3-music-extension

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

Music 拡張で実際にドラム・楽器の音声を再生。

  • scratch-vm の MP3 アセット(61ファイル: 18ドラム + 43楽器サンプル)を assets/music/ にバンドル
  • SDL2::Mixer で MP3 を直接ロード・再生
  • play_drum: ドラム番号に対応するサンプルを再生
  • play_note: 楽器の最適サンプルを選択して再生(Scratch と同じ _selectSampleIndexForNote ロジック)
  • 16 チャンネル確保(SDL2::Mixer::Channels.allocate(16)
  • テンポ管理、楽器切り替え

テスト

cd ruby/smalruby3
../rsdl/rsdl -I../ruby-sdl2 -I../ruby-sdl2/lib -Ilib examples/test_music.rb

Closes #391

🤖 Generated with Claude Code

@takaokouji takaokouji force-pushed the feature/smalruby3-music-extension branch from ea38a8f to 234e9a4 Compare March 27, 2026 16:22
Play drums and instrument notes using MP3 samples from scratch-vm.
Bundle 61 MP3 files (18 drums + 43 instrument samples) in assets/music/.
Uses SDL2::Mixer for audio playback with 16 channels.

- play_drum: loads drum MP3 and plays via SDL2::Mixer
- play_note: selects closest sample for target note, plays via SDL2::Mixer
- Instrument/tempo management matching Scratch
- Allocate 16 mixer channels on init

Closes #391

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@takaokouji takaokouji force-pushed the feature/smalruby3-music-extension branch from 234e9a4 to 69cf0ca Compare March 27, 2026 17:06
@takaokouji takaokouji merged commit 654bcf3 into develop Mar 27, 2026
3 checks passed
@takaokouji takaokouji deleted the feature/smalruby3-music-extension branch March 27, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: smalruby3 gem — Music 拡張の音声再生

1 participant