Octave figures are now written into PNGs

This commit is contained in:
ha7ilm 2017-03-05 17:21:38 +01:00
parent a1a64b3a72
commit f93e7c4a99
3 changed files with 10 additions and 3 deletions

2
csdr.c
View file

@ -2376,7 +2376,7 @@ int main(int argc, char *argv[])
timing_recovery_state_t state = timing_recovery_init(algorithm, decimation, add_q); timing_recovery_state_t state = timing_recovery_init(algorithm, decimation, add_q);
int debug_i=0; int debug_i=0;
state.debug_force = !!debug_n; //should remove that later state.debug_writefiles = state.debug_force = !!debug_n; //should remove that later
FREAD_C; FREAD_C;
for(;;) for(;;)
{ {

View file

@ -1644,8 +1644,9 @@ void pll_cc(pll_t* p, complexf* input, float* output_dphase, complexf* output_nc
} }
} }
void octave_plot_point_on_cplxsig(complexf* signal, int signal_size, float error, int index, int points_size, ...) void octave_plot_point_on_cplxsig(complexf* signal, int signal_size, float error, int index, int writefiles, int points_size, ...)
{ {
static int figure_output_counter = 0;
int* points_z = (int*)malloc(sizeof(int)*points_size); int* points_z = (int*)malloc(sizeof(int)*points_size);
int* points_color = (int*)malloc(sizeof(int)*points_size); int* points_color = (int*)malloc(sizeof(int)*points_size);
va_list vl; va_list vl;
@ -1655,6 +1656,7 @@ void octave_plot_point_on_cplxsig(complexf* signal, int signal_size, float error
points_z[i] = va_arg(vl, int); points_z[i] = va_arg(vl, int);
points_color[i] = va_arg(vl, int); points_color[i] = va_arg(vl, int);
} }
if(writefiles && !figure_output_counter) fprintf(stderr, "cf=figure();\n");
fprintf(stderr, "N = %d;\nisig = [", signal_size); fprintf(stderr, "N = %d;\nisig = [", signal_size);
for(int i=0;i<signal_size;i++) fprintf(stderr, "%f ", iof(signal,i)); for(int i=0;i<signal_size;i++) fprintf(stderr, "%f ", iof(signal,i));
fprintf(stderr, "];\nqsig = ["); fprintf(stderr, "];\nqsig = [");
@ -1679,6 +1681,7 @@ void octave_plot_point_on_cplxsig(complexf* signal, int signal_size, float error
(char)points_color[i]&0xff, (i<points_size-1)?',':' ' (char)points_color[i]&0xff, (i<points_size-1)?',':' '
); );
fprintf(stderr, ");\n"); fprintf(stderr, ");\n");
if(writefiles) fprintf(stderr, "print(cf, \"figs/%05d.png\", \"-S1024,1024\");\n", figure_output_counter++);
fflush(stderr); fflush(stderr);
free(points_z); free(points_z);
free(points_color); free(points_color);
@ -1693,6 +1696,7 @@ timing_recovery_state_t timing_recovery_init(timing_recovery_algorithm_t algorit
to_return.debug_phase = -1; to_return.debug_phase = -1;
to_return.debug_count = 3; to_return.debug_count = 3;
to_return.debug_force = 0; to_return.debug_force = 0;
to_return.debug_writefiles = 0;
return to_return; return to_return;
} }
@ -1739,6 +1743,7 @@ void timing_recovery_cc(complexf* input, complexf* output, int input_size, timin
octave_plot_point_on_cplxsig(input+current_bitstart_index, state->decimation_rate*2, octave_plot_point_on_cplxsig(input+current_bitstart_index, state->decimation_rate*2,
error, error,
current_bitstart_index, current_bitstart_index,
state->debug_writefiles,
3, //number of points to draw below: 3, //number of points to draw below:
num_samples_halfbit * 1, 'r', num_samples_halfbit * 1, 'r',
num_samples_halfbit * 2, 'r', num_samples_halfbit * 2, 'r',
@ -1781,6 +1786,7 @@ void timing_recovery_cc(complexf* input, complexf* output, int input_size, timin
octave_plot_point_on_cplxsig(input+current_bitstart_index, state->decimation_rate*2, octave_plot_point_on_cplxsig(input+current_bitstart_index, state->decimation_rate*2,
error, error,
current_bitstart_index, current_bitstart_index,
state->debug_writefiles,
3, 3,
num_samples_quarterbit * 1, 'r', num_samples_quarterbit * 1, 'r',
num_samples_quarterbit * 2, 'r', num_samples_quarterbit * 2, 'r',

View file

@ -306,6 +306,7 @@ typedef struct timing_recovery_state_s
int debug_phase; int debug_phase;
int debug_count; int debug_count;
int debug_force; int debug_force;
int debug_writefiles;
} timing_recovery_state_t; } timing_recovery_state_t;
timing_recovery_state_t timing_recovery_init(timing_recovery_algorithm_t algorithm, int decimation_rate, int use_q); timing_recovery_state_t timing_recovery_init(timing_recovery_algorithm_t algorithm, int decimation_rate, int use_q);
@ -313,4 +314,4 @@ void timing_recovery_cc(complexf* input, complexf* output, int input_length, tim
timing_recovery_algorithm_t timing_recovery_get_algorithm_from_string(char* input); timing_recovery_algorithm_t timing_recovery_get_algorithm_from_string(char* input);
char* timing_recovery_get_string_from_algorithm(timing_recovery_algorithm_t algorithm); char* timing_recovery_get_string_from_algorithm(timing_recovery_algorithm_t algorithm);
void timing_recovery_trigger_debug(timing_recovery_state_t* state, int debug_phase); void timing_recovery_trigger_debug(timing_recovery_state_t* state, int debug_phase);
void octave_plot_point_on_cplxsig(complexf* signal, int signal_size, float error, int index, int points_size, ...); void octave_plot_point_on_cplxsig(complexf* signal, int signal_size, float error, int index, int writefiles, int points_size, ...);