Skip to content

Commit

Permalink
new fixes
Browse files Browse the repository at this point in the history
* audio busses didn't mix correctly in hierarchy
* can provide pitch and gain modifications for individual containers when you play them
* editor double-click was broken on some monitors/framerates
* external files re-sort correctly when moved or deleted
* some text fields were badly formatted
* some default audio parameter graph editor behavior was buggy
* better state handling for playstacks
* can play containers at screen positions now (good for UI...)
  • Loading branch information
gl326 committed Nov 3, 2022
1 parent a6e0277 commit fae879e
Show file tree
Hide file tree
Showing 30 changed files with 495 additions and 369 deletions.
436 changes: 218 additions & 218 deletions bard-audio/bard-audio.yyp

Large diffs are not rendered by default.

53 changes: 2 additions & 51 deletions bard-audio/datafiles/audio_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
"cleft" : 99.2603550296
}
],
"blend_on" : 1,
"bpm" : 140,
"bus" : "music",
"contents_serialize" : [
Expand Down Expand Up @@ -123,7 +122,6 @@
"cleft" : 97.9289940828
}
],
"blend_on" : 1,
"bpm" : 70,
"bus" : "music",
"contents_serialize" : [
Expand Down Expand Up @@ -178,7 +176,8 @@
"from_project" : 1,
"name" : "test_choice_sfx",
"parameters" : [],
"parent" : "test_sfx"
"parent" : "test_sfx",
"threed" : true
}
],
[
Expand Down Expand Up @@ -283,35 +282,6 @@
}
],
[
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"path" : "chicory_meadows_bgm_and_lowkey_head_105bpm_CMaj_16beats"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"audio_group_id" : 1,
"editor_order" : 1,
"path" : "fart"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"path" : "chicory_meadows_bgm_head_105bpm_CMaj_16beats"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"editor_order" : 1,
"path" : "chicory_meadows_lowkey_loop_105bpm_CMaj"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"editor_order" : 1,
"path" : "chicory_meadows_bgm_loop_105bpm_CMaj"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
Expand All @@ -324,32 +294,13 @@
"external" : 1,
"path" : "audio/test_external\\noisy_pop.wav"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"bus" : "music",
"editor_order" : 1,
"path" : "mus_act1_spiritworld_active_lp_110bpm"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"bus" : "music",
"editor_order" : 1,
"path" : "mus_act1_bardstheme_active_lp_140bpm"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"bus" : "music",
"path" : "mus_act1_spiritworld_intro_110bpm"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
"bus" : "music",
"path" : "mus_act1_spiritworld_passive_lp_110bpm"
},
{
"__Elephant_Constructor__" : "class_audio_asset",
"__Elephant_Schema_Version__" : 0,
Expand Down
4 changes: 2 additions & 2 deletions bard-audio/objects/objAudioEditor/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ if !mouse_check_button(mb_left){dragging = noone; drag_start = false;}
}

if clicked!=-1{
doubleclick+=1;
if doubleclick>=15{
doubleclick+=delta_time;
if doubleclick>=(1000000*.33){
clicked = -1;
doubleclick = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion bard-audio/objects/objTextfield/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if slider and param_ref=="" and editing!=-1 and !objAudioEditor.editing_audio{
draw_rectangle(slide_l,lerp(t,b,.4),slide_r,lerp(t,b,.6),false);

var slide_x;
if is_real(variable_struct_get(editing,param)){
if is_numeric(variable_struct_get(editing,param)){
if dB{
slide_x =
lerp(slide_l,slide_r,
Expand Down
36 changes: 19 additions & 17 deletions bard-audio/scripts/GregephantToJSON/GregephantToJSON.gml
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,26 @@ function __GregephantToJSONInner(_target)

if (_verbose) __ElephantRemoveExcludedVariables(_names, _elephantSchemas);

//GREGEPHANT: get the template for a blank version of this struct
if !ds_map_exists(global.__gregephantTemplates,_instanceof){
var _constructorFunction = asset_get_index(_instanceof);
if (is_method(_constructorFunction))
{
//Is a method
_template = new _constructorFunction();
}
else if (is_numeric(_constructorFunction) && script_exists(_constructorFunction))
{
//Is a script
_template = new _constructorFunction();
}
ds_map_add(global.__gregephantTemplates,_instanceof,_template);
}else{
_template = global.__gregephantTemplates[?_instanceof];
if (!variable_struct_exists(_target, __ELEPHANT_VERBOSE_FORCE_NAME) or !_target[$ __ELEPHANT_VERBOSE_FORCE_NAME]){
//GREGEPHANT: get the template for a blank version of this struct
if !ds_map_exists(global.__gregephantTemplates,_instanceof){
var _constructorFunction = asset_get_index(_instanceof);
if (is_method(_constructorFunction))
{
//Is a method
_template = new _constructorFunction();
}
else if (is_numeric(_constructorFunction) && script_exists(_constructorFunction))
{
//Is a script
_template = new _constructorFunction();
}
ds_map_add(global.__gregephantTemplates,_instanceof,_template);
}else{
_template = global.__gregephantTemplates[?_instanceof];
}
_hastemplate = true;
}
_hastemplate = true;
}

//Sort the names alphabetically
Expand Down
2 changes: 2 additions & 0 deletions bard-audio/scripts/__ElephantSystem/__ElephantSystem.gml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#macro __ELEPHANT_VERSION_VERBOSE_NAME "__Elephant_Version_Verbose__"
#macro __ELEPHANT_VERBOSE_EXCLUDE_NAME "__Elephant_Verbose_Exclude__"

#macro __ELEPHANT_VERBOSE_FORCE_NAME "__Elephant_Verbose_Force__" // added for bard audio

#macro __ELEPHANT_JSON_CIRCULAR_REF "__Elephant_Circular_Ref__"
#macro __ELEPHANT_JSON_CONSTRUCTOR "__Elephant_Constructor__"
#macro __ELEPHANT_JSON_SCHEMA_VERSION "__Elephant_Schema_Version__"
Expand Down
9 changes: 7 additions & 2 deletions bard-audio/scripts/audio_asset_index/audio_asset_index.gml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Script assets have changed for v2.3.0 see
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
function audio_asset_index(_path){
function audio_asset_index(_path,_container = undefined, _index = 0){
var ret = global.audio_external_assets[?_path];
if is_undefined(ret){
ret = -1;
Expand All @@ -14,7 +14,12 @@ function audio_asset_index(_path){
var file_name = filename_name(file);
if file_name==search_name{
if ret==-1{
ret = file;
var _item = global.audio_external_assets[?file];
ret = _item; //return the intended index from the new location

if !is_undefined(_container){
_container.contents_serialize[_index] = container_content_serialize(_item); //move the reference to the new moved location
}
//show_debug_message(_path+" [>>MOVED TO>>] "+file);
break; //you could remove this to keep searching and make sure there arent duplicates, but for the sake of speed on big projects its probably not worth a warning
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// @param newVal
/// @param soundName
/// @param soundID
function audio_param_set_unique(param, newVal, _container, playID) {
function audio_param_set_unique(param, newVal, _container, playID=-1) {
var player = container_player(_container);
if !is_undefined(player){
return player.param_set_unique(param, newVal, playID);
Expand Down
20 changes: 20 additions & 0 deletions bard-audio/scripts/bard_audio_data_load/bard_audio_data_load.gml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ function bard_audio_data_load(){
{
global.bard_audio_data = ElephantFromJSON(json_parse(file_read_string(_path)));

//these audio assets are stranded without a corresponding file; it was probably renamed or deleted
var _assets = global.bard_audio_data[bard_audio_class.asset],
_i = 0;
repeat(array_length(_assets)){
if _assets[_i].marked_to_delete{
array_delete(_assets,_i,1);
}else{
_i ++;
}
}

//unpack container contents
var _data = global.bard_audio_data[bard_audio_class.container],
_i = 0;
repeat(array_length(_data)){
Expand All @@ -20,6 +32,14 @@ function bard_audio_data_load(){
_data[_i].check_parent();
_i ++;
}

//setup initial bus volume
var _busses = global.bard_audio_data[bard_audio_class.bus],
_i = 0;
repeat(array_length(_busses)){
_busses[_i].recalculate();
_i ++;
}
}


Expand Down
4 changes: 3 additions & 1 deletion bard-audio/scripts/bard_audio_system/bard_audio_system.gml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ function bard_audio_load_event(){
global.audio_loading.from.loaded_audio = __audioExtWavBufferToAudio(_newBuff);
global.audio_loading.from.loaded_buffer = _newBuff;
global.audio_loading.from.loaded = true;

if global.audio_loading.from.loaded_audio==-1{
show_debug_message("!!!!!!!!!!!AUDIO ERROR! File "+string(global.audio_loading.item)+" failed to load due to an issue with the file!!!!!!!!!!!");
}
buffer_delete(global.audio_loading.buffer);
}else{
//audio group. no extra logic needed.
Expand Down
13 changes: 7 additions & 6 deletions bard-audio/scripts/bus_fade/bus_fade.gml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Script assets have changed for v2.3.0 see
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
function bus_fade(bus_name,fadeToNegativeOneToZero=-1,fadeTimeInSeconds=1,curve=1){
function bus_fade(bus_name,fadeToNegativeOneHundredToZero=-100,fadeTimeInSeconds=1,curve=1){
if ds_map_exists(global.audio_busses,bus_name){
with(global.audio_busses[?bus_name]){
return tween_audio("gain",fadeToNegativeOneToZero,fadeTimeInSeconds,curve).on_update(function(){
var calc = 0;
if cv.parent!=undefined{
calc = cv.parent.calc;
return tween_audio("gain",fadeToNegativeOneHundredToZero,fadeTimeInSeconds,curve).on_update(function(){
var _calc = 0;
if parent!=undefined{
_calc = bus_getdata(parent).calc;
}
recalculate();});
recalculate(_calc);
});
}
//returns a tween which you could attach a callback(); to
}
Expand Down
6 changes: 3 additions & 3 deletions bard-audio/scripts/bus_set_gain/bus_set_gain.gml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//set the volume of a bus during gameplay
//could be used to change volume of music based on a setting,
//or some other effect.... who knows.
function bus_set_gain(bus_name,setFromNegativeOnetoZero) {
function bus_set_gain(bus_name,setFromNegativeOneHundredtoZero) {
if ds_map_exists(global.audio_busses,bus_name){
var cv = ds_map_find_value(global.audio_busses,bus_name);
if cv.gain!=setFromNegativeOnetoZero{
cv.gain = setFromNegativeOnetoZero;
if cv.gain!=setFromNegativeOneHundredtoZero{
cv.gain = setFromNegativeOneHundredtoZero;
var calc = 0;
if cv.parent!=undefined{
calc = bus_getdata(cv.parent).calc;
Expand Down
38 changes: 20 additions & 18 deletions bard-audio/scripts/class_audio_asset/class_audio_asset.gml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function class_audio_asset(_name="",_external=false,_project = "") constructor{

project = _project;

marked_to_delete = false;

ELEPHANT_SCHEMA
{
ELEPHANT_VERBOSE_EXCLUDE : [
Expand All @@ -30,14 +32,28 @@ function class_audio_asset(_name="",_external=false,_project = "") constructor{
"loaded_buffer",
"loaded_audio",
"name",
"project"
"project",
"marked_to_delete"
],
}

ELEPHANT_POST_READ_METHOD
{
setup(); //...
}

static DELETE = function(){
if ELEPHANT_IS_DESERIALIZING{
marked_to_delete = true;
}else{
var ind = array_find_index(global.bard_audio_data[bard_audio_class.asset],self);
if ind!=-1{
array_delete(global.bard_audio_data[bard_audio_class.asset],ind,1);
}else{
marked_to_delete = true;
}
}
}

static setup = function(){
if !external{
Expand All @@ -57,12 +73,7 @@ function class_audio_asset(_name="",_external=false,_project = "") constructor{
ds_map_add(global.audio_assets,index,self); //track me!
}else{
show_debug_message(concat("WARNING! no matching audio asset for \"",name,"\". was it deleted or renamed?"));

//remove from serialisation
var ind = array_find_index(global.bard_audio_data[bard_audio_class.asset],self);
if ind!=-1{
array_delete(global.bard_audio_data[bard_audio_class.asset],ind,1);
}
DELETE();
}
}else{
var _exists = false;
Expand Down Expand Up @@ -96,22 +107,13 @@ function class_audio_asset(_name="",_external=false,_project = "") constructor{
ds_map_add(global.audio_assets,index,self); //track me!
}else{
show_debug_message(concat("WARNING! no file for \"",path,"\". was it deleted or renamed?"));

//remove from serialisation
var ind = array_find_index(global.bard_audio_data[bard_audio_class.asset],self);
if ind!=-1{
array_delete(global.bard_audio_data[bard_audio_class.asset],ind,1);
}
DELETE();
}
}

//weird blank
if name=="" and path==""{
//stop serializing me
var ind = array_find_index(global.bard_audio_data[bard_audio_class.asset],self);
if ind!=-1{
array_delete(global.bard_audio_data[bard_audio_class.asset],ind,1);
}
DELETE();
}
}

Expand Down
2 changes: 1 addition & 1 deletion bard-audio/scripts/class_audio_bus/class_audio_bus.gml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function class_audio_bus(_name="",_gain=0,_parent=undefined) constructor{
array_push(calced,name);
//if ds_exists(map,ds_type_map){
var ncalc = ((_calc+1)
*((gain/1)+1)
*((gain/100)+1)
)-1;
var i;

Expand Down
Loading

0 comments on commit fae879e

Please sign in to comment.