Skip to content

Commit

Permalink
Merge branch 'dev-5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Apr 18, 2023
2 parents 266c609 + dd2cc68 commit dac5fdb
Show file tree
Hide file tree
Showing 37 changed files with 659 additions and 127 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center"><img src="https://raw.githubusercontent.com/JujuAdams/vinyl/master/LOGO.png" style="display:block; margin:auto; width:300px"></p>
<h1 align="center">Vinyl 5.2.1</h1>
<h1 align="center">Vinyl 5.3.1</h1>

<p align="center">Modular audio system for GameMaker 2023.2 (and later) by <b>@jujuadams</b></p>

Expand Down
4 changes: 1 addition & 3 deletions notes/TestConfig/TestConfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
label: sfx
}

[sndBleep0, sndBleep1, sndBleep2, sndBleep3,
sndBleep4, sndBleep5, sndBleep6, sndBleep7,
sndBleep8, sndBleep9, sndBleep10, sndBleep11]: {
sndBleep*: { //Catch every "bleep" sound effect
label: sfx
}

Expand Down
2 changes: 1 addition & 1 deletion options/windows/options_windows.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions scripts/VinylPositionGet/VinylPositionGet.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// Returns the playback position of a Vinyl voice, measured in seconds
///
/// If the voice has finished playing, this function will return 0
///
/// This function will return <undefined> if passed a label name. This function will further
/// return <undefined> for audio played using VinylPlaySimple()
///
/// @param vinylID

function VinylPositionGet(_id)
{
static _idToVoiceDict = __VinylGlobalData().__idToVoiceDict;

var _voice = _idToVoiceDict[? _id];
if (is_struct(_voice)) return _voice.__RawPositionGet();
}
11 changes: 11 additions & 0 deletions scripts/VinylPositionGet/VinylPositionGet.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions scripts/VinylPositionSet/VinylPositionSet.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// Sets the playback position of a Vinyl voice
///
/// If passed a label name, every voice currently assigned to the label will
/// individually have its playback position set paused. This is the same as calling
/// VinylPositionSet() for each individual voice
///
/// This function CANNOT be used with audio played using VinylPlaySimple()
///
/// @param vinylID
/// @param position

function VinylPositionSet(_id, _position)
{
static _globalData = __VinylGlobalData();
static _idToVoiceDict = _globalData.__idToVoiceDict;

var _voice = _idToVoiceDict[? _id];
if (is_struct(_voice)) return _voice.__RawPositionSet(_position);

var _label = _globalData.__labelDict[$ _id];
if (is_struct(_label)) return _label.__RawPositionSet(_position);

__VinylTrace("Warning! Failed to execute VinylPositionSet() for ", _id);
}
11 changes: 11 additions & 0 deletions scripts/VinylPositionSet/VinylPositionSet.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 95 additions & 0 deletions scripts/VinylSystemArrayOf/VinylSystemArrayOf.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/// Returns an array of names of all definitions for a particular type of Vinyl component
///
/// The type argument can be one of the follow values:
/// "patterns"
/// "assets"
/// "labels"
/// "effect chains"
/// "knobs"
/// "stacks"
///
/// @param type

function VinylSystemArrayOf(_type)
{
static _globalData = __VinylGlobalData();

var _return = [];

switch(_type)
{
case "pattern":
case "patterns":
var _array = _globalData.__patternArray;
var _i = 0;
repeat(array_length(_array))
{
var _pattern = _array[_i];
if ((not _pattern.__child) && (_pattern.__patternType != "asset")) array_push(_return, _pattern.__name);
++_i;
}
break;

case "asset":
case "assets":
var _array = _globalData.__patternArray;
var _i = 0;
repeat(array_length(_array))
{
var _pattern = _array[_i];
if ((not _pattern.__child) && (_pattern.__patternType == "asset")) array_push(_return, audio_get_name(_pattern.__asset));
++_i;
}
break;

case "label":
case "labels":
var _array = _globalData.__labelArray;
var _i = 0;
repeat(array_length(_array))
{
array_push(_return, _array[_i].__name);
++_i;
}
break;

case "effect chain":
case "effect chains":
var _array = _globalData.__effectChainArray;
var _i = 0;
repeat(array_length(_array))
{
array_push(_return, _array[_i].__name);
++_i;
}
break;

case "knob":
case "knobs":
var _array = _globalData.__knobArray;
var _i = 0;
repeat(array_length(_array))
{
array_push(_return, _array[_i].__name);
++_i;
}
break;

case "stack":
case "stacks":
var _array = _globalData.__stackArray;
var _i = 0;
repeat(array_length(_array))
{
array_push(_return, _array[_i].__name);
++_i;
}
break;

default:
__VinylError("Return type \"", _type, "\" unhandled");
break;
}

return _return;
}
11 changes: 11 additions & 0 deletions scripts/VinylSystemArrayOf/VinylSystemArrayOf.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 88 additions & 32 deletions scripts/VinylSystemReadConfig/VinylSystemReadConfig.gml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function VinylSystemReadConfig(_configData)
static _stackArray = _globalData.__stackArray;
static _animCurveArray = _globalData.__animCurveArray;

var _audioAssetArray = undefined;

var _oldKnobDict = _globalData.__knobDict;
var _oldLabelDict = _globalData.__labelDict;

Expand Down Expand Up @@ -187,6 +189,21 @@ function VinylSystemReadConfig(_configData)



static _addAssetFunc = function(_newPatternDict, _key, _assetIndex, _patternData)
{
if (variable_struct_exists(_newPatternDict, _key))
{
__VinylTrace("Warning! Asset \"", _key, "\" has already been defined, skipping subsequent definitions");
}
else
{
var _pattern = new __VinylClassPatternAsset(_key, false, false, _assetIndex);
_pattern.__Initialize(_patternData);
_pattern.__StoreAsset();
return _pattern;
}
}

//Instantiate basic patterns for each asset in the config data
var _inputAssetDict = _configData[$ "assets"];
if (is_undefined(_inputAssetDict))
Expand All @@ -200,44 +217,90 @@ function VinylSystemReadConfig(_configData)
else
{
var _assetNameArray = variable_struct_get_names(_inputAssetDict);

//Expand any wildcards
var _i = 0;
repeat(array_length(_assetNameArray))
{
var _assetName = _assetNameArray[_i];
var _assetIndex = asset_get_index(_assetName);
var _assetName = _assetNameArray[_i];

if ((_assetIndex < 0) && (_assetName != "fallback"))
//If we have at least one wildcard in the asset name we'll need to make a search
if (string_pos("*", _assetName) > 0)
{
__VinylTrace("Warning! Asset \"", _assetName, "\" doesn't exist");
var _assetData = _inputAssetDict[$ _assetName];

//Remove this wildcard entry from our data structures
variable_struct_remove(_inputAssetDict, _assetName);
array_delete(_assetNameArray, _i, 1);

//Build an array of all audio asset names on demand
if (!is_array(_audioAssetArray))
{
_audioAssetArray = [];

var _j = 0;
repeat(1000000)
{
if (not audio_exists(_j)) break;
array_push(_audioAssetArray, audio_get_name(_j));
++_j;
}
}

//Find all matching assets for the search string
var _array = __VinylFindMatchingAudioAssets(_assetName, _audioAssetArray);

if (array_length(_array) <= 0)
{
__VinylTrace("Warning! Search string \"", _assetName, "\" matches no assets");
}
else
{
//Iterate over all of the asset we found and merge asset data for them
var _j = 0;
repeat(array_length(_array))
{
var _assetName = audio_get_name(_array[_j]);
__VinylBufferReadConfigJSONStructMergeNoOverwrite(_inputAssetDict, _assetName, _assetData);
if (!array_contains(_assetNameArray, _assetName)) array_push(_assetNameArray, _assetName);
++_j;
}
}
}
else if ((asset_get_type(_assetName) != asset_sound) && (_assetName != "fallback"))
else
{
++_i;
}
}

//Then iterate over the unpacked asset definitions and set up asset patterns
var _i = 0;
repeat(array_length(_assetNameArray))
{
var _assetName = _assetNameArray[_i];
var _patternData = _inputAssetDict[$ _assetName];

if (_assetName == "fallback")
{
__VinylTrace("Warning! Asset \"", _assetName, "\" isn't a sound");
var _pattern = new __VinylClassPatternFallback();
_pattern.__Initialize(_patternData);
_pattern.__Store();
}
else
{
var _key = (_assetName == "fallback")? "fallback" : string(_assetIndex);
if (variable_struct_exists(_newPatternDict, _key))
var _assetIndex = asset_get_index(_assetName);
if (_assetIndex < 0)
{
__VinylTrace("Warning! Asset \"", _assetName, "\" doesn't exist");
}
else if (asset_get_type(_assetName) != asset_sound)
{
__VinylTrace("Warning! Asset \"", _key, "\" has already been defined");
__VinylTrace("Warning! Asset \"", _assetName, "\" isn't a sound");
}
else
{
//Pull out the asset data
var _patternData = _inputAssetDict[$ _assetName];

//Make a new pattern for this asset
if (_assetName == "fallback")
{
var _pattern = new __VinylClassPatternFallback();
}
else
{
var _pattern = new __VinylClassPatternAsset(_key, false, _assetIndex);
}

_pattern.__Initialize(_patternData);
_pattern.__Store();
_addAssetFunc(_newPatternDict, string(_assetIndex), _assetIndex, _patternData);
}
}

Expand Down Expand Up @@ -281,14 +344,7 @@ function VinylSystemReadConfig(_configData)
var _assetIndex = _assetArray[_k];
var _key = string(_assetIndex);

var _pattern = _newPatternDict[$ _key];
if (_pattern == undefined)
{
_pattern = new __VinylClassPatternBasic(_key, false);
_pattern.__Initialize(undefined);
_pattern.__Store();
}

var _pattern = _newPatternDict[$ _key] ?? _addAssetFunc(_newPatternDict, string(_assetIndex), _assetIndex, undefined);
_labelData.__LabelArrayAppend(_pattern.__labelArray);

++_k;
Expand Down Expand Up @@ -323,7 +379,7 @@ function VinylSystemReadConfig(_configData)
var _patternName = _patternNameArray[_i];
if (string_pos(">", _patternName)) __VinylError("Pattern names cannot contain the \">\" character (name=", _patternName, ")");

__VInylPatternCreate(_patternName, _inputPatternsDict[$ _patternName], false);
__VInylPatternCreate(_patternName, _inputPatternsDict[$ _patternName], false, false);

++_i;
}
Expand Down
7 changes: 7 additions & 0 deletions scripts/VinylUpdateCallbackGet/VinylUpdateCallbackGet.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// Returns the callback for execution when a data update occurs

function VinylUpdateCallbackGet()
{
static _globalData = __VinylGlobalData();
return _globalData.__updateCallback;
}
11 changes: 11 additions & 0 deletions scripts/VinylUpdateCallbackGet/VinylUpdateCallbackGet.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dac5fdb

Please sign in to comment.