feat(trace): trace fps and midi with args
This commit is contained in:
@@ -78,6 +78,8 @@ options:
|
|||||||
-t, --tempo base tempo (default: 60)
|
-t, --tempo base tempo (default: 60)
|
||||||
--demo demonstration mode (assume --no-save-state and --no-load-state)
|
--demo demonstration mode (assume --no-save-state and --no-load-state)
|
||||||
-w, --windowed not fullscreen
|
-w, --windowed not fullscreen
|
||||||
|
--trace-midi print midi code and values
|
||||||
|
--trace-fps print fps status of subsystems
|
||||||
```
|
```
|
||||||
|
|
||||||
## Release guide
|
## Release guide
|
||||||
|
|||||||
+10
-2
@@ -58,7 +58,9 @@ static void print_help(int status_code) {
|
|||||||
" -t, --tempo base tempo (default: 60)\n"
|
" -t, --tempo base tempo (default: 60)\n"
|
||||||
" --demo demonstration mode (assume --no-save-state "
|
" --demo demonstration mode (assume --no-save-state "
|
||||||
"and --no-load-state)\n"
|
"and --no-load-state)\n"
|
||||||
" -w, --windowed not fullscreen\n");
|
" -w, --windowed not fullscreen\n"
|
||||||
|
" --trace-midi print midi code and values\n"
|
||||||
|
" --trace-fps print fps status of subsystems\n");
|
||||||
exit(status_code);
|
exit(status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,13 +109,15 @@ Parameters args_parse(int argc, char **argv) {
|
|||||||
strncpy(params.config_path, DATADIR "/default.cfg", STR_LEN);
|
strncpy(params.config_path, DATADIR "/default.cfg", STR_LEN);
|
||||||
strncpy(params.state_file, "forge_saved_state.txt", STR_LEN);
|
strncpy(params.state_file, "forge_saved_state.txt", STR_LEN);
|
||||||
params.load_state = true;
|
params.load_state = true;
|
||||||
params.save_state = false;
|
params.save_state = true;
|
||||||
params.internal_size = 720;
|
params.internal_size = 720;
|
||||||
params.video_size = 0;
|
params.video_size = 0;
|
||||||
params.base_tempo = 60.0f;
|
params.base_tempo = 60.0f;
|
||||||
params.demo = false;
|
params.demo = false;
|
||||||
params.windowed = false;
|
params.windowed = false;
|
||||||
params.video_in.length = 0;
|
params.video_in.length = 0;
|
||||||
|
params.trace_midi = false;
|
||||||
|
params.trace_fps = false;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
arg = argv[i];
|
arg = argv[i];
|
||||||
@@ -171,6 +175,10 @@ Parameters args_parse(int argc, char **argv) {
|
|||||||
params.save_state = false;
|
params.save_state = false;
|
||||||
} else if (is_arg(arg, "-w") || is_arg(arg, "--windowed")) {
|
} else if (is_arg(arg, "-w") || is_arg(arg, "--windowed")) {
|
||||||
params.windowed = true;
|
params.windowed = true;
|
||||||
|
} else if (is_arg(arg, "--trace-midi")) {
|
||||||
|
params.trace_midi = true;
|
||||||
|
} else if (is_arg(arg, "--trace-fps")) {
|
||||||
|
params.trace_fps = true;
|
||||||
} else {
|
} else {
|
||||||
invalid_arg(arg);
|
invalid_arg(arg);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-8
@@ -31,15 +31,18 @@ static Timer timer;
|
|||||||
static ConfigFile config;
|
static ConfigFile config;
|
||||||
static MidiDevice midi;
|
static MidiDevice midi;
|
||||||
static StateConfig state_config;
|
static StateConfig state_config;
|
||||||
|
static bool trace_midi;
|
||||||
|
|
||||||
static void compute_fps() {
|
static void compute_fps(bool trace_fps) {
|
||||||
double fps;
|
double fps;
|
||||||
char title[100];
|
char title[100];
|
||||||
|
|
||||||
if (timer_inc(&timer)) {
|
if (timer_inc(&timer)) {
|
||||||
fps = timer_reset(&timer);
|
fps = timer_reset(&timer);
|
||||||
|
|
||||||
|
if (trace_fps) {
|
||||||
log_trace("(main) %.2ffps", fps);
|
log_trace("(main) %.2ffps", fps);
|
||||||
|
}
|
||||||
|
|
||||||
if (window_output != NULL) {
|
if (window_output != NULL) {
|
||||||
sprintf(title, PACKAGE " " VERSION " - %.0ffps", fps);
|
sprintf(title, PACKAGE " " VERSION " - %.0ffps", fps);
|
||||||
@@ -148,12 +151,12 @@ static void init_inputs(StringArray video_in, unsigned int video_size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool start_video_captures(unsigned int video_count) {
|
static bool start_video_captures(unsigned int video_count, bool trace_fps) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < video_count; i++) {
|
for (i = 0; i < video_count; i++) {
|
||||||
if (!inputs.values[i].error &&
|
if (!inputs.values[i].error &&
|
||||||
!video_background_read(&inputs.values[i], context, i)) {
|
!video_background_read(&inputs.values[i], context, i, trace_fps)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,15 +200,15 @@ static void key_callback(Window *window, int key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void midi_callback(unsigned char code, unsigned char value) {
|
static void midi_callback(unsigned char code, unsigned char value) {
|
||||||
state_apply_event(context, state_config, midi, code, value);
|
state_apply_event(context, state_config, midi, code, value, trace_midi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loop(bool hr) {
|
static void loop(bool hr, bool trace_fps) {
|
||||||
if (hr) {
|
if (hr) {
|
||||||
hot_reload();
|
hot_reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
compute_fps();
|
compute_fps(trace_fps);
|
||||||
|
|
||||||
context->time = window_get_time();
|
context->time = window_get_time();
|
||||||
|
|
||||||
@@ -248,7 +251,7 @@ void forge_run(Parameters params) {
|
|||||||
|
|
||||||
init_context(params, in_count);
|
init_context(params, in_count);
|
||||||
|
|
||||||
if (!start_video_captures(params.video_in.length)) {
|
if (!start_video_captures(params.video_in.length, params.trace_fps)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,6 +260,8 @@ void forge_run(Parameters params) {
|
|||||||
if (midi.error) {
|
if (midi.error) {
|
||||||
params.demo = true;
|
params.demo = true;
|
||||||
} else {
|
} else {
|
||||||
|
trace_midi = params.trace_midi;
|
||||||
|
|
||||||
if (!midi_background_listen(midi, context, midi_callback)) {
|
if (!midi_background_listen(midi, context, midi_callback)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -308,7 +313,7 @@ void forge_run(Parameters params) {
|
|||||||
|
|
||||||
while ((window_output == NULL || !window_should_close(window_output)) &&
|
while ((window_output == NULL || !window_should_close(window_output)) &&
|
||||||
(window_monitor == NULL || !window_should_close(window_monitor))) {
|
(window_monitor == NULL || !window_should_close(window_monitor))) {
|
||||||
loop(params.hot_reload);
|
loop(params.hot_reload, params.trace_fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
context->stop = true;
|
context->stop = true;
|
||||||
|
|||||||
+5
-3
@@ -182,8 +182,8 @@ static void update_values(SharedContext *context, StateConfig state_config,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void state_apply_event(SharedContext *context, StateConfig state_config,
|
void state_apply_event(SharedContext *context, StateConfig state_config,
|
||||||
MidiDevice midi, unsigned char code,
|
MidiDevice midi, unsigned char code, unsigned char value,
|
||||||
unsigned char value) {
|
bool trace_midi) {
|
||||||
unsigned int i, j, k, part;
|
unsigned int i, j, k, part;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
@@ -263,9 +263,11 @@ void state_apply_event(SharedContext *context, StateConfig state_config,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
if (trace_midi) {
|
||||||
log_trace("unknown midi: %d %d", code, value);
|
log_trace("unknown midi: %d %d", code, value);
|
||||||
|
}
|
||||||
midi_write(midi, code, value);
|
midi_write(midi, code, value);
|
||||||
} else {
|
} else if (trace_midi) {
|
||||||
log_trace("midi: %d %d", code, value);
|
log_trace("midi: %d %d", code, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@
|
|||||||
StateConfig state_parse_config(ConfigFile config);
|
StateConfig state_parse_config(ConfigFile config);
|
||||||
|
|
||||||
void state_apply_event(SharedContext *context, StateConfig state_config,
|
void state_apply_event(SharedContext *context, StateConfig state_config,
|
||||||
MidiDevice midi, unsigned char code,
|
MidiDevice midi, unsigned char code, unsigned char value,
|
||||||
unsigned char value);
|
bool trace_midi);
|
||||||
|
|
||||||
bool state_background_midi_write(SharedContext *context,
|
bool state_background_midi_write(SharedContext *context,
|
||||||
StateConfig state_config, MidiDevice midi);
|
StateConfig state_config, MidiDevice midi);
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ typedef struct Parameters {
|
|||||||
bool demo;
|
bool demo;
|
||||||
bool windowed;
|
bool windowed;
|
||||||
StringArray video_in;
|
StringArray video_in;
|
||||||
|
bool trace_midi;
|
||||||
|
bool trace_fps;
|
||||||
} Parameters;
|
} Parameters;
|
||||||
|
|
||||||
typedef struct Vertex {
|
typedef struct Vertex {
|
||||||
|
|||||||
+3
-1
@@ -329,7 +329,7 @@ static bool read_video(VideoCapture *video_capture) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool video_background_read(VideoCapture *video_capture, SharedContext *context,
|
bool video_background_read(VideoCapture *video_capture, SharedContext *context,
|
||||||
int input_index) {
|
int input_index, bool trace_fps) {
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
double fps;
|
double fps;
|
||||||
@@ -352,9 +352,11 @@ bool video_background_read(VideoCapture *video_capture, SharedContext *context,
|
|||||||
fps = timer_reset(&timer);
|
fps = timer_reset(&timer);
|
||||||
|
|
||||||
context->input_fps[input_index] = (unsigned int)round(fps);
|
context->input_fps[input_index] = (unsigned int)round(fps);
|
||||||
|
if (trace_fps) {
|
||||||
log_trace("(%s) %.2ffps", video_capture->name, fps);
|
log_trace("(%s) %.2ffps", video_capture->name, fps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (context->stop) {
|
if (context->stop) {
|
||||||
log_info("(%s) background acquisition stopped by main thread (pid: %d)",
|
log_info("(%s) background acquisition stopped by main thread (pid: %d)",
|
||||||
video_capture->name, pid);
|
video_capture->name, pid);
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
VideoCapture video_init(char *name, unsigned int preferred_height);
|
VideoCapture video_init(char *name, unsigned int preferred_height);
|
||||||
|
|
||||||
bool video_background_read(VideoCapture *video_capture, SharedContext *context,
|
bool video_background_read(VideoCapture *video_capture, SharedContext *context,
|
||||||
int input_index);
|
int input_index, bool trace_fps);
|
||||||
|
|
||||||
void video_free(VideoCapture video_capture);
|
void video_free(VideoCapture video_capture);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user