fix: allow demo even without midi
This commit is contained in:
@@ -18,7 +18,7 @@ TODO cool image and youtube link
|
||||
- [From release](#from-release)
|
||||
- [From repository (PKGBUILD)](#from-repository-pkgbuild)
|
||||
- [From repository (dev version)](#from-repository-dev-version)
|
||||
- [Usage](#usage)
|
||||
- [CLI usage](#cli-usage)
|
||||
- [Default Shaders and Config](#default-shaders-and-config)
|
||||
- [Sources and Effects](#sources-and-effects)
|
||||
- [Debug View](#debug-view)
|
||||
@@ -81,7 +81,7 @@ make
|
||||
make install
|
||||
```
|
||||
|
||||
## Usage
|
||||
## CLI usage
|
||||
|
||||
```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]
|
||||
|
||||
+3
-3
@@ -265,10 +265,10 @@ void forge_run(Parameters params) {
|
||||
if (!midi_background_listen(midi, context, midi_callback)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!state_background_midi_write(context, state_config, midi)) {
|
||||
return;
|
||||
}
|
||||
if (!state_background_write(context, state_config, midi)) {
|
||||
return;
|
||||
}
|
||||
|
||||
window_startup(error_callback);
|
||||
|
||||
+11
-9
@@ -272,8 +272,8 @@ void state_apply_event(SharedContext *context, StateConfig state_config,
|
||||
}
|
||||
}
|
||||
|
||||
bool state_background_midi_write(SharedContext *context,
|
||||
StateConfig state_config, MidiDevice midi) {
|
||||
bool state_background_write(SharedContext *context, StateConfig state_config,
|
||||
MidiDevice midi) {
|
||||
pid_t pid;
|
||||
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);
|
||||
|
||||
update_page(context, state_config, midi);
|
||||
update_active(context, state_config, midi);
|
||||
update_values(context, state_config, midi);
|
||||
if (!midi.error) {
|
||||
update_page(context, state_config, midi);
|
||||
update_active(context, state_config, midi);
|
||||
update_values(context, state_config, midi);
|
||||
}
|
||||
|
||||
last_active = false;
|
||||
last_change = false;
|
||||
@@ -297,20 +299,20 @@ bool state_background_midi_write(SharedContext *context,
|
||||
while (!context->stop) {
|
||||
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,
|
||||
beat_active ? MIDI_MAX : 0);
|
||||
|
||||
safe_midi_write(midi,
|
||||
state_config.select_frag_codes.values[context->selected],
|
||||
beat_active ? MIDI_MAX : 0);
|
||||
|
||||
last_active = beat_active;
|
||||
}
|
||||
|
||||
last_active = beat_active;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ void state_apply_event(SharedContext *context, StateConfig state_config,
|
||||
MidiDevice midi, unsigned char code, unsigned char value,
|
||||
bool trace_midi);
|
||||
|
||||
bool state_background_midi_write(SharedContext *context,
|
||||
StateConfig state_config, MidiDevice midi);
|
||||
bool state_background_write(SharedContext *context, StateConfig state_config,
|
||||
MidiDevice midi);
|
||||
|
||||
void state_init(SharedContext *context, StateConfig state_config, bool demo,
|
||||
unsigned int base_tempo, char *state_file, bool load_state);
|
||||
|
||||
Reference in New Issue
Block a user