choupification

This commit is contained in:
tth 2021-04-15 22:36:00 +02:00
parent 054715a960
commit 918e29cb98
10 changed files with 83 additions and 26 deletions

View File

@ -1,3 +1,10 @@
#
# _ _ ____ _ _ _ ____ _____ _____ ____
# / \ ! ! / ___! ! ! ! / \ ! __ )! ____! ____! _ \
# / _ \ ! ! ! ! _! ! ! !/ _ \ ! _ \! _! ! _! ! !_) !
# / ___ \! !__! !_! ! !_! / ___ \! !_) ! !___! !___! __/
# /_/ \_\_____\____!\___/_/ \_\____/!_____!_____!_!
#
CC = gcc

View File

@ -1,11 +1,22 @@
# AlguaBeep
Une expérimentation hasardeuse pour traduire des images de webcam
en sons qui déchirent les oreilles, mais qui sont bio-dégradables.
C'est une expérimentation hasardeuse pour traduire des images de webcam
en sons qui déchirent les oreilles, mais qui sont relativement
inoffensifs.
Pour le moment, il n'y a pas de procédure d'installation, il faut
donc lancer le binaire à partir du répertoire de dèv :
`~/Devel/DD2-monitor/Beep/alguabeep [options]`, ce qui implique
de ne pas aller mettre la grouille dans ce coin-là.
Ensuite, pour apprécier pleinement la kitchitude (assumée) de l'affichage
numérique de la machinerie en action, il faut un `xterm` en 150 caractères
de large, et une toute petite fonte.
## Usage
```
available options:
-d /dev/? select video device
-I take pictures
-K set the K parameter

View File

@ -1,4 +1,10 @@
/* V4L2 video picture grabber
/*
A crude sound experiment, by Clairchanoir et tTh
approimatively based on :
V4L2 video picture grabber
Copyright (C) 2009 Mauro Carvalho Chehab <mchehab@infradead.org>
This program is free software; you can redistribute it and/or modify
@ -58,14 +64,14 @@ do {
} while (r == -1 && ((errno == EINTR) || (errno == EAGAIN)));
if (r == -1) {
fprintf(stderr, "error %d, %s\n", errno, strerror(errno));
fprintf(stderr, "%s: error %d, %s\n", __func__, errno, strerror(errno));
exit(EXIT_FAILURE);
}
}
/* --------------------------------------------------------------------- */
void help(int v)
{
puts("options :");
puts("available options:");
puts("\t-d /dev/?\tselect video device");
puts("\t-I\t\ttake pictures");
puts("\t-K\t\tset the K parameter");
@ -200,7 +206,7 @@ initialise_ecran(0);
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
xioctl(fd, VIDIOC_STREAMON, &type);
sprintf(chaine, "entering main loop, %d iters\n", nbre_capt);
sprintf(chaine, "entering main loop, %9d iters\n", nbre_capt);
mvaddstr(1, 0, chaine);
refresh();
fprintf(stderr, "%s\n", chaine);
@ -243,8 +249,8 @@ for (i = 0; i < nbre_capt; i++) {
// fmt.fmt.pix.width, fmt.fmt.pix.height, K);
if (mk_img) {
sprintf(out_name, "i/out%04d.ppm", i);
if (verbosity) fprintf(stderr, "--> %s\n", out_name);
sprintf(out_name, "o/out%04d.ppm", i);
if (verbosity) fprintf(stderr, "\t--> %s\n", out_name);
fout = fopen(out_name, "w");
if (!fout) {
@ -257,6 +263,10 @@ for (i = 0; i < nbre_capt; i++) {
fclose(fout);
}
/* XXX CRITICAL BUG XXX
Doc say 'period can be real', so why not
use nanosleep(2) ?
*/
if (nbre_capt > 1 && period) {
sleep(period);
}

View File

@ -1,4 +1,10 @@
/*
* Ugly hack made for AlguaBeep
*
* +++++++++++++++++++++++++++++++++++++++++
* + DO NOT USE IN REAL LIFE +
* +++++++++++++++++++++++++++++++++++++++++
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -27,10 +33,10 @@ if (-1 == ioctl (fd, VIDIOC_QUERYCTRL, &queryctrl)) {
perror ("VIDIOC_QUERYCTRL");
exit (EXIT_FAILURE);
} else {
printf ("V4L2_CID_BRIGHTNESS is not supported\n");
fprintf (stderr, "V4L2_CID_BRIGHTNESS is not supported\n");
}
} else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
printf ("V4L2_CID_BRIGHTNESS is not supported\n");
fprintf (stderr, "V4L2_CID_BRIGHTNESS is not supported\n");
} else {
memset (&control, 0, sizeof (control));
control.id = V4L2_CID_BRIGHTNESS;

View File

@ -1,3 +1,8 @@
/*
* AlguaBeep is a cool project.
* merci clairchanoir.
*/
/*
* various V4L2 functions
*/

View File

@ -1,3 +1,6 @@
/*
* un module 'curses' de AlguaBeep
*/
#include <stdio.h>
#include <unistd.h>
@ -18,7 +21,7 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */
atexit(finish);
sprintf(chaine, " alguabeep (%s %s) pid=%d \n", __DATE__, __TIME__,
sprintf(chaine, " AlguaBeep (%s %s) pid=%d \n", __DATE__, __TIME__,
getpid());
standout(); mvaddstr(0, 0, chaine); standend();

View File

@ -1,5 +1,9 @@
/*
* algua beep module
*
* il faut etre honnete, mais ce module m'interpelle, parce
* ce que je ne comprend plus l'intention premiere.
*
*/
#include <stdio.h>

View File

@ -1,5 +1,7 @@
/* --------------------------------------------------------------------- */
/*
* did you'v got funk with this funcs.h file ?
*/
typedef struct {
int x, y, w, h;
} Rect;

View File

@ -28,6 +28,9 @@ static ao_sample_format format;
static double debut;
/* --------------------------------------------------------------------- */
/*
* what is the meaning of the 'K' parameter ?
*/
int init_process(int K)
{
// int foo;
@ -50,7 +53,7 @@ format.rate = 44100;
format.byte_format = AO_FMT_LITTLE;
device = ao_open_live(default_driver, &format, NULL);
if (device == NULL) {
fprintf(stderr, "Error opening AO device.\n");
fprintf(stderr, "%s: Error opening AO device.\n", __func__);
return -1;
}
@ -69,8 +72,8 @@ typedef struct {
static int cmp_datums(const void *a, const void *b)
{
Datum *pa = (Datum *)a;
Datum *pb = (Datum *)b;
Datum *pa = (Datum *)a; /* nice */
Datum *pb = (Datum *)b; /* code */
return pa->v < pb->v;
}
@ -95,7 +98,7 @@ return 30.0* (1.0 / (double)i); /* please explain */
static int generate_samples(short *where, int size, Datum *datas)
{
int loop;
short value;
short svalue;
double vol;
char chaine[100];
@ -108,24 +111,26 @@ for (loop=0; loop<size; loop++) {
/* LEFT */
vol = 10000.0 * pow(datas[0].v / 256.0, 2.0);
value = (short)(sin((double)loop*i2freq(datas[0].y)) * vol);
*where++ = value;
svalue = (short)(sin((double)loop*i2freq(datas[0].y)) * vol);
*where++ = svalue;
/* RIGHT */
vol = 10000.0 * pow(datas[1].v / 256.0, 2.0);
value = (short)(sin((double)loop*i2freq(datas[1].y)) * vol);
*where++ = value;
svalue = (short)(sin((double)loop*i2freq(datas[1].y)) * vol);
*where++ = svalue;
}
sprintf(chaine, "sample %6.3f = %7d", vol, value);
sprintf(chaine, "sample %6.3f = %7d", vol, svalue);
mvaddstr(35, 0, chaine);
return 0;
}
/* --------------------------------------------------------------------- */
/*
* PLEASE EXPLAIN !
*/
int charcuteur(unsigned char *datas, int w, int h, int K)
{
@ -166,7 +171,7 @@ for (bigR=0; bigR<nbR; bigR++) {
mvaddstr(SL+1+bigR*DL, SC+bigC*DC, chaine);
idx++;
#if DEBUG_LEVEL
fprintf(stderr, "%s %6d %6d %6d\n", __func__, bigR, bigC, idx);
fprintf(stderr, "%s: %6d %6d %6d\n", __func__, bigR, bigC, idx);
#endif
}
}
@ -176,7 +181,7 @@ qsort(vals, nbR*nbC, sizeof(Datum), cmp_datums);
for (idx=0; idx<16; idx++) {
sprintf(chaine, "%2d %2d %6.2f", vals[idx].x, vals[idx].y,
vals[idx].v);
mvaddstr(5+idx, 130, chaine);
mvaddstr(5+idx, 130, chaine); /* XXX why 130 ? */
}
/* *** sound generator ***/

View File

@ -1,3 +1,7 @@
/*
* AlguaBeep is a cool project.
* merci clairchanoir.
*/
double dtime(void);