From 2321e798d2eeb40f951a004f8df13727984dfe99 Mon Sep 17 00:00:00 2001 From: Arnaud Blanchard <arnaud.blanchard@ensea.fr> Date: Tue, 16 May 2017 14:22:06 +0200 Subject: [PATCH] Add blc_quit in parameter of blc_init of each program --- i_sndfile/i_sndfile.cpp | 6 +++--- o_sndfile/o_sndfile.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/i_sndfile/i_sndfile.cpp b/i_sndfile/i_sndfile.cpp index 59e519c..c66281a 100644 --- a/i_sndfile/i_sndfile.cpp +++ b/i_sndfile/i_sndfile.cpp @@ -20,10 +20,10 @@ int main(int argc, char**argv){ blc_program_add_option(&filename, 'f', "file", "string", "filename of the file to write", NULL); blc_program_add_option(&output_name, 'o', "output", "string", "Channel containing the fast fourier transformation", DEFAULT_OUTPUT_NAME); blc_program_add_option(&period_str, 'p', "period", "integer", "Period between each sample in ms (0 as fast as possible)", "0"); - blc_program_add_option(&length_str, 's', "size", "integer", "Sample size", "1024"); + blc_program_add_option(&length_str, 's', "size", "integer", "Sample size", "4096"); blc_program_add_option(&samplerate_str, 'S', "samplerate", "integer", "frequency of sampling", "44100"); blc_program_add_option(&type_str, 't', "type", "INT8|FL32", "Type of the data.", "FL32"); - blc_program_init(&argc, &argv, NULL); + blc_program_init(&argc, &argv, blc_quit); SSCANF(1, samplerate_str, "%d", &samplerate); @@ -52,7 +52,7 @@ int main(int argc, char**argv){ BLC_COMMAND_LOOP(period*1000){ read_items_nb=sf_read_float(sndfile, output.floats, output.total_length); if (read_items_nb!=output.total_length) { - color_eprintf(BLC_YELLOW, "%s: Iteration %d: Missing data. Read '%d' items instead of '%d'. It is probably the end of the file\n", blc_program_name, blc_loop_iteration, read_items_nb, output.total_length); + color_eprintf(BLC_YELLOW, "%s: Iteration %d: Missing data. Read '%lld' items instead of '%ld'. It is probably the end of the file\n", blc_program_name, blc_loop_iteration, read_items_nb, output.total_length); blc_command_ask_quit(); break; } diff --git a/o_sndfile/o_sndfile.cpp b/o_sndfile/o_sndfile.cpp index dcdfa74..f1053c0 100644 --- a/o_sndfile/o_sndfile.cpp +++ b/o_sndfile/o_sndfile.cpp @@ -6,19 +6,21 @@ int main(int argc, char**argv){ blc_channel input; - char const *filename, *input_name, *samplerate_str; + char const *filename, *input_name, *samplerate_str, *output_length_str; SF_INFO sfinfo; SNDFILE *sndfile; sf_count_t write_items_nb; - int samplerate; + int samplerate, length; blc_program_set_description("Load a sound file (no mp3) and put the result in the blc_channel"); blc_program_add_option(&filename, 'f', "file", "string", "filename of the file to write", NULL); + blc_program_add_option(&output_length_str, 's', "size", "integer", "items nb in buffer", "4096"); blc_program_add_option(&samplerate_str, 'S', "samplerate", "integer", "frequency of sampling", "44100"); blc_program_add_parameter(&input_name, "blc_channel-in", 1, "blc channel containing the sound", NULL); - blc_program_init(&argc, &argv, NULL); + blc_program_init(&argc, &argv, blc_quit); SSCANF(1, samplerate_str, "%d", &samplerate); + SSCANF(1, output_length_str, "%d", &length); if (filename==NULL) { blc_program_args_display_help(); @@ -26,8 +28,6 @@ int main(int argc, char**argv){ exit(1); } - if (strcmp(blc_get_filename_extension(filename), "wav")!=0) EXIT_ON_ERROR("Only '.wav' extention is managed but your extension is '.%s'", blc_get_filename_extension(filename)); - input.open(input_name, BLC_CHANNEL_READ); CLEAR(sfinfo); -- GitLab