Sound effects in cutscenes occasionally "blip out"

Greetings,

I am having an issue I've as yet been unable to solve. Sometimes sound effects do not play properly in events. This is a bug that is not easily replicable, as about 80% of the time the sound effects play properly even with no changes whatsoever to the event from the bugged version.

For example, take this event:

sound effects bug.png


I am attempting to create an event that is someone knocking at the door. I have added small waits to pace out the sound effects so it, consequently, sounds like someone knocking at the door.

However, about 20% of the time when I play this event here, the sound effects jumble together as if the wait commands were ignored. For other, similar events, like a SE played when a player transitions to a different map (think opening a door SE), the SE will be cutoff and the only audio the player will hear is the latter half of the SE.

I have been unable to figure out how to fix it, and I am starting to believe it is an error within the RPG Maker MZ engine itself and not something I will be able to fix.

Does anyone out there have any additional information about this issue?

Thank you in advance,
-Niniann
For something specific and premade like this, you could use Audacity to put the knocks together and play one sound effect.

I think it might be difficult to time sound files so exactly in a fraction of a second with possible file loading delays.
That is an excellent idea and something I will definitely keep in mind. I do have Audacity already, will have to brush up on using the tool a bit but what you're saying shouldn't be too difficult.

That being said, take a look at this event:

sound effects bug2.png


This event has the exact same bug as the knocks. About 80% of the time it plays correctly. 20% of the time or so, the first half of the SE will not play, the player will only hear the last 10 frames or whatever worth of sound.

Do you think running SE's within a move route is just partially non-functional due to the file loading delays of the game engine?
The core engine starts playing an audio track once it is ready, i.e. the data is loaded and, if appropriate, decrypted. Some contexts can't play OGG natively, thus need to resort to the built-in software decoder, which decodes in chunks...but playtest (Chromium) ought to be totally OK with OGG, so that's a moot point. 😴

Slow loading might result in an SE being played late, like in your first case. It might be due to direct interference from external applications, or simply because the disk is busy with other stuff at the moment.

Turan's suggestion of merging the sequence into 1 file is good. In case you want to investigate the cause, you could try using one of the first 4 system SEs (Cursor, OK, Cancel, Buzzer) instead, using one of these lines in a Script move command:

SoundManager.playCursor(); SoundManager.playOk(); SoundManager.playCancel(); SoundManager.playBuzzer();
System SEs are defined on the left side of the System 1 tab in the database. The first 4 are preloaded when the game launches, so they should have no load delay. These are uniquely buffered, though, so e.g. Cursor cannot overlap with Cursor.

The core Play SE command redirects to AudioManager.playSe(obj) regardless of whether it triggers from a move route or an event command. And the engine makes a new audio buffer for every SE, so overlap should not be an issue in any case.

For your second case: does the audio clip back in, or does it fade in? I imagine it'll clip if there is missing or invalid data. If it's fading in instead, that might suggest there's an anti-noise filter and/or dynamic range compression being applied by sources such as your system audio driver enhancements, a third-party app, or a plugin in your game.

Also, does the period of silence/quiet include all audio, or just this SE? Might help to narrow down the exact cause.
The core engine starts playing an audio track once it is ready, i.e. the data is loaded and, if appropriate, decrypted. Some contexts can't play OGG natively, thus need to resort to the built-in software decoder, which decodes in chunks...but playtest (Chromium) ought to be totally OK with OGG, so that's a moot point. 😴

Slow loading might result in an SE being played late, like in your first case. It might be due to direct interference from external applications, or simply because the disk is busy with other stuff at the moment.

Turan's suggestion of merging the sequence into 1 file is good. In case you want to investigate the cause, you could try using one of the first 4 system SEs (Cursor, OK, Cancel, Buzzer) instead, using one of these lines in a Script move command:

SoundManager.playCursor(); SoundManager.playOk(); SoundManager.playCancel(); SoundManager.playBuzzer();

System SEs are defined on the left side of the System 1 tab in the database. The first 4 are preloaded when the game launches, so they should have no load delay. These are uniquely buffered, though, so e.g. Cursor cannot overlap with Cursor.

The core Play SE command redirects to AudioManager.playSe(obj) regardless of whether it triggers from a move route or an event command. And the engine makes a new audio buffer for every SE, so overlap should not be an issue in any case.

For your second case: does the audio clip back in, or does it fade in? I imagine it'll clip if there is missing or invalid data. If it's fading in instead, that might suggest there's an anti-noise filter and/or dynamic range compression being applied by sources such as your system audio driver enhancements, a third-party app, or a plugin in your game.

Also, does the period of silence/quiet include all audio, or just this SE? Might help to narrow down the exact cause.
I fully realize this is a thread necro, but since this problem was never solved and it's my original thread on the topic, I believe it is okay to do per the forum rules 🙂.

First, my apologies on taking so long in replying to this thread, at the time I was just so busy I completely forgot about it.

So, long story short, I've never been able to fix this SE issue. I'd like to compile some more info in the hopes I can get some additional assistance in solving it.

To answer caethyril's questions: I believe the audio clips back in (to be honest i'm not entirely sure if I can audibly tell the difference, but it does sound more like a sudden jerk of sound. Still, it could be the sound fading in as its always the latter frames of the SE's being played). There is no other audio playing at the moment this occurs as it's meant to be a mostly silent event. There are other SE's that play earlier in the event, and they also sometimes clip. However, no particular sound always clips, most of the time they play perfectly fine, so I don't think there is anything wrong with the SE files themselves.

Plugin wise, for more info, I believe the only sound related plugins I am using are the Visustella Core Engine and Tea Proximity Sound (although Tea++'s plugin isn't used anywhere in these events and is not running anything parallel on the map).

Edit: I would also like to point out that sometimes SEs do this exact effect in the Sound Test section of the editor.

Edit2: I am able to reliably replicate the SE bug in the Sound Test section by simply browsing the internet for about 5 minutes, opening up the Sound Test in RPG Maker MZ, and playing an SE. The first time an SE is played, it will always "glitch out" and only play the last 10 frames or so of the SE. It does seem to me like it's fading in the SE for whatever reason. I have no idea if this is related to SE's not properly playing in events, but perhaps?

Edit3: After a few hours of experimentation I have found a functional work-around for this bug. I can "pre-load" any SEs on a map (through an autorun event that plays all the SEs at 0 volume). This will result in the SEs no longer glitching out when they are played properly later in a cutscene, on the map, etc. I don't know the cause of this issue, but I suspect there is some sort of lag with how the RPG Maker MZ engine loads SEs the first time they are played on a map, and it can result in glitched out sound effects. By playing the SEs earlier on the map at 0 volume, the SEs are already loaded, and will play properly the next time they are called.

I don't want to report this issue as solved to the mods just yet as it technically is not, I've simply found a functional work-around. So if anyone else may have insight on how to actually fix this bug, I would still greatly appreciate it 🙂. For now, I'll simply work with what I've got.
Yep, bumping your own unsolved thread is OK~ 👋

Edit: I would also like to point out that sometimes SEs do this exact effect in the Sound Test section of the editor.
OK, that's significant: the issue is not limited to the game's app/code. Ideas:
  1. Does it happen even with the default audio files?
    • If not, what are the typical bitrate/file size values for the problematic audio files? Maybe you can fix it by reducing the audio quality and/or changing the compression level (less compression means larger file size but less decode time).

  2. Does it happen if you play the audio in, say, your browser or a desktop audio player?
    • More sophisticated/dedicated audio players will tend to stream the data rather than load it up-front like MZ does. Streaming audio typically removes any noticeable load delay.

  3. Have you ever seen this kind of problem in other games etc?
    • If so, it might be related to a real-time security scan, or perhaps your audio driver.

There is no other audio playing at the moment this occurs as it's meant to be a mostly silent event.
The reason I asked is because it might have been a global system audio enhancement, e.g. some kind of noise cancellation.

I have found a functional work-around for this bug. I can "pre-load" any SEs on a map (through an autorun event that plays all the SEs at 0 volume). This will result in the SEs no longer glitching out when they are played properly later in a cutscene, on the map, etc.
Neat! Hopefully that will fix it for players, too. Based on your description, it seems like some kind of load and/or decode delay. If it happens per-session, perhaps some real-time security feature is scanning the audio file and/or game before flagging it as "safe"?

As far as I know, without plugins, the engine only has persistent buffers for system sounds. Perhaps the app (browser) has some kind of automatic cache system for audio. The only system like that of which I'm aware is the Cache API, though, which I don't think the core scripts use.

I did find this MZ plugin with a quick search, maybe it'll help?
Yep, bumping your own unsolved thread is OK~ 👋


OK, that's significant: the issue is not limited to the game's app/code. Ideas:
  1. Does it happen even with the default audio files?
    • If not, what are the typical bitrate/file size values for the problematic audio files? Maybe you can fix it by reducing the audio quality and/or changing the compression level (less compression means larger file size but less decode time).

  2. Does it happen if you play the audio in, say, your browser or a desktop audio player?
    • More sophisticated/dedicated audio players will tend to stream the data rather than load it up-front like MZ does. Streaming audio typically removes any noticeable load delay.

  3. Have you ever seen this kind of problem in other games etc?
    • If so, it might be related to a real-time security scan, or perhaps your audio driver.


The reason I asked is because it might have been a global system audio enhancement, e.g. some kind of noise cancellation.


Neat! Hopefully that will fix it for players, too. Based on your description, it seems like some kind of load and/or decode delay. If it happens per-session, perhaps some real-time security feature is scanning the audio file and/or game before flagging it as "safe"?

As far as I know, without plugins, the engine only has persistent buffers for system sounds. Perhaps the app (browser) has some kind of automatic cache system for audio. The only system like that of which I'm aware is the Cache API, though, which I don't think the core scripts use.

I did find this MZ plugin with a quick search, maybe it'll help?
Apologies in advance for another necro on my thread. This issue still persists and I am unable to find any soluton.

To add some more fuel to the fire, I have a new similar issue with event that reads as follows:

Capture.PNG

In this event, about 10% of the time, the SE simply does not play. The picture will appear without any sound played whatsoever. I do not have a clue why 90% of the time the event works as setup and 10% of the time it simply does not play the SE.

This event is on the very first screen you see when starting a new game. There is nothing else on the map, it is blank, there is just this one autorun event showing a tutorial on game controls. There are no previous pages of anything running or having been ran.

Caethyril, if you happen to read this, I apologize for not responding to the assistance you provided. At the time I just needed to move on with other work on the project since my ad hoc "fix" sorta-kinda put a workable bandaid on the problem. But the sound blipping out still occurs, just rarer than it used to be.

I wanted to go ahead and answer the questions posed earlier in the thread by Caethyril.

1. Yes, it happens with default and custom audio files. Doesn't seem to be an issue related to any audio file in particular.

2. I have never heard this issue occur when playing sound effects in Audacity or in a browser...but hard for me to know for sure that this would never occur outside of the RPG Maker engine, I can only say that I have not had this issue occur anywhere else BUT my game's SE when I play it and the RPG Maker Editor's own Sound Test at this point.

3. I have not had this issue in any other game that I have played, and I've played quite a few haha.


Also, I want to add that while my girlfriend also experiences this issue on her computer, I have not had anyone who has played our game report this sound issue to us, and we've a had a decent chunk of people play the game since launching the demo on Steam. She uses a similar gaming laptop to my own, so part of me thinks it is some sort of issue with the sound hardware we have and how RPG Maker processes SEs. I really don't know. Of course, this doesn't mean users aren't running into the issue, only that they aren't telling us if they are.

PS: I tried the plugin you recommended, including running the script the plugin dev recommended in an if statement to ensure audio is loaded before displaying the picture, but it had no noticeable effect; the issue still occurs.
@Niniann Have you tried add a wait command before play se? For example, wait for 10 frame to see if there's still the issue?
@Niniann Have you tried add a wait command before play se? For example, wait for 10 frame to see if there's still the issue?
utunnels,

Thank you for the reply and suggestion! I have tried adding waits as that was something I had thought of in the past as well, that maybe there just needed to be a little lag time between the engine processing a move route or whatever and the SE.

Unfortunately adding waits has no discernible effect on the sound blips / nullifies. I went ahead and, just to experiment, I added a 10 frame wait to the event I linked earlier before the sound plays. It also had no effect: after booting the game up and hitting new game 20 times with the 10 frame wait included, 5 times the SE did not play, and 15 times it did play.
Interesting.
I can confirm your problem using a new project or a visustella project.
When I start a new game for the first and second time, there's no problem.
However, after the 3rd try the sound doesn't play anymore, unless:
1. Load a saved game
2. Start a battle
3. Press F5

At first I thought I press start too fast, but it seems after the 3rd try the sound won't play anymore.

Edit*
I think I found the culprit.
It is because Graphics.frameCount is reset very time you start a new game.
And for some reason AudioManager._seBuffers doesn't clean up old values?
JavaScript:
AudioManager.playSe = function(se) {
    if (se.name) {
        // [Note] Do not play the same sound in the same frame.
        const latestBuffers = this._seBuffers.filter(
            buffer => buffer.frameCount === Graphics.frameCount
        );
        if (latestBuffers.find(buffer => buffer.name === se.name)) {
            return;
        }
        const buffer = this.createBuffer("se/", se.name);
        this.updateSeParameters(buffer, se);
        buffer.play(false);
        this._seBuffers.push(buffer);
        this.cleanupSe();
    }
};

Edit*2
Place a stop se before play se should fix the problem.
@utunnels - it's worth trying, but that wouldn't explain how it happens via the editor's Sound Test, or how it cuts off only the start of certain sounds.

I feel fairly confident that it's related in some way to how RM fully loads audio before playing, rather than streaming it like many modern applications. Though, re-reading the previous posts makes me wonder whether it is all just an aggressive Windows Audio Enhancement setting from your audio driver. Audio enhancements can be disabled via the audio device properties window, in case you want to try that. I've personally had issues related to that setting, especially with RM where the audio can be...pretty loud. 😅

I mentioned system sounds earlier, but I'm not clear whether you actually tested that. System sounds are essentially pre-buffered, eliminating the usual load/decode delay. Feature D24 of my plugin Cae_Tweaks offers plugin commands to preload audio...theoretically anyway, I didn't test the audio stuff much. Preloaded audio is loaded and packed into a static buffer, basically the same as a system SE in the core engine, which does mean it can't overlap with itself: playing a static buffer again while it's already playing will just cause it to restart.
@caethyril I have only tested the OP's last question. It is definitely a bug of the se cache.
A stop se command will clear the cache so it solves the problem.
Using frameCount to check is not a very good idea. I think that is why the command always fails on the 3rd try on my pc, it should fail on the second try too, but guess frameCount is not always the same when the se is played.

but that wouldn't explain how it happens via the editor's Sound Test, or how it cuts off only the start of certain sounds.
I haven't been able to reproduce that.
Why does it have anything to do with 'browsing the internet for 5 minutes'?
MZ uses QtWebEngine, yes, but it shouldn't share data with other browsers.
Just coming in from left field here - does the issue persist if you already have audio playing? Any kind of audio (a song in the background from a different application, or even a bgm that is currently playing).

I wonder if it is the way Windows handles audio - there is an auto-ducking feature that reduces/mutes the noise/audio for a few ms and ramps up when the device receives audio, sort of like a compress/expander. When it receives audio, it will keep the signal active for a few seconds and then ramp back down until it receives audio again.

Again, not sure if this is even the issue - I just found it interesting that when I used your commands (Knock with wait), it would never play the first knock completely, even with ample wait time. I cued up a very quiet bgm in the background and all the knocks played without issues.

Edit: I think this is it - at least for what I am currently experiencing:
Though, re-reading the previous posts makes me wonder whether it is all just an aggressive Windows Audio Enhancement setting from your audio driver.
Interesting.
I can confirm your problem using a new project or a visustella project.
When I start a new game for the first and second time, there's no problem.
However, after the 3rd try the sound doesn't play anymore, unless:
1. Load a saved game
2. Start a battle
3. Press F5

At first I thought I press start too fast, but it seems after the 3rd try the sound won't play anymore.

Edit*
I think I found the culprit.
It is because Graphics.frameCount is reset very time you start a new game.
And for some reason AudioManager._seBuffers doesn't clean up old values?
JavaScript:
AudioManager.playSe = function(se) {
    if (se.name) {
        // [Note] Do not play the same sound in the same frame.
        const latestBuffers = this._seBuffers.filter(
            buffer => buffer.frameCount === Graphics.frameCount
        );
        if (latestBuffers.find(buffer => buffer.name === se.name)) {
            return;
        }
        const buffer = this.createBuffer("se/", se.name);
        this.updateSeParameters(buffer, se);
        buffer.play(false);
        this._seBuffers.push(buffer);
        this.cleanupSe();
    }
};

Edit*2
Place a stop se before play se should fix the problem.
utunnels,

OMG! You are right! I put a stop SE event command right before the SE plays and it seems to have fixed it! Just did a test and 20 out of 20 times, the SE played!

Thank you so much for the suggestion!

Going over the rest of the suggestions now. I realized after reading through the thread and caethyril's and bass2yang's latest comments that there is a common denominator to the instances where the SE "blips" during cutscenes; it's always and only cutscenes where there is currently no BGM playing...same deal with the RPG Maker Sound Test tool, i'll usually have all other music and everything disabled when I'm using it so I can hear the SEs better.

I'm going to try something a little tricksy and play a silent BGM on these events so that Windows has "something" audio related processing and see how that effects the issue.

Edit: Just did 20 test runs of a cutscene that fairly frequently had the sound blipping out (the one I posted about in the original post). With a silent BGM (i.e. 0 volume) playing at the start of the event, no SE blips occured in all 20 tests!

I think you all may very well be right, it's something to do with Windows and the way it's processing sounds in RPG Maker. Going to do more thorough testing over the next week as 20 test runs isn't enough for me to say the issue is totally solved, but I am tentatively hoping this works to prevent the sound issue, with this silent BGM method...a little bit of a rough way to do it, but if it works, it works!

Note that this testing also included 20 more tests of a New Game being fired, and in all 20 again, the SE played as it should, with the Stop SE event command played right before the Decision SE. So I think that is working perfectly.

Thank you all so much for the assistance, I've been trying to solve this issue for over a year now and I think I may finally be approaching a method to do so!!! I will post again in this thread if I am able to get the bug to reappear even with the above methods, need much more testing to truly conclude the issue as solved.
I have only tested the OP's last question. It is definitely a bug of the se cache.
I wonder if it's worth reporting?
I think this is it - at least for what I am currently experiencing
I have never heard of that before. Guess we are living in a good time that we can learn new things every day.

I wonder if it's worth reporting?
Not sure, it is very rare and easy to fix so maybe not?
Tinkering core engine may have a chance to break things if something like a plugin happens to use that part of code.
I have never heard of that before. Guess we are living in a good time that we can learn new things every day.
I think this is common for a lot of sound devices. The gate/expander/compressor/etc is there to mask the noise floor of the device. If there is no audio information being sent to the device, it will auto-mute. It's harder to tell without headphones, of course. High end professional devices don't have this issue because of a higher bit depth (24-bit, 32-bit float, etc.) / lower noise floor. Some might still implement a gate/expander depending on the software.

If Windows or any audio device receives any command for audio, it will open the gate and allow it to come through. If it senses that there is only noise-floor, it will close the gate after a second or so to mitigate the distracting noise. Bluetooth is notorious for this because of the way it compresses and sends information.

This causes one of the "blip" issues people experience because it isn't fast enough to remove the gate (or it is a slow ramp up of audio instead, causing you to miss a small part of the first audio sample) and it doesn't always distinguish the audio source - basically, if it thinks something is playing, it will try to keep the gate open. If not, it closes.

Original thread: https://forums.rpgmakerweb.com/threads/sound-effects-in-cutscenes-occasionally-blip-out.159930/