Skip to content

Commit beacf6a

Browse files
fix: fade in and fade out macros multiply each note's relative velocity
Co-Authored-By: BedrRedstone <[email protected]>
1 parent 80dc706 commit beacf6a

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

scripts/macro_fadein/macro_fadein.gml

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
function macro_fadein() {
22
// macro_fadein()
3-
var str, total_vals, val, decr, inc, maxdecr, velval
3+
var str, total_vals, val, decr, maxdecr
44
str = selection_code
55
if (selected = 0) return 0
66
var arr_data = selection_to_array_ext()
77
total_vals = array_length(arr_data)
88
val = 0
9-
// Check bottom-right note block's velocity value, calculate fade out from that.
10-
velval = array_length(arr_data)
11-
maxdecr = arr_data[velval-4]
12-
decr = maxdecr/macro_column_count(arr_data)
13-
show_debug_message(string(maxdecr))
14-
inc = decr
9+
maxdecr = 1.0
10+
decr = maxdecr/(macro_column_count(arr_data) - 1)
11+
var current_factor = 0.0
1512
//show_debug_message(string_count("-1", str))
1613
//for (var i = 0; i < total_vals; i++;) {show_debug_message(arr_data[i])}
1714
while (val < total_vals) {
1815
val += 4
19-
arr_data[val] = abs(0+decr)
16+
arr_data[val] = ceil(arr_data[val] * current_factor)
17+
arr_data[val] = max(1, min(arr_data[val], 100))
2018
val += 3
2119
while arr_data[val] != -1 {
2220
val += 3
23-
arr_data[val] = abs(0+decr)
21+
arr_data[val] = ceil(arr_data[val] * current_factor)
22+
arr_data[val] = max(1, min(arr_data[val], 100))
2423
val += 3
2524
}
26-
decr = decr + inc
25+
// Reached end of column; next column
26+
current_factor += decr
2727
val ++
2828
}
2929
selection_load_from_array(selection_x, selection_y, arr_data)

scripts/macro_fadeout/macro_fadeout.gml

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
function macro_fadeout() {
22
// macro_fadeout()
3-
var str, total_vals, val, decr, inc, maxdecr
3+
var str, total_vals, val, decr, maxdecr
44
str = selection_code
55
if (selected = 0) return 0
66
var arr_data = selection_to_array_ext()
77
total_vals = array_length(arr_data)
88
val = 0
9-
// Check top-left note block's velocity value, calculate fade out from that.
10-
maxdecr = arr_data[4]
11-
decr = maxdecr/macro_column_count(arr_data)
12-
inc = decr
9+
maxdecr = 1.0
10+
decr = maxdecr/(macro_column_count(arr_data) - 1)
11+
var current_factor = 1.0
1312
//show_debug_message(string_count("-1", str))
1413
//for (var i = 0; i < total_vals; i++;) {show_debug_message(arr_data[i])}
1514
while (val < total_vals) {
1615
val += 4
17-
arr_data[val] = abs(maxdecr-decr)
16+
arr_data[val] = ceil(arr_data[val] * current_factor)
17+
arr_data[val] = max(1, min(arr_data[val], 100))
1818
val += 3
1919
while arr_data[val] != -1 {
2020
val += 3
21-
arr_data[val] = abs(maxdecr-decr)
21+
arr_data[val] = ceil(arr_data[val] * current_factor)
22+
arr_data[val] = max(1, min(arr_data[val], 100))
2223
val += 3
2324
}
24-
decr = decr + inc
25+
// Reached end of column; next column
26+
current_factor -= decr
2527
val ++
2628
}
2729
selection_load_from_array(selection_x, selection_y, arr_data)

0 commit comments

Comments
 (0)