Commit d6155ce2ca1d0e128f7e111d4f1b82f3342efe1a
Merge branch 'master' of https://promethe.u-cergy.fr/blaar/bapps
Showing
2 changed files
with
91 additions
and
21 deletions
README.md
0 → 100644
1 | +Set of programs to manipulate data in blc_channels. They do not have any lib dependency. | ||
2 | + | ||
3 | +Acquire input values | ||
4 | +==================== | ||
5 | + | ||
6 | +from files | ||
7 | +---------- | ||
8 | + | ||
9 | +`i_fread <filename.tsv>` reads a line of data from the file in tsv (i.e. '0.3 0.55 0.56 ' is a vector of 3 values) and creates a channel (a vector) containing these data. | ||
10 | +If there are many lines, it updates the data as fast as possible with each time. | ||
11 | +It is very fast you can be either be synchronized or using **-p** to requiert a minimal time between each update. | ||
12 | +You can also use a first column describing the time in µs to read the line. | ||
13 | +Finaly you can limit the number of line read by using -n. | ||
14 | + | ||
15 | +To load sound or images, see [i_sndfile](http://blaar.org/../sndfile) and [i_pngfile](http://blaar.org/../png) | ||
16 | + | ||
17 | +from keyboard | ||
18 | +------------- | ||
19 | + | ||
20 | +`i_keyboard` changes values with the keyboard arrows or specific keys: | ||
21 | + | ||
22 | + Waiting for one key in '0123456789abcdef'. Quitting with 'q' | ||
23 | + /i_keyboard31058 | ||
24 | + | ||
25 | +This means that a channel (/i_keyboard31058) of 16 ( by default there is 16 characters in the string) 'UIN8' has been created. | ||
26 | +Press Up and Down to increase or decrease the first value. Use Right and Left or one key of the key list to select another value to change. | ||
27 | +`Esc` sets the value back to neutral values (default 50% i.e. 127) | ||
28 | + | ||
29 | +i_keyboard has many options (use `i_keyboard -h` to list them) we illustrate some: | ||
30 | + | ||
31 | + i_keyboard -d -tFL32 -k abcd -o/toto | ||
32 | + | ||
33 | +Creates a channel '/toto' of 4 float values between 0 and 1 and display the pourcentage in text mode. | ||
34 | + | ||
35 | + 100%(1.00) [/toto] | | ||
36 | + ^ | ||
37 | + | 49 49 49 49 | ||
38 | + | [] [] [] [] | ||
39 | + 0%(0.000) > | ||
40 | + >|#a| b| c| d| | ||
41 | + | ||
42 | +We see the initial values are set to 49% (i.e. 0.5) and we can chenge them with the arrow. | ||
43 | +You could change the initial value by changing the neutral value (-N). | ||
44 | +You can change the min and max with -m and -M. The default step of one keypressed in 0.004 (~1/256) or 1 with UIN8 type. | ||
45 | +It can be changed with -S. | ||
46 | + | ||
47 | +Sometime you do not want intermediate values but only toggle to max and min. Then use -T. | ||
48 | + | ||
49 | +from oscillator | ||
50 | +--------------- | ||
51 | + | ||
52 | +`i_oscillator -o/toto` generates sinusoidale oscillations and put it in the channel /toto. | ||
53 | +You can specify the frequency with -f and the refresh rate with -r. | ||
54 | +The refresh rate defines how often you will update the value of the oscillator but will not change the frequency. | ||
55 | + | ||
56 | +You can use a buffer to keep the historic of the oscillation. | ||
57 | + | ||
58 | + | ||
59 | +Generate outputs | ||
60 | +================ | ||
61 | + | ||
62 | +to a file | ||
63 | +--------- | ||
64 | + | ||
65 | +`o_fread <channel> -f <filename.tsv>` create a tsv file with the data of the channel. The options are symetrical with i_fread. | ||
66 | + | ||
67 | +To save sounds or images see [o_sndfile](http://blaar.org/../sndfile] and [o_pngfile](http://blaar.org/../png] | ||
68 | + | ||
69 | + | ||
70 | + |
@@ -7,36 +7,36 @@ | @@ -7,36 +7,36 @@ | ||
7 | #include <unistd.h> | 7 | #include <unistd.h> |
8 | 8 | ||
9 | int main(int argc, char **argv){ | 9 | int main(int argc, char **argv){ |
10 | - blc_channel input, output1, output2; | ||
11 | - char const *output_name1, *output_name2, *input_name; | 10 | + blc_channel input, output1, output2; |
11 | + char const *output_name1, *output_name2, *input_name; | ||
12 | 12 | ||
13 | - blc_program_set_description("Duplicate a channel"); | ||
14 | - blc_program_add_parameter(&input_name, "blc_channel-in", 1, "input channel to split", NULL); | ||
15 | - blc_program_add_parameter(&output_name1, "blc_channel-out", 1, "first copy of input", NULL); | ||
16 | - blc_program_add_parameter(&output_name2, "blc_channel-out", 1, "second_copy of input", NULL); | 13 | + blc_program_set_description("Duplicate a channel"); |
14 | + blc_program_add_option(&output_name1,'1', "output1", "blc_channel-out", "first copy of input", NULL); | ||
15 | + blc_program_add_option(&output_name2, '2', "output2", "blc_channel-out", "second_copy of input", NULL); | ||
16 | + blc_program_add_parameter(&input_name, "blc_channel-in", 1, "input channel to split", NULL); | ||
17 | 17 | ||
18 | blc_program_init(&argc, &argv, blc_quit); | 18 | blc_program_init(&argc, &argv, blc_quit); |
19 | 19 | ||
20 | - input.open(input_name, BLC_CHANNEL_READ); | ||
21 | - blc_loop_try_add_waiting_semaphore(input.sem_new_data); | ||
22 | - blc_loop_try_add_posting_semaphore(input.sem_ack_data); | 20 | + if (output_name1==NULL) EXIT_ON_ERROR("You need option -1 <name of output channel>"); |
21 | + if (output_name2==NULL) EXIT_ON_ERROR("You need option -2 <name of output channel>"); | ||
23 | 22 | ||
23 | + input.open(input_name, BLC_CHANNEL_READ); | ||
24 | + blc_loop_try_add_waiting_semaphore(input.sem_new_data); | ||
25 | + blc_loop_try_add_posting_semaphore(input.sem_ack_data); | ||
24 | 26 | ||
27 | + | ||
25 | output1.create_or_open(output_name1, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims); | 28 | output1.create_or_open(output_name1, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims); |
26 | - | ||
27 | output2.create_or_open(output_name2, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims); | 29 | output2.create_or_open(output_name2, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims); |
28 | 30 | ||
29 | 31 | ||
30 | - BLC_COMMAND_LOOP(0){ | ||
31 | - if (output1.sem_ack_data) sem_wait(output1.sem_ack_data); | ||
32 | - memcpy(output1.data, input.data, output1.size); | ||
33 | - if (output1.sem_new_data) sem_post(output1.sem_new_data); | ||
34 | - | ||
35 | - | ||
36 | - if (output2.sem_ack_data) sem_wait(output2.sem_ack_data); | ||
37 | - memcpy(output2.data, input.data, output2.size); | ||
38 | - if (output2.sem_new_data) sem_post(output2.sem_new_data); | ||
39 | - | 32 | + BLC_COMMAND_LOOP(0){ |
33 | + if (output1.sem_ack_data) sem_wait(output1.sem_ack_data); | ||
34 | + memcpy(output1.data, input.data, output1.size); | ||
35 | + if (output1.sem_new_data) sem_post(output1.sem_new_data); | ||
36 | + | ||
37 | + if (output2.sem_ack_data) sem_wait(output2.sem_ack_data); | ||
38 | + memcpy(output2.data, input.data, output2.size); | ||
39 | + if (output2.sem_new_data) sem_post(output2.sem_new_data); | ||
40 | } | 40 | } |
41 | - return EXIT_SUCCESS; | 41 | + return EXIT_SUCCESS; |
42 | } | 42 | } |
-
Please register or login to post a comment