refactor(state): state_init
This commit is contained in:
@@ -158,3 +158,4 @@ make -f Makefile.dev release-arch
|
||||
- [ ] Bonus
|
||||
- [ ] Record show as text files
|
||||
- [ ] Play from record text file
|
||||
- [ ] Try to write NanoKontrol config
|
||||
+4
-26
@@ -11,7 +11,6 @@
|
||||
#include "file.h"
|
||||
#include "forge.h"
|
||||
#include "midi.h"
|
||||
#include "rand.h"
|
||||
#include "shaders.h"
|
||||
#include "shared.h"
|
||||
#include "state.h"
|
||||
@@ -56,34 +55,13 @@ static void compute_fps() {
|
||||
}
|
||||
}
|
||||
|
||||
static void init_context(Parameters params, unsigned int in_count,
|
||||
unsigned int frag_count) {
|
||||
static void init_context(Parameters params, unsigned int in_count) {
|
||||
unsigned int i;
|
||||
|
||||
context->tempo = tempo_init();
|
||||
tempo_set(&context->tempo, params.base_tempo);
|
||||
context->demo = params.demo;
|
||||
state_init(context, state_config, params.demo, params.base_tempo);
|
||||
|
||||
context->monitor = params.monitor;
|
||||
|
||||
context->state.length = frag_count;
|
||||
memset(context->state.values, 0, sizeof(context->state.values));
|
||||
|
||||
if (params.demo) {
|
||||
state_randomize(context, state_config);
|
||||
}
|
||||
|
||||
memset(context->active, 0, sizeof(context->active));
|
||||
memset(context->values, 0, sizeof(context->values));
|
||||
|
||||
context->page = 0;
|
||||
context->selected = 0;
|
||||
|
||||
memset(context->seeds, 0, sizeof(context->seeds));
|
||||
|
||||
for (i = 0; i < frag_count; i++) {
|
||||
context->seeds[i] = rand_uint(1000);
|
||||
}
|
||||
|
||||
memset(context->input_resolutions, 0, sizeof(context->input_resolutions));
|
||||
memset(context->input_formats, 0, sizeof(context->input_formats));
|
||||
memset(context->input_fps, 0, sizeof(context->input_fps));
|
||||
@@ -269,7 +247,7 @@ void forge_run(Parameters params) {
|
||||
|
||||
init_inputs(params.video_in, params.video_size);
|
||||
|
||||
init_context(params, in_count, frag_count);
|
||||
init_context(params, in_count);
|
||||
|
||||
if (!start_video_captures(params.video_in.length)) {
|
||||
return;
|
||||
|
||||
+28
@@ -317,6 +317,34 @@ bool state_background_midi_write(SharedContext *context,
|
||||
return false;
|
||||
}
|
||||
|
||||
void state_init(SharedContext *context, StateConfig state_config, bool demo,
|
||||
unsigned int base_tempo) {
|
||||
unsigned int i;
|
||||
|
||||
context->tempo = tempo_init();
|
||||
tempo_set(&context->tempo, base_tempo);
|
||||
context->demo = demo;
|
||||
|
||||
context->state.length = state_config.select_frag_codes.length;
|
||||
memset(context->state.values, 0, sizeof(context->state.values));
|
||||
|
||||
if (demo) {
|
||||
state_randomize(context, state_config);
|
||||
}
|
||||
|
||||
memset(context->active, 0, sizeof(context->active));
|
||||
memset(context->values, 0, sizeof(context->values));
|
||||
|
||||
context->page = 0;
|
||||
context->selected = 0;
|
||||
|
||||
memset(context->seeds, 0, sizeof(context->seeds));
|
||||
|
||||
for (i = 0; i < state_config.select_frag_codes.length; i++) {
|
||||
context->seeds[i] = rand_uint(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void state_randomize(SharedContext *context, StateConfig state_config) {
|
||||
unsigned int i;
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ void state_apply_event(SharedContext *context, StateConfig state_config,
|
||||
bool state_background_midi_write(SharedContext *context,
|
||||
StateConfig state_config, MidiDevice midi);
|
||||
|
||||
void state_init(SharedContext *context, StateConfig state_config, bool demo,
|
||||
unsigned int base_tempo);
|
||||
|
||||
void state_randomize(SharedContext *context, StateConfig state_config);
|
||||
|
||||
#endif /* STATE_H */
|
||||
Reference in New Issue
Block a user