fix: allow demo even without midi

This commit is contained in:
2025-11-06 00:15:15 +01:00
parent ca20a54f56
commit 0d4f5886bf
4 changed files with 18 additions and 16 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ TODO cool image and youtube link
- [From release](#from-release) - [From release](#from-release)
- [From repository (PKGBUILD)](#from-repository-pkgbuild) - [From repository (PKGBUILD)](#from-repository-pkgbuild)
- [From repository (dev version)](#from-repository-dev-version) - [From repository (dev version)](#from-repository-dev-version)
- [Usage](#usage) - [CLI usage](#cli-usage)
- [Default Shaders and Config](#default-shaders-and-config) - [Default Shaders and Config](#default-shaders-and-config)
- [Sources and Effects](#sources-and-effects) - [Sources and Effects](#sources-and-effects)
- [Debug View](#debug-view) - [Debug View](#debug-view)
@@ -81,7 +81,7 @@ make
make install make install
``` ```
## Usage ## CLI usage
```txt ```txt
usage: forge [-h] [-v] [-hr] [-s=SCREEN] [-m=SCREEN] [-mo] [-f=DIR_PATH] [-c=CFG_PATH] [-sf=STATE_PATH] [-ls / -nls] [-ss / -nss] [-is=SIZE] [-v=FILE] [-vs=SIZE] [-t=TEMPO] [--demo] [-w] usage: forge [-h] [-v] [-hr] [-s=SCREEN] [-m=SCREEN] [-mo] [-f=DIR_PATH] [-c=CFG_PATH] [-sf=STATE_PATH] [-ls / -nls] [-ss / -nss] [-is=SIZE] [-v=FILE] [-vs=SIZE] [-t=TEMPO] [--demo] [-w]
+3 -3
View File
@@ -265,10 +265,10 @@ void forge_run(Parameters params) {
if (!midi_background_listen(midi, context, midi_callback)) { if (!midi_background_listen(midi, context, midi_callback)) {
return; return;
} }
if (!state_background_midi_write(context, state_config, midi)) {
return;
} }
if (!state_background_write(context, state_config, midi)) {
return;
} }
window_startup(error_callback); window_startup(error_callback);
+7 -5
View File
@@ -272,8 +272,8 @@ void state_apply_event(SharedContext *context, StateConfig state_config,
} }
} }
bool state_background_midi_write(SharedContext *context, bool state_background_write(SharedContext *context, StateConfig state_config,
StateConfig state_config, MidiDevice midi) { MidiDevice midi) {
pid_t pid; pid_t pid;
bool beat_active, last_active, change, last_change; bool beat_active, last_active, change, last_change;
@@ -287,9 +287,11 @@ bool state_background_midi_write(SharedContext *context,
} }
log_info("(state) background writing started (pid: %d)", pid); log_info("(state) background writing started (pid: %d)", pid);
if (!midi.error) {
update_page(context, state_config, midi); update_page(context, state_config, midi);
update_active(context, state_config, midi); update_active(context, state_config, midi);
update_values(context, state_config, midi); update_values(context, state_config, midi);
}
last_active = false; last_active = false;
last_change = false; last_change = false;
@@ -297,20 +299,20 @@ bool state_background_midi_write(SharedContext *context,
while (!context->stop) { while (!context->stop) {
beat_active = tempo_progress(context->tempo, 1.0) < 0.25; beat_active = tempo_progress(context->tempo, 1.0) < 0.25;
if (beat_active != last_active) { if (!midi.error && beat_active != last_active) {
safe_midi_write(midi, state_config.tap_tempo_code, safe_midi_write(midi, state_config.tap_tempo_code,
beat_active ? MIDI_MAX : 0); beat_active ? MIDI_MAX : 0);
safe_midi_write(midi, safe_midi_write(midi,
state_config.select_frag_codes.values[context->selected], state_config.select_frag_codes.values[context->selected],
beat_active ? MIDI_MAX : 0); beat_active ? MIDI_MAX : 0);
}
last_active = beat_active; last_active = beat_active;
}
change = tempo_progress(context->tempo, 4.0) < 0.25; change = tempo_progress(context->tempo, 4.0) < 0.25;
if (change && !last_change && context->demo) { if (context->demo && change && !last_change) {
state_randomize(context, state_config); state_randomize(context, state_config);
} }
+2 -2
View File
@@ -9,8 +9,8 @@ void state_apply_event(SharedContext *context, StateConfig state_config,
MidiDevice midi, unsigned char code, unsigned char value, MidiDevice midi, unsigned char code, unsigned char value,
bool trace_midi); bool trace_midi);
bool state_background_midi_write(SharedContext *context, bool state_background_write(SharedContext *context, StateConfig state_config,
StateConfig state_config, MidiDevice midi); MidiDevice midi);
void state_init(SharedContext *context, StateConfig state_config, bool demo, void state_init(SharedContext *context, StateConfig state_config, bool demo,
unsigned int base_tempo, char *state_file, bool load_state); unsigned int base_tempo, char *state_file, bool load_state);