Sound Effects of the same name shouldn't stack. #125

Open
opened 2015-07-15 04:27:25 +00:00 by sorlok · 5 comments
sorlok commented 2015-07-15 04:27:25 +00:00 (Migrated from github.com)

If you have a script with the following:

for i in 0..20
  Sound.play_decision
end

...RPG Maker will only play the sound once, while MKXP will "stack" the sound on top of itself. There is either a timeout on sounds with the same filename, or there is handled some other way.

To determine that this is actually how RPG Maker works, I recorded a sound being played once, followed by that sound being played 20 times in both RPG Maker VX and MKXP on Windows. You can clearly see that the waveform is unaffected in RPG Maker, but affected in MKXP. (In Linux, this distortion can actually be heard.)

waveform

For my own purposes, I solved the problem this way:
https://github.com/sorlok/mkxp/blob/ld_hacks/src/audio.cpp#L313

Perhaps this isn't really an issue for most games? Stacking sound effects is certainly bad design. Anyway, just thought I'd bring this to your attention.

If you have a script with the following: ``` for i in 0..20 Sound.play_decision end ``` ...RPG Maker will only play the sound once, while MKXP will "stack" the sound on top of itself. There is either a timeout on sounds with the same filename, or there is handled some other way. To determine that this is actually how RPG Maker works, I recorded a sound being played once, followed by that sound being played 20 times in both RPG Maker VX and MKXP on Windows. You can clearly see that the waveform is unaffected in RPG Maker, but affected in MKXP. (In Linux, this distortion can actually be heard.) ![waveform](https://cloud.githubusercontent.com/assets/513512/8690846/ca8c4b56-2a87-11e5-9657-0a002144de75.png) For my own purposes, I solved the problem this way: https://github.com/sorlok/mkxp/blob/ld_hacks/src/audio.cpp#L313 Perhaps this isn't really an issue for most games? Stacking sound effects is certainly bad design. Anyway, just thought I'd bring this to your attention.
Ancurio commented 2015-07-15 16:50:14 +00:00 (Migrated from github.com)

Ah yes, I've dealt with this problem before. Specifically, in a game which displayed each letter of a message box separately and made a typewriter kind of noise for each letter. RMVXA actually ate every 2nd or 3rd of those sounds and made it sound very unnatural, so to be honest, I'm not sure if the behavior in RMVXA is even intentional or just some obscure implementation detail of the sound backend they use.

It certainly wouldn't be wrong to at least introduce some kind of throttling in mkxp, at least for all sound instances played during the same frame. Since you already started experimenting, would you mind finding out what the threshold for RMXP/VXA is before a sound is "swallowed", and if it's related to the current graphics frame at all? (I suspect not)

Ah yes, I've dealt with this problem before. Specifically, in a game which displayed each letter of a message box separately and made a typewriter kind of noise for each letter. RMVXA actually ate every 2nd or 3rd of those sounds and made it sound very unnatural, so to be honest, I'm not sure if the behavior in RMVXA is even intentional or just some obscure implementation detail of the sound backend they use. It certainly wouldn't be wrong to at least introduce some kind of throttling in mkxp, at least for all sound instances played during the same frame. Since you already started experimenting, would you mind finding out what the threshold for RMXP/VXA is before a sound is "swallowed", and if it's related to the current graphics frame at all? (I suspect not)
cremno commented 2015-07-15 16:54:29 +00:00 (Migrated from github.com)

From the help file(s):

When attempting to play the same SE more than once in a very short period, they will automatically be filtered to prevent choppy playback.

From the help file(s): > When attempting to play the same SE more than once in a very short period, they will automatically be filtered to prevent choppy playback.
Ancurio commented 2015-07-15 16:55:31 +00:00 (Migrated from github.com)

Now, to find out what "short period" means :)

Now, to find out what "short period" means :)
sorlok commented 2015-07-15 18:10:51 +00:00 (Migrated from github.com)

Sure, I'll dig into it. I expect it'll be somewhere around ~50ms, and I agree that it's not likely to be related to the current graphics frame (because I added "sleep" statements to the sample code and then all the sounds played in RMVX).

Sure, I'll dig into it. I expect it'll be somewhere around ~50ms, and I agree that it's not likely to be related to the current graphics frame (because I added "sleep" statements to the sample code and then all the sounds played in RMVX).
sorlok commented 2015-07-15 22:56:12 +00:00 (Migrated from github.com)

Looks like I was way off: it's actually 1ms:

audio_2

I would hazard a guess that they don't even test actual time deltas; they just check if time_in_ms() > last_time_in_ms() for each filename.

Looks like I was way off: it's actually 1ms: ![audio_2](https://cloud.githubusercontent.com/assets/513512/8711787/dbef9ace-2b09-11e5-9913-2bf838b405c5.png) I would hazard a guess that they don't even test actual time deltas; they just check if time_in_ms() > last_time_in_ms() for each filename.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: MapleShrine/mkxp#125
No description provided.