Repository navigation
Play AltSound packs instead of the ROM's sound - #49
Merged
Merged
Conversation
The Player's PinMAME settings get an AltSound section: a toggle, the folder with the packs, and when it's on, the pack's volume and how much of the ROM's own sound stays under it (none by default, like Visual PinMAME). The ROM's sound commands drive libaltsound, built into a new VpeAltSound library from native/AltSound with a C interface, two fixes on top of the pinned sources (folder-based packs, failed loads) and a Windows directory listing that leaves the current directory alone. The mix plays through the central mixer's ROM bus, or through Unity without it, and pauses with the game. Needs the OnSoundCommand event of the next pinmame-dotnet release.
[Medium impact] The PR appears safe to merge, with the previous volume-tracking issue addressed and no new actionable findings. SummaryAdds AltSound packs as an optional replacement for ROM audio.
|
…ltSound library The pack now stops when the ROM ends or fails to start, so looping music doesn't outlive it; each start is counted, so the end of a stopped earlier run can't stop the pack of the retry. An AltSound library that can't be loaded reports AltSound unavailable instead of failing the ROM's start.
1.1.2 adds the OnSoundCommand event that AltSound needs.
…he ROM libaltsound now mixes at the packs' 44.1 kHz: at the output rate, its own resampling (miniaudio's engine, low-pass off) put images of the treble into the audible band about 20 dB under the music, which sounded like hiss and grit. The plugin converts the mix with a 64-tap windowed-sinc resampler instead (spurs below -80 dB) and applies the pack's volume there, up to 200% and no longer scaled by the ROM volume. The game's own volume setting no longer scales the pack unless 'Follow the game's volume' is on; the wrapper keeps tracking it, so the option applies at once. The pinned libaltsound gets one more fix: a stream silenced by a zero game volume came back as NaN. Unity playback without the mixer waits for a little audio before it starts, since the mix arrives in bursts.
…oesn't follow it While the pack doesn't follow the game's volume it played at exactly 1, so a command to full volume looked like no command and turning following on later restored an older, lower volume. It now plays at the float just under 1, which no volume command produces.
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.
Plays AltSound packs (recorded music, callouts and effects triggered by the ROM's sound commands) instead of the ROM's own sound, as Visual PinMAME does.
Player settings
The PinMAME plugin settings get an AltSound section:
altsoundfolder. The plugin also accepts a ROM's own folder, or a folder that containsaltsound. Left empty, it looks next to VPinMAME's ROM folder and in VPE's PinMAME folder.The status lines report whether a pack plays, and why not when it doesn't.
How it works
native/AltSoundbuilds VpeAltSound, which compiles libaltsound (BSD-3-Clause, pinned atce11780) together with a small C interface. libaltsound's own API takesstd::string, which C# can't call. Every entry point runs under one lock, commands outside a running instance are dropped, and no C++ exception crosses the boundary.patches/fixes.patchjoins the sample paths of folder-based packs (Fix sample paths of folder-based packs vpinball/libaltsound#22), makesAltSoundInitfail when no samples could be loaded, and lets a stream silenced by a zero game volume come back instead of turning into NaN.compat/direntreplaces the Windows directory listing, which changed the process's current directory and couldn't nest (Windows: give each opendir() its own state and keep the current directory vpinball/libaltsound#23).PinMameAltSoundfinds the pack and starts libaltsound at 44.1 kHz, the packs' rate: at the output rate, libaltsound's own resampling (miniaudio's engine, which runs without its low-pass filter) put images of the treble into the audible band about 20 dB under the music, heard as hiss. The plugin converts the mix to the output rate with a 64-tap windowed-sinc resampler (spurs below -80 dB) and applies the pack's volume there. It pushes the mix into a central-mixer stream on the ROM bus, or into a ring the engine's audio filter plays when the mixer is off (it waits for a little audio first, since libaltsound delivers in bursts). Commands arrive through pinmame-dotnet's newOnSoundCommandevent, the hardware generation is set when the game starts, and the pack pauses with the game.Testing
Order
Uses the
OnSoundCommandevent from vpinball/pinmame-dotnet#48, released as PinMame 1.1.2;PinMameVersionis bumped to it here.