2023-05-22 20:31:55 +02:00
|
|
|
function Node_Audio_Window(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "Audio Window";
|
|
|
|
previewable = false;
|
|
|
|
|
|
|
|
w = 96;
|
|
|
|
h = 32 + 24;
|
|
|
|
min_h = h;
|
|
|
|
|
|
|
|
inputs[| 0] = nodeValue("Audio Array", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [])
|
|
|
|
.setArrayDepth(1)
|
|
|
|
.setVisible(true, true);
|
|
|
|
|
|
|
|
inputs[| 1] = nodeValue("Sample", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 44100);
|
|
|
|
|
|
|
|
inputs[| 2] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 64);
|
|
|
|
|
|
|
|
outputs[| 0] = nodeValue("Windowed Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [])
|
|
|
|
.setArrayDepth(1);
|
|
|
|
|
2023-07-06 19:49:16 +02:00
|
|
|
static update = function(frame = PROJECT.animator.current_frame) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _arr = getInputData(0);
|
2023-05-22 20:31:55 +02:00
|
|
|
|
2023-05-24 15:02:17 +02:00
|
|
|
if(!is_array(_arr) || array_length(_arr) < 1) return;
|
|
|
|
if(!is_array(_arr[0])) return;
|
2023-05-22 20:31:55 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var sam = getInputData(1);
|
|
|
|
var siz = getInputData(2);
|
2023-05-22 20:31:55 +02:00
|
|
|
var res = [];
|
2023-07-06 19:49:16 +02:00
|
|
|
var off = frame / PROJECT.animator.framerate * sam;
|
2023-05-22 20:31:55 +02:00
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(_arr); i < n; i++ ) {
|
2023-05-22 20:31:55 +02:00
|
|
|
var _dat = _arr[i];
|
|
|
|
res[i] = [];
|
|
|
|
array_copy(res[i], 0, _dat, off, siz);
|
|
|
|
}
|
|
|
|
|
|
|
|
outputs[| 0].setValue(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
draw_sprite_fit(s_node_audio_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
|
|
|
}
|
|
|
|
}
|