[Bugfix] Sound.play_varied() restores pitch/volume immediately after play(), cancelling the variation #407
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#407
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while working #394.
PySound::py_play_variedapplies the randomised pitch/volume, callsplay(), then immediatelyrestores the originals:
The comment is wrong for the OpenAL backend.
sf::Sound::setPitch/setVolumemap toalSourcef(AL_PITCH / AL_GAIN), which apply live to an already-playing source — they are notsampled once at
play(). So the restore un-varies the playback essentially instantly.Corroborated: while
sound.playingisTrueimmediately afterplay_varied(),sound.pitchreadsback the original value, i.e. the live source pitch is the original, not the drawn one.
If that is right,
play_varied()has never audibly varied anything, and the feature is a no-op witha plausible-looking implementation. Worth confirming by ear before choosing a fix; the fix is
probably to stop restoring (and document that
play_variedleaves the varied values on the object),or to hold the variation for the lifetime of the playback.
Related but separate: as of #394
play_varied()returns the(pitch, volume)it drew, so the drawis at least observable from Python now — that is what made it testable. This issue is about whether
the draw ever reaches the speakers.
Reviewer note from the #394 review (commit
ac29b35), for whoever picks this up.A mutation that makes
py_play_variedcompute the varied pitch/volume, return them, but applythe originals to the source before
play()survives all three of #394's test files green:So the returned tuple is gated as the values that were drawn — which is exactly what its docstring
claims and what #394 needed — but nothing anywhere gates that those values were the ones actually
handed to the source. That is not a defect in #394 (the draw is what it set out to make observable),
but it is the same hole this issue is about, one layer up: today
play_variedcould stop varyinganything at all and no test would notice.
When this is fixed, the fix should come with an assertion that closes that: after
play_varied()returns, while
sound.playingisTrue,sound.pitch/sound.volumeshould read back thedrawn values rather than the originals. That assertion is only writable once the restore is
removed, which is what makes it the right gate to add here rather than in #394.