Audio Lag Fix

Hello @Fornoreason1000, I tried to used your plugin and it helps to remove the sound delay when i deployed in android app. But the problem is, I have an error that says


function Html5Audio() {
throw new Error('This is a static class');
}




that's what the error throws. 


The event that i set is:

Spoiler
chwHB7.jpg



I'm not sure if line 134 of your plugin is what the error throws.


I tried to remove your plugin and it works but there's a sound delay 🙁 . I don't want to remove it because it removes the delay when deploying on android.


I Hope that it will be fixed hehehe. Thank you so much in advance 🙂


EDIT: I didn't encounter any error when i tried a playtest. In my case the error prompt only on android application.


EDIT: line 136 sorry.
So far, it seems to be working for me. Haven't done a ton of testing, though.

I have a question, though. What are the terms of use on this? Commercial? Non-Commercial? Do we need your permission or is it alright simply to credit you?
Could someone else verify if they can get this plugin to work with Izy's Radio Vehicle? I really don't want to abandon either plugin ;(

you don't need to , because the two scripts are compatible with each other. what you were experiencing was a bug caused by the pitch modifier in my script. the bug does not occur anywhere else because it was necessary to supply a pitch value, but in Izzys Vehicle Radio, they're was no need. the pitch would default to undefined or 0 , and the sound would play at a really really slow and undetectable rate.

I will update my script in a hour or so

Hello @Fornoreason1000, I tried to used your plugin and it helps to remove the sound delay when i deployed in android app. But the problem is, I have an error that says


function Html5Audio() {
throw new Error('This is a static class');
}

I'm not sure if line 134 of your plugin is what the error throws.


I tried to remove your plugin and it works but there's a sound delay 🙁 . I don't want to remove it because it removes the delay when deploying on android.


I Hope that it will be fixed hehehe. Thank you so much in advance 🙂
EDIT: I didn't encounter any error when i tried a playtest. In my case the error prompt only on android application.
EDIT: line 136 sorry.


I haven't built an Android in RPGmaker mainly to the Hideous and Hacky process it entails. but I know Web Audio is not well supported on Android which is why RPGmakerMV implemented a HTML5 version.


The script only modifies the WebAudio implementation if you look at that line i assume it is "return HTML5Audio;"? that line calls the default HTML5 done by RPGmakerMV.
"RPGmakerMV" said:
We use HTML5 Audio to play BGM instead of Web Audio API
because decodeAudioData() is very slow on Android Chrome.
My Suggestion is to turn this script off then see if it does it. the HTML5 version shouldn't have the Lag issue anyway so this script probably will not do anything for you. If there is Lag when using HTML, I'll see if i can cook something up. I do find it strange that you can even get that error


So far, it seems to be working for me. Haven't done a ton of testing, though.

I have a question, though. What are the terms of use on this? Commercial? Non-Commercial? Do we need your permission or is it alright simply to credit you?


The Idea i had when making this script is to make a community available plugin fix that solve this irritable immersion breaking bug so that users who have purchased RPGmaker can use iot to make a professional quality game. The "Terms of Use" is pretty much open source. You can use it for Non-Commerical, Commercial, Educational etc. You do not need my permission to use this script in a Commerical RPGMakerMV game. It is Ok to Simply Credit me .
you don't need to , because the two scripts are compatible with each other. what you were experiencing was a bug caused by the pitch modifier in my script. the bug does not occur anywhere else because it was necessary to supply a pitch value, but in Izzys Vehicle Radio, they're was no need. the pitch would default to undefined or 0 , and the sound would play at a really really slow and undetectable rate.

I will update my script in a hour or so




I haven't built an Android in RPGmaker mainly to the Hideous and Hacky process it entails. but I know Web Audio is not well supported on Android which is why RPGmakerMV implemented a HTML5 version.


The script only modifies the WebAudio implementation if you look at that line i assume it is "return HTML5Audio;"? that line calls the default HTML5 done by RPGmakerMV.

My Suggestion is to turn this script off then see if it does it. the HTML5 version shouldn't have the Lag issue anyway so this script probably will not do anything for you. If there is Lag when using HTML, I'll see if i can cook something up. I do find it strange that you can even get that error





The Idea i had when making this script is to make a community available plugin fix that solve this irritable immersion breaking bug so that users who have purchased RPGmaker can use iot to make a professional quality game. The "Terms of Use" is pretty much open source. You can use it for Non-Commerical, Commercial, Educational etc. You do not need my permission to use this script in a Commerical RPGMakerMV game. It is Ok to Simply Credit me .

Ah that makes sense. Thanks for getting back to me 🙂
My Suggestion is to turn this script off then see if it does it. the HTML5 version shouldn't have the Lag issue anyway so this script probably will not do anything for you. If there is Lag when using HTML, I'll see if i can cook something up. I do find it strange that you can even get that error

Thank you for your reply 🙂

It's my fault. Sorry, As i've checked, the audio file is the problem and It has no file size.
This really has helped my project a lot! I'd be all for every type of sound playing in this way! Thank you for this, really have to say.

However... I have two things I want to mention, the first being a bug, the second being a request/question.

First, the bug: BGM doesn't play when you deploy a game, and encrypt the audio files. SE play, because those are running off of the older way of loading sounds. I've seen this issue in other plugins (like Galenmereth's Preload Manager for example can't run anything encrypted, images or audio). Encrypted files can be read... somehow, as the default code manages to read them, but this plugin doesn't seem to be able to yet.

Secondly: you mention being able to loop audio through notepad documents, since the old loop method doesn't work any more? How would I do this? Or, is there a link to somewhere else that I could see how to do this?
Sorry to bother you with another compatibility request, but could you add in a patch for the Codec System plugin? BGM seems to stop after any codec call. D:
Hello, I always have a sound delay with some BGM musics. But my music file weighs 8.6MB. It's too much for your plugin or not?
What is the maximum weight you recommend?
Hello, I always have a sound delay with some BGM musics. But my music file weighs 8.6MB. It's too much for your plugin or not?
What is the maximum weight you recommend?

file size shouldn't be a problem. my 10minute test was around 11.5MB and it had no effect. Th plugin works by loading only some of the data for the sound directly from the HDD (Hard drive / Server) instead of loading all of it into memory (RAM) and decoding it all. That said , the is no real virtual limit on file size, only the quality.

If you experience lag with this plugin. let me know via PM or this thread. if you experience stuttering between maps, see the known issues section of the plugin. I recommend you check that section anyway.
With your plugin, I always have a lag, but I notice a slight improvement (1 or 2 seconds). It's not between a map. 😉
I took my musics from YouTube and I converted in .ogg 320kbps with http://www.onlinevideoconverter.com/fr/mp3-converter
If you experience lag with this plugin. let me know via PM or this thread.
Should I give you more information? And if yes, how?^^
With your plugin, I always have a lag, but I notice a slight improvement (1 or 2 seconds). It's not between a map. 😉
I took my musics from YouTube and I converted in .ogg 320kbps with http://www.onlinevideoconverter.com/fr/mp3-converter

Should I give you more information? And if yes, how?^^

320kps is a very high bit rate. in fact anything above that and its potentially just a waste. I'm going to assume you had permission to record the audio of those YouTubers and not planning on releasing commercial products with them.

Now, I tired with a 500kbs and can't produce the lag. if you press F8 when it lags do any errors message show up? (RED) if so, could you make a screenshot of it. Are you testing this on an Android or PC?
Of course, it's non-commercial. 😉
Which rate do you recommend?
1488596708-1.png

I am on Mac.
I recommend 196kbs, although , that will scarcely affect the issue here, if its lagging heaps on 320kps and it still will on 196kps. now when you run your game, how long does the console sit on "stream is null, waiting"? is it instantaneous or does it hang there? if not there does it hang on one message at all before reaching "connecting nodes"?

And your Audio you got from YouTube, did you check that it has no silence at the start? (Audacity is a free Audio editor if you need one).
When my character walks on the event with the music, "Stream is null, waiting" appears immediately, but the music appears 2 seconds later.
if not there does it hang on one message at all before reaching "connecting nodes"?
all messages are displayed at one time, as a block. There is no hang on.

My english isn't very good, and I am not an expert about technique. I hope I have understood and answered your questions.
1488596708-2.png
removed
Hey, hopefully this is the plugin I've been looking for.
Problem is, when I go to playtest my game with your plugin on, it comes up with an error saying-

"Reference Error
Decrypter is not defined"

Any idea how I can fix this?
Thank you so much. It works fine on my game.
My main issue was on the title screen.
Hey, hopefully this is the plugin I've been looking for.
Problem is, when I go to playtest my game with your plugin on, it comes up with an error saying-

"Reference Error
Decrypter is not defined"

Any idea how I can fix this?

Yes, check your RPGmaker MV version, if possible update it to 1.4
Also check that your core scripts are at 1.4, because I've personally had issue of them not updating to 1.4.
So, not sure what's causing it, but upon changing from V 068 to 0.71, the game keeps crashing from both combat and pausing. To the best of my knowledge, my game is MV version 1.4.0. When I enter combat, the game crashes, and displays this:

Spoiler: Error
TypeError: Cannot read property 'name' of null
at Function.AudioManager.saveBgs (/C:/Users/Brian/Documents/Games/NameOfMyGame/js/plugins/DSE-AUDIOLAG-FIX.js:296)
at Function.BattleManager.saveBgmAndBgs (rpg_managers.js:2007)
at Scene_Map.launchBattle (rpg_scenes.js:636)
at Scene_Map.stop (rpg_scenes.js:440)
at Function.SceneManager.goto (rpg_managers.js:1879)
at Function.SceneManager.push (rpg_managers.js:1885)
at Game_Interpreter.command301 (rpg_objects.js:10118)
at Game_Interpreter.executeCommand (rpg_objects.js:8922)
at Game_Interpreter.update (rpg_objects.js:8830)
at Game_Map.updateInterpreter (rpg_objects.js:6107)
at Game_Map.update (rpg_objects.js:6014)
at Scene_Map.updateMain (rpg_scenes.js:420)
at Scene_Map.updateMainMultiply (rpg_scenes.js:412)

And when pausing the game/loading the team menu, this error happens:

Spoiler: Error
Error: Failed to execute 'createMediaElementSource' on 'AudioContext': HTMLMediaElement already connected previously to a different MediaElementSourceNode.
at Error (native)
at DSEIV.AudioBuffer.createSourceNode (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/plugins/DSE-AUDIOLAG-FIX.js:1082:36)
at DSEIV.AudioBuffer.createNodes (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/plugins/DSE-AUDIOLAG-FIX.js:1070:10)
at DSEIV.AudioBuffer.startPlayingWebAudio (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/plugins/DSE-AUDIOLAG-FIX.js:901:10)
at DSEIV.AudioBuffer.play (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/plugins/DSE-AUDIOLAG-FIX.js:859:18)
at Function.AudioManager.playStaticSe (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/plugins/DSE-AUDIOLAG-FIX.js:472:18)
at Function.SoundManager.playSystemSound (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/rpg_managers.js:1346:22)
at Function.SoundManager.playOk (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/rpg_managers.js:1355:10)
at Scene_Map.callMenu (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/rpg_scenes.js:599:18)
at Scene_Map.updateCallMenu (file:///C:/Users/Brian/Documents/Games/NameOfMyGame/js/rpg_scenes.js:583:18)rpg_managers.js:1756 SceneManager.catchException

All other plugins are turned off when testing, the main RPG js files are untouched from the 1.4.0 update. When I turn this plugin off, combat and pausing work fine. In addition, reverting it back to V 0.68 makes combat and pausing work.

If you have any other questions, I'll be glad to provide as much information as I can!
Hello,

I have this message if the plugin is turn on.
This is when I click on an event to take an object.
1494314882-capture-d-ecran-2017-05-09-a-13-23-45.png

Original thread: https://forums.rpgmakerweb.com/threads/audio-lag-fix.73031/