feat: 0 hotkey to reset everything
This commit is contained in:
+1
-1
@@ -113,7 +113,7 @@ make -f Makefile.dev release-arch
|
|||||||
- [x] Documentation in default config file
|
- [x] Documentation in default config file
|
||||||
- [x] Clone "shaders" and config in system path at setup
|
- [x] Clone "shaders" and config in system path at setup
|
||||||
- [ ] Minimal sample shaders
|
- [ ] Minimal sample shaders
|
||||||
- [ ] Hotkey `0` to reset everything
|
- [x] Hotkey `0` to reset everything
|
||||||
- [x] Printable PDF of default scr/fx
|
- [x] Printable PDF of default scr/fx
|
||||||
- [x] Add NanoKontrol setup file
|
- [x] Add NanoKontrol setup file
|
||||||
- [x] Find and fix opengl errors 0500 ?
|
- [x] Find and fix opengl errors 0500 ?
|
||||||
|
|||||||
@@ -159,7 +159,8 @@ make install
|
|||||||
When running, the following hotkeys are available:
|
When running, the following hotkeys are available:
|
||||||
|
|
||||||
* <kbd>Esc</kbd>: Exit window
|
* <kbd>Esc</kbd>: Exit window
|
||||||
* <kbd>R</kbd>: Randomize shader state
|
* <kbd>R</kbd>: Randomize internal values
|
||||||
|
* <kbd>0</kbd>: Reset internal values to 0
|
||||||
* <kbd>D</kbd>: Demo mode On/Off
|
* <kbd>D</kbd>: Demo mode On/Off
|
||||||
* <kbd>A</kbd>: Auto Random mode On/Off
|
* <kbd>A</kbd>: Auto Random mode On/Off
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -125,8 +125,14 @@ static void key_callback(Window *window, int key,
|
|||||||
window_close(window);
|
window_close(window);
|
||||||
} else if (window_char_key(key, action, 82)) {
|
} else if (window_char_key(key, action, 82)) {
|
||||||
// R: randomize
|
// R: randomize
|
||||||
log_info("[R] Randomizing...");
|
log_info("[R] Randomized");
|
||||||
state_randomize(context, &project.state_config);
|
state_randomize(context, &project.state_config);
|
||||||
|
state_apply(context, &project.state_config, &midi);
|
||||||
|
} else if (window_char_key(key, action, 48)) {
|
||||||
|
// 0: reset
|
||||||
|
log_info("[0] Reset");
|
||||||
|
state_reset(context);
|
||||||
|
state_apply(context, &project.state_config, &midi);
|
||||||
} else if (window_char_key(key, action, 68)) {
|
} else if (window_char_key(key, action, 68)) {
|
||||||
// D: demo on/off
|
// D: demo on/off
|
||||||
log_info((context->demo ? "[D] Demo OFF" : "[D] Demo ON"));
|
log_info((context->demo ? "[D] Demo OFF" : "[D] Demo ON"));
|
||||||
|
|||||||
+19
@@ -279,6 +279,13 @@ void state_apply_event(SharedContext *context, const StateConfig *state_config,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void state_apply(SharedContext *context, const StateConfig *state_config,
|
||||||
|
const MidiDevice *midi) {
|
||||||
|
if (!midi->error) {
|
||||||
|
update_values(context, state_config, midi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool state_background_write(SharedContext *context,
|
bool state_background_write(SharedContext *context,
|
||||||
const StateConfig *state_config,
|
const StateConfig *state_config,
|
||||||
const MidiDevice *midi) {
|
const MidiDevice *midi) {
|
||||||
@@ -322,6 +329,8 @@ bool state_background_write(SharedContext *context,
|
|||||||
|
|
||||||
if (context->auto_random && change && !last_change) {
|
if (context->auto_random && change && !last_change) {
|
||||||
state_randomize(context, state_config);
|
state_randomize(context, state_config);
|
||||||
|
|
||||||
|
state_apply(context, state_config, midi);
|
||||||
}
|
}
|
||||||
|
|
||||||
last_change = change;
|
last_change = change;
|
||||||
@@ -403,7 +412,17 @@ void state_init(SharedContext *context, const StateConfig *state_config,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void state_reset(SharedContext *context) {
|
||||||
|
memset(context->values, 0, sizeof(context->values));
|
||||||
|
memset(context->state.values, 0, sizeof(context->state.values));
|
||||||
|
}
|
||||||
|
|
||||||
void state_randomize(SharedContext *context, const StateConfig *state_config) {
|
void state_randomize(SharedContext *context, const StateConfig *state_config) {
|
||||||
|
for (unsigned int i = 0; i < state_config->midi_codes.length; i++) {
|
||||||
|
context->values[i][0] = (float)rand_uint(MIDI_MAX) / MIDI_MAX;
|
||||||
|
context->values[i][1] = (float)rand_uint(MIDI_MAX) / MIDI_MAX;
|
||||||
|
context->values[i][2] = (float)rand_uint(MIDI_MAX) / MIDI_MAX;
|
||||||
|
}
|
||||||
for (unsigned int i = 0; i < context->state.length; i++) {
|
for (unsigned int i = 0; i < context->state.length; i++) {
|
||||||
context->state.values[i] = rand_uint(state_config->state_max);
|
context->state.values[i] = rand_uint(state_config->state_max);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,13 @@ void state_init(SharedContext *context, const StateConfig *state_config,
|
|||||||
bool demo, bool auto_random, unsigned int base_tempo,
|
bool demo, bool auto_random, unsigned int base_tempo,
|
||||||
const char *state_file, bool load_state);
|
const char *state_file, bool load_state);
|
||||||
|
|
||||||
|
void state_reset(SharedContext *context);
|
||||||
|
|
||||||
void state_randomize(SharedContext *context, const StateConfig *state_config);
|
void state_randomize(SharedContext *context, const StateConfig *state_config);
|
||||||
|
|
||||||
|
void state_apply(SharedContext *context, const StateConfig *state_config,
|
||||||
|
const MidiDevice *midi);
|
||||||
|
|
||||||
void state_save(const SharedContext *context, const StateConfig *state_config,
|
void state_save(const SharedContext *context, const StateConfig *state_config,
|
||||||
const char *state_file);
|
const char *state_file);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user