so close rn

This commit is contained in:
2025-10-02 21:50:26 +02:00
parent a2ba37df16
commit ce52ec8d6f
5 changed files with 85 additions and 54 deletions
+2 -2
View File
@@ -94,8 +94,8 @@ SRC_1_6_Z=
SRC_2_ACTIVE_COUNT=3
SRC_2_ACTIVE_1=36
SRC_2_ACTIVE_2=52
SRC_2_ACTIVE_3=68
SRC_2_ACTIVE_2=68
SRC_2_ACTIVE_3=52
SRC_2_COUNT=7
SRC_2_1_X=37
SRC_2_1_Y=53
+8 -8
View File
@@ -1299,22 +1299,22 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
f += char_at(uv2, vec2(-5.4, 1.45), hex_chars[selected_srca]);
f += char_at(uv2, vec2(-5.4, -2.55), hex_chars[selected_srcb]);
f += char_at(uv2, vec2(-2.4, 1.45), hex_chars[selected_fxa]);
f += char_at(uv2, vec2(4.6, -0.55), hex_chars[selected_fxb]);
f += char_at(uv2, vec2(-2.4, -2.55), hex_chars[selected_mfx]);
f += char_at(uv2, vec2(-2.4, -2.55), hex_chars[selected_fxb]);
f += char_at(uv2, vec2(4.6, -0.55), hex_chars[selected_mfx]);
// show current selected
f += iSelected == 3 ? h_rect(uv2, vec2(-5, 2), vec2(1.2), 0.1) : 0;
f += iSelected == 4 ? h_rect(uv2, vec2(-5, -2), vec2(1.2), 0.1) : 0;
f += iSelected == 5 ? h_rect(uv2, vec2(-2, 2), vec2(1.2), 0.1) : 0;
f += iSelected == 6 ? h_rect(uv2, vec2(5, 0), vec2(1.2), 0.1) : 0;
f += iSelected == 8 ? h_rect(uv2, vec2(-2, -2), vec2(1.2), 0.1) : 0;
f += iSelected == 6 ? h_rect(uv2, vec2(-2, -2), vec2(1.2), 0.1) : 0;
f += iSelected == 8 ? h_rect(uv2, vec2(5, 0), vec2(1.2), 0.1) : 0;
// show selected src/fx
f += active1 == 1 ? h_rect(uv2, vec2(-5, 0.8), vec2(1, 0), 0.1) : 0;
f += active1 == 2 ? h_rect(uv2, vec2(-5, -3.2), vec2(1, 0), 0.1) : 0;
f += active2 == 1 ? h_rect(uv2, vec2(-2, 0.8), vec2(1.2, 0), 0.1) : 0;
f += active2 == 2 ? h_rect(uv2, vec2(5, -1.2), vec2(1, 0), 0.1) : 0;
f += active2 == 3 ? h_rect(uv2, vec2(-2, -3.2), vec2(1, 0), 0.1) : 0;
f += active2 == 2 ? h_rect(uv2, vec2(-2, -3.2), vec2(1, 0), 0.1) : 0;
f += active2 == 3 ? h_rect(uv2, vec2(5, -1.2), vec2(1, 0), 0.1) : 0;
// show inputs / feedback
float line_a_a = rect(uv2, vec2(-8, 2), vec2(2, 0.1));
@@ -1343,8 +1343,8 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// show fx values
f = mix(f, 1 - f, rect(uv2, vec2(-2, 1.1 + 0.9 * fxa_value), vec2(0.9, 0.9 * fxa_value)));
f = mix(f, 1 - f, rect(uv2, vec2(5, -0.9 + 0.9 * fxb_value), vec2(0.9, 0.9 * fxb_value)));
f = mix(f, 1 - f, rect(uv2, vec2(-2, -2.9 + 0.9 * mfx_value), vec2(0.9, 0.9 * mfx_value)));
f = mix(f, 1 - f, rect(uv2, vec2(-2, -2.9 + 0.9 * fxb_value), vec2(0.9, 0.9 * fxb_value)));
f = mix(f, 1 - f, rect(uv2, vec2(5, -0.9 + 0.9 * mfx_value), vec2(0.9, 0.9 * mfx_value)));
// show mix
f += char_at(uv2, vec2(1.55, -0.6), mix_type ? 0x4B : 0x4D);
+7 -1
View File
@@ -8,5 +8,11 @@ in vec2 vUV;
out vec4 fragColor;
void main() {
fragColor = fx_stage(vUV, tex9, tex0, seed8, src2_3[0], src2_3[1].xy, src2_3[2], src2_3[3].xy, src2_3[4], src2_3[5].xy, src2_3[6].xy);
vec4 color = fx_stage(vUV, tex9, tex0, seed8, src2_3[0], src2_3[1].xy, src2_3[2], src2_3[3].xy, src2_3[4], src2_3[5].xy, src2_3[6].xy);
color = mix(color, vec4(0), src3_1[0].y);
color = mix(color, 1 - color, src3_1[0].z);
fragColor = color;
}
+17 -7
View File
@@ -326,17 +326,26 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
glGetUniformLocation(program->programs[i], name);
}
if (program->src_lengths.length == 0) {
index1 = 0;
for (j = 0; j < state_config.src_active_counts.length; j++) {
for (k = 0; k < state_config.src_active_counts.values[j]; k++) {
program->src_lengths.values[index1++] =
state_config.src_counts.values[j];
}
}
program->src_lengths.length = index1;
}
prefix = config_file_get_str(config, "UNIFORM_SRC_PREFIX", "src");
index1 = index2 = 0;
index2 = 0;
for (j = 0; j < state_config.src_active_counts.length; j++) {
for (k = 0; k < state_config.src_active_counts.values[j]; k++) {
program->src_lengths.values[index1++] = state_config.src_counts.values[j];
sprintf(name, "%s%d_%d", prefix, j + 1, k + 1);
program->isrc_locations[index2++] =
program->isrc_locations[i * program->src_lengths.length + index2++] =
glGetUniformLocation(program->programs[i], name);
}
}
program->src_lengths.length = index1;
// create texX uniforms pointer
prefix = config_file_get_str(config, "UNIFORM_TEX_PREFIX", "tex");
@@ -381,6 +390,7 @@ ShaderProgram shaders_init(FileArray fragment_shaders, ConfigFile config,
program.in_count = config_file_get_int(config, "IN_COUNT", 0);
program.sub_variant_count = state_config.state_max;
program.active_count = state_config.src_active_counts.length;
program.src_lengths.length = 0;
if (program.frag_count > MAX_FRAG) {
log_error("FRAG_COUNT over %d", MAX_FRAG);
@@ -542,9 +552,9 @@ static void use_program(ShaderProgram program, int i, bool output,
offset = 0;
for (j = 0; j < program.src_lengths.length; j++) {
write_uniform_multi_3f(program.isrc_locations[j],
program.src_lengths.values[j],
context->values + offset);
write_uniform_multi_3f(
program.isrc_locations[i * program.src_lengths.length + j],
program.src_lengths.values[j], context->values + offset);
offset += program.src_lengths.values[j];
}
+51 -36
View File
@@ -150,91 +150,106 @@ static void update_page(SharedContext *context, StateConfig state_config,
}
}
static void update_selected(SharedContext *context, StateConfig state_config,
MidiDevice midi) {
unsigned int i;
static void update_active(SharedContext *context, StateConfig state_config,
MidiDevice midi) {
unsigned int i, j, k;
for (i = 0; i < state_config.select_frag_codes.length; i++) {
safe_midi_write(midi, state_config.select_frag_codes.values[i],
i == context->selected ? MIDI_MAX : 0);
for (i = 0; i < state_config.src_active_counts.length; i++) {
for (j = 0; j < state_config.src_active_counts.values[i]; j++) {
k = state_config.src_active_offsets.values[i] + j;
safe_midi_write(midi, state_config.src_active_codes.values[k],
context->active[i] == j ? MIDI_MAX : 0);
}
}
}
static void update_values(SharedContext *context, StateConfig state_config,
MidiDevice midi) {
unsigned int i, j, k, part;
for (i = 0; i < state_config.src_codes.length; i++) {
j = i / 3;
part = arr_uint_remap_index(state_config.src_offsets, &j);
k = state_config.values_offsets.values[part] +
context->active[part] * state_config.src_counts.values[part] + j;
safe_midi_write(midi, state_config.src_codes.values[i],
context->values[k][i % 3] * MIDI_MAX);
}
}
void state_apply_event(SharedContext *context, StateConfig state_config,
MidiDevice midi, unsigned char code,
unsigned char value) {
unsigned int index, sub_index, src_index, part;
unsigned int i, j, k, part;
bool found;
found = false;
// PAGE CHANGE
index = arr_uint_index_of(state_config.select_page_codes, code);
if (index != ARRAY_NOT_FOUND) {
i = arr_uint_index_of(state_config.select_page_codes, code);
if (i != ARRAY_NOT_FOUND) {
found = true;
if (value > 0) {
context->page = index;
context->page = i;
update_page(context, state_config, midi);
}
}
// TARGET CHANGE
index = arr_uint_index_of(state_config.select_frag_codes, code);
if (index != ARRAY_NOT_FOUND) {
i = arr_uint_index_of(state_config.select_frag_codes, code);
if (i != ARRAY_NOT_FOUND) {
found = true;
if (value > 0) {
context->selected = index;
context->selected = i;
update_page(context, state_config, midi);
update_selected(context, state_config, midi);
}
}
// ITEM CHANGE
index = arr_uint_index_of(state_config.select_item_codes, code);
if (index != ARRAY_NOT_FOUND) {
i = arr_uint_index_of(state_config.select_item_codes, code);
if (i != ARRAY_NOT_FOUND) {
found = true;
if (value > 0) {
context->state[context->selected] =
context->page * state_config.select_item_codes.length + index;
context->page * state_config.select_item_codes.length + i;
update_page(context, state_config, midi);
}
}
// ACTIVE CHANGE
index = arr_uint_index_of(state_config.src_active_codes, code);
if (index != ARRAY_NOT_FOUND) {
i = arr_uint_index_of(state_config.src_active_codes, code);
if (i != ARRAY_NOT_FOUND) {
found = true;
if (value > 0) {
part = arr_uint_remap_index(state_config.src_active_offsets, &index);
context->active[part] = index;
// TODO update values
part = arr_uint_remap_index(state_config.src_active_offsets, &i);
context->active[part] = i;
update_active(context, state_config, midi);
update_values(context, state_config, midi);
}
}
// VALUE CHANGE
index = arr_uint_index_of(state_config.src_codes, code);
if (index != ARRAY_NOT_FOUND) {
i = arr_uint_index_of(state_config.src_codes, code);
if (i != ARRAY_NOT_FOUND) {
found = true;
sub_index = index / 3;
part = arr_uint_remap_index(state_config.src_offsets, &sub_index);
src_index = state_config.values_offsets.values[part] +
context->active[part] * state_config.src_counts.values[part] +
sub_index;
j = i / 3;
part = arr_uint_remap_index(state_config.src_offsets, &j);
k = state_config.values_offsets.values[part] +
context->active[part] * state_config.src_counts.values[part] + j;
if (arr_uint_index_of(state_config.fader_codes, code) != ARRAY_NOT_FOUND) {
context->values[src_index][index % 3] = (float)value / MIDI_MAX;
context->values[k][i % 3] = (float)value / MIDI_MAX;
} else if (value > 0) {
if (context->values[src_index][index % 3] > 0.5) {
context->values[src_index][index % 3] = 0;
if (context->values[k][i % 3] > 0.5) {
context->values[k][i % 3] = 0;
midi_write(midi, code, 0);
} else {
context->values[src_index][index % 3] = 1;
context->values[k][i % 3] = 1;
midi_write(midi, code, MIDI_MAX);
}
}
}
// TODO values
if (!found) {
log_trace("unknown midi: %d %d", code, value);
midi_write(midi, code, value);
@@ -258,8 +273,8 @@ bool state_background_midi_write(SharedContext *context,
log_info("(state) background writing started (pid: %d)", pid);
update_page(context, state_config, midi);
update_selected(context, state_config, midi);
// TODO init values
update_active(context, state_config, midi);
update_values(context, state_config, midi);
while (!context->stop) {
// TODO tap tempo and more