Closed wilfrem closed 7 years ago
That's sounds good. Pleaase PR this APIs.
@wilfrem I'm trying to add master volume control.
In my implementation, only one getter-setter is defined below.
WebAudio.masterVolume
(get)(set) (min: 0, max: 1)
Is this enough for your website?
@krmbn0576 not enough. We think, it is better to modify corescript to use API than to called from platform. Because RPGAtsumaru API code is partially opened will be opened, but RPGAtsumaru's player code is not open and will not be opened. so, to implement this, need to use RPGAtsumaru API.
We modified rpgatsumaru.js and added volume api "mock" at last week. http://html5.nicogame.jp/core/player/js/rpgatsumaru.js
There are two API
window.RPGAtsumaru.volume.getCurrentValue()
and window.RPGAtsumaru.volume.changed.subscribe(observer | nextFunc)
First API is to get current volume(min: 0, max: 100. 0 to 1 range is better or not?) Last API is to subscribe volume changed event.
this is an sample to use this
if (window.RPGAtsumaru) {
WebAudio.masterVolume = window.RPGAtsumaru.volume.getCurrentValue();
window.RPGAtsumaru.volume.changed.subscribe(function(value) {
WebAudio.masterVolume = value;
});
}
Note:
RPGAtsumaru Volume API is currently mock. so getCurrentValue()
always return 100
and no changed event emitted.
@wilfrem What is your concern?
Because RPGAtsumaru API code is partially opened will be opened, but RPGAtsumaru's player code is not open and will not be opened.
I cant understand what you say. If inverting dependency, what is solved by that?
We discuss this problem which connect between API and corescript this week.
The conclusion is rpgatsumaru.js should connect between API and corescript.
So, This is enough implementation @krmbn0576 https://github.com/rpgtkoolmv/corescript/issues/70#issuecomment-291476520
just implement one getter-setter WebAudio.masterVolume
.
@liply Some RPGAtsumaru functions are implemented by RPGAtsumaru Player and calling/modifying corescript function and others directly. It's not clear which corescript items referenced by RPGAtsumaru Player because it's not opened nor well documented. So, I thought it's not good for corescript to put new RPGAtsumaru functions in the Player.
But, we are planning to put rpgatsumaru.js into github.com. So, put a code part of new RPGAtsumaru function in rpgatsumaru.js will solve the problem because the code referring to core script items is written in rpgatsumaru.js which will be opened.
I wrote this! #87
Complete!
Finally, I replaced WebAudio.masterVolume
to AudioManager.masterVolume
for clarity.
Anything else are the same as before!
Probrem
Currently, default tkool engine volumes(BGM BGS, ME, SE) are all 100%. So, when we open a game, we hear the noisy title sound many times. We just want to turn down default volume, but KADOKAWA says it's by design.
Idea(draft)
I want to put two new master volume control APIs to RPG Atsumaru API (atsumaru.js). First API will be to get current volume, other API will be to subscribe volume change event. This volume will be changed by volume control ui at RPG Atsumaru site (like Niconico Douga or Youtube)
Master volume will take effect on that 4 volumes. For example, if BGM volume will be 60% and master volume is 50%, so this game will play BGMs 30% volume.
Volume control ui will be displayed when corescript subscribe the API, because I think it's not good to display when playing a game not supported volume control APIs.