2023-10-08 04:14:35 +02:00
|
|
|
function Node_Audio_Loudness(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2024-03-28 14:18:02 +01:00
|
|
|
name = "Audio Loudness";
|
|
|
|
setDimension(96, 72);
|
2023-10-08 04:14:35 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0] = nodeValue_Float("Audio Data", self, [])
|
2023-10-08 04:14:35 +02:00
|
|
|
.setArrayDepth(1)
|
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Loudness", self, VALUE_TYPE.float, 0);
|
2023-10-08 04:14:35 +02:00
|
|
|
|
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
|
|
|
var _dat = _data[0];
|
|
|
|
|
|
|
|
var N = array_length(_dat);
|
|
|
|
var val = 0;
|
|
|
|
if(N == 0) return 0;
|
|
|
|
|
|
|
|
for( var i = 0; i < N; i++ )
|
|
|
|
val += _dat[i] * _dat[i];
|
|
|
|
val = sqrt(val / N);
|
|
|
|
|
|
|
|
var dec = 10 * log10(val);
|
|
|
|
return dec;
|
|
|
|
}
|
|
|
|
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
draw_sprite_fit(s_node_audio_volume, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
|
|
|
}
|
|
|
|
}
|