Commit d6155ce2 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Merge branch 'master' of https://promethe.u-cergy.fr/blaar/bapps

parents bad0e06a 7b2d6196
Set of programs to manipulate data in blc_channels. They do not have any lib dependency.
Acquire input values
====================
from files
----------
`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.
If there are many lines, it updates the data as fast as possible with each time.
It is very fast you can be either be synchronized or using **-p** to requiert a minimal time between each update.
You can also use a first column describing the time in µs to read the line.
Finaly you can limit the number of line read by using -n.
To load sound or images, see [i_sndfile](http://blaar.org/../sndfile) and [i_pngfile](http://blaar.org/../png)
from keyboard
-------------
`i_keyboard` changes values with the keyboard arrows or specific keys:
Waiting for one key in '0123456789abcdef'. Quitting with 'q'
/i_keyboard31058
This means that a channel (/i_keyboard31058) of 16 ( by default there is 16 characters in the string) 'UIN8' has been created.
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.
`Esc` sets the value back to neutral values (default 50% i.e. 127)
i_keyboard has many options (use `i_keyboard -h` to list them) we illustrate some:
i_keyboard -d -tFL32 -k abcd -o/toto
Creates a channel '/toto' of 4 float values between 0 and 1 and display the pourcentage in text mode.
100%(1.00) [/toto] |
^
| 49 49 49 49
| [] [] [] []
0%(0.000) >
>|#a| b| c| d|
We see the initial values are set to 49% (i.e. 0.5) and we can chenge them with the arrow.
You could change the initial value by changing the neutral value (-N).
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.
It can be changed with -S.
Sometime you do not want intermediate values but only toggle to max and min. Then use -T.
from oscillator
---------------
`i_oscillator -o/toto` generates sinusoidale oscillations and put it in the channel /toto.
You can specify the frequency with -f and the refresh rate with -r.
The refresh rate defines how often you will update the value of the oscillator but will not change the frequency.
You can use a buffer to keep the historic of the oscillation.
Generate outputs
================
to a file
---------
`o_fread <channel> -f <filename.tsv>` create a tsv file with the data of the channel. The options are symetrical with i_fread.
To save sounds or images see [o_sndfile](http://blaar.org/../sndfile] and [o_pngfile](http://blaar.org/../png]
\ No newline at end of file
......@@ -7,36 +7,36 @@
#include <unistd.h>
int main(int argc, char **argv){
blc_channel input, output1, output2;
char const *output_name1, *output_name2, *input_name;
blc_channel input, output1, output2;
char const *output_name1, *output_name2, *input_name;
blc_program_set_description("Duplicate a channel");
blc_program_add_parameter(&input_name, "blc_channel-in", 1, "input channel to split", NULL);
blc_program_add_parameter(&output_name1, "blc_channel-out", 1, "first copy of input", NULL);
blc_program_add_parameter(&output_name2, "blc_channel-out", 1, "second_copy of input", NULL);
blc_program_set_description("Duplicate a channel");
blc_program_add_option(&output_name1,'1', "output1", "blc_channel-out", "first copy of input", NULL);
blc_program_add_option(&output_name2, '2', "output2", "blc_channel-out", "second_copy of input", NULL);
blc_program_add_parameter(&input_name, "blc_channel-in", 1, "input channel to split", NULL);
blc_program_init(&argc, &argv, blc_quit);
input.open(input_name, BLC_CHANNEL_READ);
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
if (output_name1==NULL) EXIT_ON_ERROR("You need option -1 <name of output channel>");
if (output_name2==NULL) EXIT_ON_ERROR("You need option -2 <name of output channel>");
input.open(input_name, BLC_CHANNEL_READ);
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
output1.create_or_open(output_name1, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims);
output2.create_or_open(output_name2, BLC_CHANNEL_WRITE, input.type, input.format, input.dims_nb, input.dims);
BLC_COMMAND_LOOP(0){
if (output1.sem_ack_data) sem_wait(output1.sem_ack_data);
memcpy(output1.data, input.data, output1.size);
if (output1.sem_new_data) sem_post(output1.sem_new_data);
if (output2.sem_ack_data) sem_wait(output2.sem_ack_data);
memcpy(output2.data, input.data, output2.size);
if (output2.sem_new_data) sem_post(output2.sem_new_data);
BLC_COMMAND_LOOP(0){
if (output1.sem_ack_data) sem_wait(output1.sem_ack_data);
memcpy(output1.data, input.data, output1.size);
if (output1.sem_new_data) sem_post(output1.sem_new_data);
if (output2.sem_ack_data) sem_wait(output2.sem_ack_data);
memcpy(output2.data, input.data, output2.size);
if (output2.sem_new_data) sem_post(output2.sem_new_data);
}
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment