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) {
|
for (var prop of props) {
|
||||||
var p = Object.getOwnPropertyDescriptor(obj,prop);
|
var p = Object.getOwnPropertyDescriptor(obj,prop);
|
||||||
if (!p) {
|
if (!p) continue;
|
||||||
console.error(`No property of name ${prop}.`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
p.enumerable = false;
|
p.enumerable = false;
|
||||||
Object.defineProperty(obj, prop, p);
|
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)
|
Object.unhide = function(obj, ...props)
|
||||||
{
|
{
|
||||||
for (var prop of props) {
|
for (var prop of props) {
|
||||||
var p = Object.getOwnPropertyDescriptor(obj,prop);
|
var p = Object.getOwnPropertyDescriptor(obj,prop);
|
||||||
if (!p)
|
if (!p) continue;
|
||||||
continue;
|
|
||||||
p.enumerable = true;
|
p.enumerable = true;
|
||||||
Object.defineProperty(obj, prop, p);
|
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.dimensions = "Window width and height packaged in an array [width,height]";
|
||||||
window.doc.title = "Name in the title bar of the window.";
|
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.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/input");
|
||||||
global.mixin("scripts/std");
|
global.mixin("scripts/std");
|
||||||
|
|
|
@ -22,10 +22,17 @@ audio.bus.master = dspsound.master();
|
||||||
audio.dsp = {};
|
audio.dsp = {};
|
||||||
audio.dsp = dspsound;
|
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);
|
file = Resources.find_sound(file);
|
||||||
var player = audio.play(file);
|
var player = audio.play(file, bus);
|
||||||
if (!player) return;
|
if (!player) return;
|
||||||
|
|
||||||
player.guid = prosperon.guid();
|
player.guid = prosperon.guid();
|
||||||
|
@ -50,19 +57,19 @@ var song;
|
||||||
audio.music = function(file, fade = 0.5) {
|
audio.music = function(file, fade = 0.5) {
|
||||||
file = Resources.find_sound(file);
|
file = Resources.find_sound(file);
|
||||||
if (!fade) {
|
if (!fade) {
|
||||||
song = audio.play(file);
|
song = audio.play(file, audio.bus.music);
|
||||||
song.loop = true;
|
song.loop = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!song) {
|
if (!song) {
|
||||||
song = audio.play(file);
|
song = audio.play(file, audio.bus.music);
|
||||||
song.volume = 1;
|
song.volume = 1;
|
||||||
// tween(song,'volume', 1, fade);
|
// tween(song,'volume', 1, fade);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var temp = audio.play(file);
|
var temp = audio.play(file, audio.bus.music);
|
||||||
if (!temp) return;
|
if (!temp) return;
|
||||||
|
|
||||||
temp.volume = 1;
|
temp.volume = 1;
|
||||||
|
@ -73,11 +80,8 @@ audio.music = function(file, fade = 0.5) {
|
||||||
song.loop = true;
|
song.loop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio.dsp.mix = function(to) {
|
audio.bus.music = audio.dsp.mix();
|
||||||
var n = audio.dsp.mix();
|
audio.bus.music.plugin(audio.bus.master);
|
||||||
if (to) n.plugin(to);
|
|
||||||
return n;
|
|
||||||
};
|
|
||||||
|
|
||||||
audio.dsp.allpass = function(secs, decay) {
|
audio.dsp.allpass = function(secs, decay) {
|
||||||
var composite = {};
|
var composite = {};
|
||||||
|
@ -106,6 +110,8 @@ audio.dsp.doc = {
|
||||||
red: "Red noise"
|
red: "Red noise"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
audio.dsp.obscure('doc');
|
||||||
|
|
||||||
Object.mixin(audio.bus.master.__proto__, {
|
Object.mixin(audio.bus.master.__proto__, {
|
||||||
get db() { return 20*Math.log10(Math.abs(this.volume)); },
|
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); },
|
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[] = {
|
static const JSCFunctionListEntry js_window_funcs[] = {
|
||||||
CGETSET_ADD(window, fullscreen),
|
CGETSET_ADD(window, fullscreen),
|
||||||
CGETSET_ADD(window, title,)
|
CGETSET_ADD(window, title),
|
||||||
CGETSET_ADD(window, vsync),
|
CGETSET_ADD(window, vsync),
|
||||||
CGETSET_ADD(window, enable_clipboard),
|
CGETSET_ADD(window, enable_clipboard),
|
||||||
CGETSET_ADD(window, enable_dragndrop),
|
CGETSET_ADD(window, enable_dragndrop),
|
||||||
|
|
Loading…
Reference in a new issue