SMAF Engine Enhancement - #66
Merged
Merged
Conversation
…ser robustness smaf crate changes: - Tolerate unknown top-level chunks (SmafChunk::Unknown) instead of panicking - Skip reserved MIDI status bytes 0xA0/0xD0 in mobile format instead of panicking - Replace panic on unknown 0xFF second_byte with catch-all Nop - Add parse_handy_variable_number for HPS variable-length encoding - Refactor parse_handy into parse_handy_like(input, softbank) + parse_softbank wrapper - Add short-format lookup tables: SHORT_MOD_VALUES, SHORT_EXPRESSION_VALUES - Add SHORT_PITCH_BEND_VALUES and SHORT_EXPRESSION_VALUES for PCM audio track - Rewrite PCM 0x00 branch to use event_type dispatch and lookup tables - Change NoteMessage velocity to Option<u8> (HPS notes have no velocity) - Add pitch_bend_byte_to_midi for 8-bit to 14-bit pitch bend conversion - Add SoftbankSequenceData variant to SmafChunk and SEQU chunk parsing - Add Huffman decoder (huffman_decode) for MobileStandardCompress format - Export ChannelStatus, ChannelType, parse_variable_number, parse_handy_variable_number - Add 16 integration tests covering all new functionality
smaf_player: - Add ToneMap struct tracking per-channel state: channel types, programs, volumes, expressions, velocities, bank select, forced rhythm flags, and atmosphere layer configuration - Add MIDI channel allocation with melody compaction around drum channel 9 and per-track offset for HPS multi-track files - Add Yamaha MA program mapping (0x7c/0x01 bank voices to GM fallbacks) and rhythm bank detection (0x7d) - Add HPS-specific note mapping: melody notes get +36 offset, rhythm notes use program number as drum key - Add HPS expression folding into volume (CC7) instead of CC11 - Add HPS drum velocity calculation from volume * expression - Add atmosphere voice layering for Yamaha MA ambience voice (0x7c/0x01/0x62): emits two layered notes on channels 14/15 with reverb, chorus, and release envelope extensions - Add setup data SysEx parsing with MIDI variable-length quantity - Add octave shift, modulation (CC1), bank select (CC0), and pitch bend event conversion - Add MidiPitchBend and MidiSysEx variants to SmafEvent - Add stable event sort ordering (control changes before program changes before note events at same timestamp) - Add SoftbankSequenceData chunk handling in parse_smaf - Fix duration accumulation: apply duration before event time - Add 11 unit tests covering ToneMap allocation, program mapping, atmosphere layering, HPS rhythm/melody behavior, and duration timing
smaf_cli:
- Add MidiPitchBend and MidiSysEx event handling
- Extract play_events into reusable async fn
- Wrap playback in loop {} for default infinite BGM looping
- Use saturating_sub for time delta to prevent underflow
- Clone wave data on each iteration for repeat playback
dlunch
enabled auto-merge (squash)
June 24, 2026 07:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some feat require modifications on the Main Emulator side and will be submitted as a PR later. : )
Test Video:
bandicam.2026-06-23.12-19-01-757.mp4