- [Audio] Now use audioBit datatype instead of pure array to improve performance.

- [Audio File In] Add mono conversion property.
- [Audio window] Now only accept audioBit datatype.
This commit is contained in:
MakhamDev 2023-10-03 09:29:58 +07:00
parent 337f98b6b9
commit 0311e2eeb6
14 changed files with 244 additions and 115 deletions

View file

@ -215,6 +215,7 @@
{"name":"biterator","order":2,"path":"folders/VCT/biterator.yy",},
{"name":"widget","order":3,"path":"folders/VCT/widget.yy",},
{"name":"widgets","order":5,"path":"folders/widgets.yy",},
{"name":"audio","order":13,"path":"folders/nodes/data/value/audio.yy",},
],
"ResourceOrderSettings": [
{"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",},
@ -818,7 +819,6 @@
{"name":"BBMOD_Vec4","order":6,"path":"scripts/BBMOD_Vec4/BBMOD_Vec4.yy",},
{"name":"s_biterator_color_slot","order":17,"path":"sprites/s_biterator_color_slot/s_biterator_color_slot.yy",},
{"name":"s_node_pb_layer","order":18,"path":"sprites/s_node_pb_layer/s_node_pb_layer.yy",},
{"name":"node_audio_window","order":16,"path":"scripts/node_audio_window/node_audio_window.yy",},
{"name":"node_surface_from_color","order":1,"path":"scripts/node_surface_from_color/node_surface_from_color.yy",},
{"name":"s_node_pb_draw_rectangle","order":13,"path":"sprites/s_node_pb_draw_rectangle/s_node_pb_draw_rectangle.yy",},
{"name":"panel_animation","order":1,"path":"scripts/panel_animation/panel_animation.yy",},
@ -1541,6 +1541,7 @@
{"name":"sh_fd_replace_material_advanced_glsl","order":11,"path":"shaders/sh_fd_replace_material_advanced_glsl/sh_fd_replace_material_advanced_glsl.yy",},
{"name":"sh_solid","order":15,"path":"shaders/sh_solid/sh_solid.yy",},
{"name":"panel_animation_scaler","order":1,"path":"scripts/panel_animation_scaler/panel_animation_scaler.yy",},
{"name":"wav_file_object","order":2,"path":"scripts/wav_file_object/wav_file_object.yy",},
{"name":"s_node_json_file_write","order":10,"path":"sprites/s_node_json_file_write/s_node_json_file_write.yy",},
{"name":"node_pb_fx_intersect","order":5,"path":"scripts/node_pb_fx_intersect/node_pb_fx_intersect.yy",},
{"name":"fd_rectangle_get_material_time_step","order":13,"path":"scripts/fd_rectangle_get_material_time_step/fd_rectangle_get_material_time_step.yy",},

View file

@ -248,6 +248,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"biterator","folderPath":"folders/VCT/biterator.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/VCT/widget.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"audio","folderPath":"folders/nodes/data/value/audio.yy",},
],
"IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},
@ -453,6 +454,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_tunnel.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_undo.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_unit_angle.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_unit_audio.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_unit_ref.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_vct.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_vfx.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
@ -2262,6 +2264,7 @@
{"id":{"name":"sh_fd_replace_material_advanced_glsl","path":"shaders/sh_fd_replace_material_advanced_glsl/sh_fd_replace_material_advanced_glsl.yy",},},
{"id":{"name":"sh_solid","path":"shaders/sh_solid/sh_solid.yy",},},
{"id":{"name":"panel_animation_scaler","path":"scripts/panel_animation_scaler/panel_animation_scaler.yy",},},
{"id":{"name":"wav_file_object","path":"scripts/wav_file_object/wav_file_object.yy",},},
{"id":{"name":"s_node_json_file_write","path":"sprites/s_node_json_file_write/s_node_json_file_write.yy",},},
{"id":{"name":"node_pb_fx_intersect","path":"scripts/node_pb_fx_intersect/node_pb_fx_intersect.yy",},},
{"id":{"name":"timer_function","path":"scripts/timer_function/timer_function.yy",},},

Binary file not shown.

View file

@ -89,7 +89,11 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor {
}
var aa = interactable * 0.25 + 0.75;
if(icon) draw_sprite_ui_uniform(icon, icon_index, _x + _w / 2, _y + _h / 2,, icon_blend, aa);
if(icon) {
var ind = is_real(icon_index)? icon_index : icon_index();
draw_sprite_ui_uniform(icon, ind, _x + _w / 2, _y + _h / 2,, icon_blend, aa);
}
if(text != "") {
draw_set_alpha(aa);
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text);
@ -97,8 +101,7 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor {
draw_set_alpha(1);
}
if(WIDGET_CURRENT == self)
draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1);
if(WIDGET_CURRENT == self) draw_sprite_stretched_ext(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6), COLORS._main_accent, 1);
resetFocus();

View file

@ -2,43 +2,128 @@ function Node_Audio_Window(_x, _y, _group = noone) : Node(_x, _y, _group) constr
name = "Audio Window";
previewable = false;
w = 96;
h = 32 + 24;
w = 128;
h = 128;
min_h = h;
inputs[| 0] = nodeValue("Audio Array", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [])
.setArrayDepth(1)
inputs[| 0] = nodeValue("Audio data", self, JUNCTION_CONNECT.input, VALUE_TYPE.audioBit, noone)
.setVisible(true, true);
inputs[| 1] = nodeValue("Sample", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 44100);
inputs[| 1] = nodeValue("Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 64, "Amount of bits to extract.");
inputs[| 2] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 64);
inputs[| 2] = nodeValue("Location", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY._default, { unit: 0, side_button: button(function() {
inputs[| 2].display_data.unit = (inputs[| 2].display_data.unit + 1) % 3;
inputs[| 2].display_data.side_button.tooltip.index = inputs[| 2].display_data.unit;
update();
}).setTooltip( new tooltipSelector("Unit", [ "Bit", "Second", "Progress" ]) )
.setIcon( THEME.unit_audio, function() { return inputs[| 2].display_data.unit; }, COLORS._main_icon )
}
);
inputs[| 3] = nodeValue("Cursor location", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_button, [ "Start", "Middle", "End" ]);
outputs[| 0] = nodeValue("Windowed Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [])
inputs[| 4] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1);
inputs[| 5] = nodeValue("Match animation", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false, "Set window cursor to match animation timeline.");
outputs[| 0] = nodeValue("Bit Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [])
.setArrayDepth(1);
input_display_list = [ 0,
["Window", false], 1, 5, 2, 3, 4,
];
preview_cr = 0;
preview_st = 0;
preview_ed = 0;
static step = function() {
var _anim = getInputData(5);
inputs[| 2].setVisible(!_anim);
}
static update = function(frame = PROJECT.animator.current_frame) {
var _arr = getInputData(0);
var _aud = getInputData(0);
if(!is_instanceof(_aud, audioObject)) return;
if(!is_array(_arr) || array_length(_arr) < 1) return;
if(!is_array(_arr[0])) return;
var _wid = getInputData(1);
var _loc = getInputData(2);
var _cloc = getInputData(3);
var _stp = getInputData(4); _stp = max(1, _stp);
var _anim = getInputData(5);
var sam = getInputData(1);
var siz = getInputData(2);
var res = [];
var off = frame / PROJECT.animator.framerate * sam;
var _unit = inputs[| 2].display_data.unit;
var off = 0, st = 0, ed = 1, len = 1;
var _ch = _aud.getChannel();
for( var i = 0, n = array_length(_arr); i < n; i++ ) {
var _dat = _arr[i];
res[i] = [];
array_copy(res[i], 0, _dat, off, siz);
if(_anim) off = frame / PROJECT.animator.framerate * _aud.sample;
else {
switch(_unit) {
case 0 : off = _loc; break;
case 1 : off = _loc * _aud.sample; break;
case 2 : off = _loc * _aud.duration * _aud.sample; break;
}
}
switch(_cloc) {
case 0 : st = off; break;
case 1 : st = off - round(_wid / 2); break;
case 2 : st = off - _wid; break;
}
ed = st + _wid;
st = clamp(st, 0, _aud.packet - 1);
ed = clamp(ed, 0, _aud.packet - 1);
len = (ed - st) / _stp;
preview_cr = off / _aud.packet;
preview_st = st / _aud.packet;
preview_ed = ed / _aud.packet;
var res = array_create(_ch);
var dat = _aud.getData();
for( var i = 0; i < _ch; i++ ) {
var _dat = dat[i];
var _ind = 0;
res[i] = array_create(len);
for(var j = st; j < ed; j += _stp)
res[i][_ind++] = _dat[j];
}
outputs[| 0].setValue(res);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
var _aud = getInputData(0);
if(!is_instanceof(_aud, audioObject)) return;
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_audio_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
var surf = _aud.checkPreview(320, 128);
if(!is_surface(surf)) return;
var sw = surface_get_width_safe(surf);
var sh = surface_get_height_safe(surf);
var ss = min(bbox.w / sw, bbox.h / sh);
var dx = bbox.xc - sw * ss / 2;
var dy = bbox.yc - sh * ss / 2;
draw_surface_ext_safe(surf, dx, dy, ss, ss,,, 0.50);
var st = preview_st * sw;
var ed = preview_ed * sw;
var cr = preview_cr * sw;
draw_surface_part_ext_safe(surf, st, 0, ed - st, sh, dx + st * ss, dy, ss, ss,, COLORS._main_accent);
draw_set_color(COLORS._main_accent);
draw_line(dx + cr * ss, bbox.yc - 16 * _s, dx + cr * ss, bbox.yc + 16 * _s);
} #endregion
}

View file

@ -5,7 +5,7 @@
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "array",
"path": "folders/nodes/data/value/array.yy",
"name": "audio",
"path": "folders/nodes/data/value/audio.yy",
},
}

View file

@ -55,6 +55,8 @@ enum VALUE_TYPE {
dynaSurface = 31,
PCXnode = 32,
audioBit = 33,
action = 99,
}
@ -169,6 +171,7 @@ function value_color(i) { #region
$976bff, //d3Material
$976bff, //dynaSurf
#c2c2d1, //PCX
$5dde8f, //audiobit
];
if(i == 99) return $5dde8f;
@ -216,6 +219,7 @@ function value_bit(i) { #region
case VALUE_TYPE.d3Material : return 1 << 33;
case VALUE_TYPE.PCXnode : return 1 << 34;
case VALUE_TYPE.audioBit : return 1 << 35;
case VALUE_TYPE.any : return ~0 & ~(1 << 32);
}
@ -447,7 +451,7 @@ function nodeValueUnit(_nodeValue) constructor { #region
function nodeValue(_name, _node, _connect, _type, _value, _tooltip = "") { return new NodeValue(_name, _node, _connect, _type, _value, _tooltip); }
function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constructor {
static DISPLAY_DATA_KEYS = [ "linked", "angle_display", "bone_id", "area_type" ];
static DISPLAY_DATA_KEYS = [ "linked", "angle_display", "bone_id", "area_type", "unit" ];
#region ---- main ----
node = _node;
@ -733,7 +737,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} );
editWidget.slidable = true;
if(type == VALUE_TYPE.integer) editWidget.slide_speed = 1;
if(struct_has(display_data, "slide_speed")) editWidget.slide_speed = display_data.slide_speed;
if(struct_has(display_data, "slide_speed")) editWidget.slide_speed = display_data.slide_speed;
if(struct_has(display_data, "unit")) editWidget.unit = display_data.unit;
if(struct_has(display_data, "side_button")) editWidget.side_button = display_data.side_button;
extract_node = "Node_Number";
break; #endregion

View file

@ -44,7 +44,9 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
} })
.rejectArray();
outputs[| 0] = nodeValue("Data", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [])
inputs[| 2] = nodeValue("Mono", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
outputs[| 0] = nodeValue("Data", self, JUNCTION_CONNECT.output, VALUE_TYPE.audioBit, noone)
.setArrayDepth(1);
outputs[| 1] = nodeValue("Path", self, JUNCTION_CONNECT.output, VALUE_TYPE.path, "");
@ -66,8 +68,8 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
first_update = false;
input_display_list = [ 0, 1, 2 ];
output_display_list = [ 0, 1, 2, 3, 4, 5 ];
audio_surface = -1;
preview_audio = -1;
preview_id = noone;
@ -101,44 +103,6 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
return false;
} #endregion
function checkPreview(force = false) { #region
if(content == noone) return;
if(!force && is_surface(audio_surface)) return;
print("-- Creating preview surface...");
var ch = content.channels;
if(ch == 0) return;
if(!struct_has(content, "sound")) return;
if(array_length(content.sound) < 1) return;
var len = array_length(content.sound[0]);
if(len == 0) return;
var spc = min(320, len);
var stp = len / spc;
var ww = h;
audio_surface = surface_verify(audio_surface, 320, ww);
surface_set_target(audio_surface);
draw_clear_alpha(c_white, 0);
draw_set_color(c_white);
var ox, oy, nx, ny;
for( var i = 0; i < len; i += stp ) {
nx = i / len * 320;
ny = ww / 2 + content.sound[0][i] * ww;
if(i) draw_line_width(ox, oy, nx, ny, 4);
ox = nx;
oy = ny;
}
surface_reset_target();
} #endregion
function updatePaths(path) { #region
path = try_get_path(path);
if(path == -1) return false;
@ -161,7 +125,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
} #endregion
function readSoundComplete() { #region
outputs[| 0].setValue(content.sound);
outputs[| 0].setValue(content);
outputs[| 2].setValue(content.sample);
outputs[| 3].setValue(content.channels);
outputs[| 4].setValue(content.duration);
@ -180,6 +144,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
buffer_write(bufferId, buffer_s16, round(content.sound[0][i] / 4 * 65535));
preview_audio = audio_create_buffer_sound(bufferId, buffer_s16, content.sample, 0, content.packet * 2, audio_mono);
var surf = content.checkPreview(320, 128, true);
} #endregion
#region ++++ inspector ++++
@ -206,7 +171,6 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
if(file_read_wav_step()) {
print("Load audio complete");
readSoundComplete();
checkPreview(true);
if(content != noone) {
var frm = max(1, ceil(content.duration * PROJECT.animator.framerate));
@ -235,14 +199,13 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
static update = function(frame = PROJECT.animator.current_frame) { #region
var path = getInputData(0);
var mono = getInputData(2);
if(path == "") return;
if(path_current != path) updatePaths(path);
checkPreview();
if(!struct_has(content, "sound")) return;
if(array_length(content.sound) < 1) return;
if(!is_instanceof(content, audioObject)) return;
content.mono = mono;
var len = content.packet;
var amp_ind = round(frame * content.sample / PROJECT.animator.framerate);
var amp_win = content.sample / PROJECT.animator.framerate * 3;
@ -265,6 +228,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
if(content == noone) return;
var bbox = drawGetBbox(xx, yy, _s);
var surf = content.checkPreview(320, 128);
if(wav_file_reading) {
var cx = xx + w * _s / 2;
@ -274,21 +238,21 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
draw_set_color(COLORS._main_icon);
draw_arc(cx, cy, rr, 90, 90 - 360 * wav_file_prg / content.packet, 4 * _s, 180);
return;
} else if(is_surface(audio_surface)) {
var sw = surface_get_width_safe(audio_surface);
var sh = surface_get_height_safe(audio_surface);
} else if(is_surface(surf)) {
var sw = surface_get_width_safe(surf);
var sh = surface_get_height_safe(surf);
var ss = min(bbox.w / sw, bbox.h / sh);
draw_surface_ext_safe(audio_surface,
bbox.xc - sw * ss / 2,
bbox.yc - sh * ss / 2,
ss, ss,,, 0.50);
var dx = bbox.xc - sw * ss / 2;
var dy = bbox.yc - sh * ss / 2;
draw_surface_ext_safe(surf, dx, dy, ss, ss,,, 0.50);
var wd = (PROJECT.animator.current_frame / PROJECT.animator.framerate) / content.duration * sw;
draw_surface_part_ext_safe(audio_surface, 0, 0, min(wd, sw), sh,
bbox.xc - sw * ss / 2,
bbox.yc - sh * ss / 2,
ss, ss,, attributes.play? COLORS._main_accent : c_white);
var wd = clamp((PROJECT.animator.current_frame / PROJECT.animator.framerate) / content.duration, 0, 1) * sw;
draw_surface_part_ext_safe(surf, 0, 0, min(wd, sw), sh, dx, dy, ss, ss,, attributes.play? COLORS._main_accent : c_white);
draw_set_color(attributes.play? COLORS._main_accent : c_white);
draw_line(dx + wd * ss, bbox.yc - 16 * _s, dx + wd * ss, bbox.yc + 16 * _s);
}
var str = filename_name(path_current);

View file

@ -35,12 +35,12 @@
delete PANEL_GRAPH;
delete PANEL_COLLECTION;
PANEL_MAIN = 0;
PANEL_MENU = 0;
PANEL_INSPECTOR = 0;
PANEL_PREVIEW = 0;
PANEL_GRAPH = 0;
PANEL_COLLECTION = 0;
PANEL_MAIN = {};
PANEL_MENU = {};
PANEL_INSPECTOR = {};
PANEL_PREVIEW = {};
PANEL_GRAPH = {};
PANEL_COLLECTION = {};
}
function getPanelFromName(name, create = false) {

View file

@ -318,9 +318,9 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
case fa_bottom: _y = _y - _h; break;
}
if(extras && instanceof(extras) == "buttonClass") {
extras.setFocusHover(active, hover);
extras.draw(_x + _w - ui(32), _y + _h / 2 - ui(32 / 2), ui(32), ui(32), _m, THEME.button_hide);
if(side_button && instanceof(side_button) == "buttonClass") {
side_button.setFocusHover(active, hover);
side_button.draw(_x + _w - ui(32), _y + _h / 2 - ui(32 / 2), ui(32), ui(32), _m, THEME.button_hide);
_w -= ui(40);
}

View file

@ -1,7 +1,7 @@
function textInput(_input, _onModify, _extras = noone) : widget() constructor {
input = _input;
onModify = _onModify;
extras = _extras;
input = _input;
onModify = _onModify;
side_button = noone;
static _resetFocus = function() { resetFocus(); }

View file

@ -0,0 +1,52 @@
function audioObject(sample = 8, channel = 2) constructor {
self.sound = [];
self.soundF = [];
self.sample = sample;
self.channels = channel;
self.bit_depth = 32;
self.duration = 0;
self.packet = 0;
self.mono = false;
preview_surface = noone;
static checkPreview = function(w, h, force = false) {
if(!force && is_surface(preview_surface)) return preview_surface;
print($"--- Creating preview surface [{w}, {h}] ---");
var ch = channels;
if(ch == 0) return;
if(array_length(sound) < 1) return;
var len = array_length(sound[0]);
if(len == 0) return;
var spc = min(w, len);
var stp = len / spc;
preview_surface = surface_verify(preview_surface, w, h);
surface_set_target(preview_surface);
draw_clear_alpha(c_white, 0);
draw_set_color(c_white);
var ox, oy, nx, ny;
for( var i = 0; i < len; i += stp ) {
nx = i / len * 320;
ny = h / 2 + sound[0][i] * h;
if(i) draw_line_width(ox, oy, nx, ny, 4);
ox = nx;
oy = ny;
}
surface_reset_target();
return preview_surface;
}
static getChannel = function() { return mono? 1 : channels; }
static getData = function() { return mono? soundF : sound; }
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "wav_file_object",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "audio",
"path": "folders/functions/audio.yy",
},
}

View file

@ -69,7 +69,8 @@ function file_read_wav(path) {
var bpc = br / ch;
var bits = l / br;
var data = array_create(ch);
var data = array_create(ch);
var dataF = [ array_create(bits) ];
debug_str += "-- READ --\n";
debug_str += $"Channels: {ch}\n";
@ -78,18 +79,17 @@ function file_read_wav(path) {
debug_str += $"samples: {sm}\n";
debug_str += $"duration: {real(bits) / real(sm)}\n";
for( var j = 0; j < ch; j++ )
data[j] = array_create(bits);
for( var j = 0; j < ch; j++ )
data[j] = array_create(bits);
wav_file_range = [0, 0];
content = {
sound: data,
sample: sm,
channels: ch,
bit_depth: bpc * 8,
duration: real(bits) / real(sm),
packet: bits,
};
content = new audioObject(sm, ch);
content.sound = data;
content.soundF = dataF;
content.bit_depth = bpc * 8;
content.duration = real(bits) / real(sm);
content.packet = bits;
printIf(global.FLAG.wav_import, debug_str);
@ -106,11 +106,14 @@ function file_read_wav_step() {
else if(content.bit_depth == 32) { bf_type = buffer_s32; lim = 2_147_483_648; }
for(; wav_file_prg < content.packet; wav_file_prg++ ) {
for( var j = 0; j < content.channels; j++ )
content.sound[j][wav_file_prg] = buffer_read(wav_file_reader, bf_type) / lim;
var ch = 0;
for( var j = 0; j < content.channels; j++ ) {
var b = buffer_read(wav_file_reader, bf_type) / lim;
ch += b;
content.sound[j][wav_file_prg] = b;
}
//wav_file_range[0] = min(wav_file_range[0], content.sound[0][wav_file_prg]);
//wav_file_range[1] = max(wav_file_range[1], content.sound[0][wav_file_prg]);
content.soundF[0][wav_file_prg] = ch / content.channels;
if(current_time - t > 1000 / 30) return false;
}