Add Randomize Music Instruments to Audio Options#6799
Open
jdperos wants to merge 12 commits into
Open
Conversation
… ranges on instrument ranges.
…andomize-music-layers
Contributor
Author
RandomMusicLayers_Small.mp4 |
Contributor
Author
|
Note: this option sounds more musical when used together with Experimental Octave Drop Because instruments are remapped to other sounds in the same sound font, some notes can end up outside the usable pitch range of the replacement sample. When that happens, the audio system can hit the 4x pitch multiplier limit and effectively clamp very high notes instead of playing them at the intended pitch. Experimental Octave Drop helps by pulling those notes back into a playable range while maintaining their musical function. |
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.
Summary
This adds a new Randomize Music Instruments option to the Audio Editor.
When enabled, music sequence instruments are shuffled within the currently playing song’s sound font. The idea is to make the music sound cursed without going fully off the rails into SFX, drums, or other special sequence modes.
What it does
Implementation notes
The randomizer only remaps normal instrument IDs from
0x00through0x7D. IDs0x7Eand above are left alone because those are special sequence modes like drums, etc.Each sound font gets its own remap table. When an instrument is first used, it lazily picks a replacement from the same font and remembers that choice for the rest of the sequence. This keeps a song internally consistent instead of changing the same instrument every time it appears.
The replacement selection tries to behave more like a shuffle than pure random:
There is also a range override hook for sample selection. When instrument A is replaced by instrument B, the replacement still uses A’s pitch range boundaries when choosing low / normal / high samples. This helps avoid cases where the replacement instrument’s native split points cause notes to get routed into weird or missing sample ranges.
Hook changes
This adds two new audio hooks:
OnSeqInstrumentSetOnSeqInstrumentGetSoundOnSeqInstrumentSetlets enhancements modify the instrument ID before the audio system resolves it.OnSeqInstrumentGetSoundlets enhancements override whichSoundFontSoundgets used for a given instrument/semitone pair. The instrument randomizer uses this to preserve the original instrument’s range behavior after remapping.Memory note
The remap table is static and per-font. Replacement tracking uses a bitset so the “already used” state stays relatively small. No runtime allocation is used in the randomizer path.
Why
Mostly because chaotic music randomization is funny, but keeping it constrained to valid instruments in the same song makes it way more usable than total random noise.
Build Artifacts