add music audio bus
This commit is contained in:
parent
05aeb62242
commit
76497fb600
|
@ -522,21 +522,27 @@ Object.hide = function(obj,...props)
|
|||
{
|
||||
for (var prop of props) {
|
||||
var p = Object.getOwnPropertyDescriptor(obj,prop);
|
||||
if (!p) {
|
||||
console.error(`No property of name ${prop}.`);
|
||||
continue;
|
||||
}
|
||||
if (!p) continue;
|
||||
p.enumerable = false;
|
||||
Object.defineProperty(obj, prop, p);
|
||||
}
|
||||
}
|
||||
|
||||
Object.enumerable = function(obj, val, ...props)
|
||||
{
|
||||
for (var prop of props) {
|
||||
p = Object.getOwnPropertyDescriptor(obj,prop);
|
||||
if (!p) continue;
|
||||
p.enumerable = val;
|
||||
Object.defineProperty(obj, prop, p);
|
||||
}
|
||||
}
|
||||
|
||||
Object.unhide = function(obj, ...props)
|
||||
{
|
||||
for (var prop of props) {
|
||||
var p = Object.getOwnPropertyDescriptor(obj,prop);
|
||||
if (!p)
|
||||
continue;
|
||||
if (!p) continue;
|
||||
p.enumerable = true;
|
||||
Object.defineProperty(obj, prop, p);
|
||||
}
|
||||
|
|
|
@ -290,6 +290,13 @@ window.doc = {};
|
|||
window.doc.dimensions = "Window width and height packaged in an array [width,height]";
|
||||
window.doc.title = "Name in the title bar of the window.";
|
||||
window.doc.boundingbox = "Boundingbox of the window, with top and right being its height and width.";
|
||||
window.__proto__.toJSON = function()
|
||||
{
|
||||
return {
|
||||
size: this.size,
|
||||
fullscreen: this.fullscreen,
|
||||
};
|
||||
}
|
||||
|
||||
global.mixin("scripts/input");
|
||||
global.mixin("scripts/std");
|
||||
|
|
|
@ -22,10 +22,17 @@ audio.bus.master = dspsound.master();
|
|||
audio.dsp = {};
|
||||
audio.dsp = dspsound;
|
||||
|
||||
audio.cry = function(file)
|
||||
|
||||
audio.bus.master.__proto__.imgui = function()
|
||||
{
|
||||
this.volume = imgui.slider("Volume", this.volume);
|
||||
this.off = imgui.checkbox("Mute", this.off);
|
||||
}
|
||||
|
||||
audio.cry = function(file, bus = audio.bus.master)
|
||||
{
|
||||
file = Resources.find_sound(file);
|
||||
var player = audio.play(file);
|
||||
var player = audio.play(file, bus);
|
||||
if (!player) return;
|
||||
|
||||
player.guid = prosperon.guid();
|
||||
|
@ -50,19 +57,19 @@ var song;
|
|||
audio.music = function(file, fade = 0.5) {
|
||||
file = Resources.find_sound(file);
|
||||
if (!fade) {
|
||||
song = audio.play(file);
|
||||
song = audio.play(file, audio.bus.music);
|
||||
song.loop = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!song) {
|
||||
song = audio.play(file);
|
||||
song = audio.play(file, audio.bus.music);
|
||||
song.volume = 1;
|
||||
// tween(song,'volume', 1, fade);
|
||||
return;
|
||||
}
|
||||
|
||||
var temp = audio.play(file);
|
||||
var temp = audio.play(file, audio.bus.music);
|
||||
if (!temp) return;
|
||||
|
||||
temp.volume = 1;
|
||||
|
@ -73,11 +80,8 @@ audio.music = function(file, fade = 0.5) {
|
|||
song.loop = true;
|
||||
}
|
||||
|
||||
audio.dsp.mix = function(to) {
|
||||
var n = audio.dsp.mix();
|
||||
if (to) n.plugin(to);
|
||||
return n;
|
||||
};
|
||||
audio.bus.music = audio.dsp.mix();
|
||||
audio.bus.music.plugin(audio.bus.master);
|
||||
|
||||
audio.dsp.allpass = function(secs, decay) {
|
||||
var composite = {};
|
||||
|
@ -106,6 +110,8 @@ audio.dsp.doc = {
|
|||
red: "Red noise"
|
||||
};
|
||||
|
||||
audio.dsp.obscure('doc');
|
||||
|
||||
Object.mixin(audio.bus.master.__proto__, {
|
||||
get db() { return 20*Math.log10(Math.abs(this.volume)); },
|
||||
set db(x) { x = Math.clamp(x,-100,0); this.volume = Math.pow(10, x/20); },
|
||||
|
|
|
@ -2037,7 +2037,7 @@ JSC_GETSET(window, sample_count, number)
|
|||
|
||||
static const JSCFunctionListEntry js_window_funcs[] = {
|
||||
CGETSET_ADD(window, fullscreen),
|
||||
CGETSET_ADD(window, title,)
|
||||
CGETSET_ADD(window, title),
|
||||
CGETSET_ADD(window, vsync),
|
||||
CGETSET_ADD(window, enable_clipboard),
|
||||
CGETSET_ADD(window, enable_dragndrop),
|
||||
|
|
Loading…
Reference in a new issue