From
|
jaromil <jaromil@kyuzz.org>
|
Date
|
Sat, 24 Aug 2002 14:56:20 +0200
|
Subject
|
Re: [HaCkmEeTiNg] maybe utile 4 mediattivisti con portatili in giro, anal mode on, siege hill
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, Aug 23, 2002 at 05:43:44PM +0200, jaromil wrote:
> piuttosto di muse pensavo di usare un programmillo in c piu' piccolo,
> che utilizza solo parte dei codici di muse
intanto oggi ho scritto questo, che e' un vumeter su commandline, prende
da stdin e sputa in stdout, ottimo da usare per dei pipe
mo tra un po' ci metto anche qualche opzioncina e un gestore dei segnali
per un quit piu' decente al ctrl-c
ecco il codice
(lo posto qui dai, tanto e' anche piu' leggero dello spam che ci passa
di solito)
=== vumeter.c = cut-here ===
/* commandline VUMETER
* Copyright (C) 2002 Denis Rojo aka jaromil <jaromil@dyne.org>
*
* This source code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please refer to the GNU Public License for more details.
*
* You should have received a copy of the GNU Public License along with
* this source code; if not, write to:
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
* to compile:
* gcc -o vumeter vumeter.c
*
* this sucks from stdin and spits in stdout
*/
#include <stdio.h>
#define CHUNK_SIZE 16192
#define SCR_WIDTH 80
#define BAR_WIDTH (SCR_WIDTH-10)
static short buf[CHUNK_SIZE];
int main(int argc, char **argv) {
int c,cc, cpeak, readed = 0;
long peak[8];
unsigned long vumeter = 0, vubarsize = 0;
int vupercent = 0;
char *p,vubar[SCR_WIDTH];
while(!feof(stdin)) {
readed = fread(buf,1,CHUNK_SIZE,stdin);
if(ferror(stdin))
perror("error reading from STDIN: ");
peak[0] = 0; peak[1] = 0; peak[2] = 0; peak[3] = 0;
peak[4] = 0; peak[5] = 0; peak[6] = 0; peak[7] = 0;
for(cpeak=0;cpeak<8;cpeak++) {
cc = (CHUNK_SIZE>>3)*cpeak;
for(c=0;c<CHUNK_SIZE>>3;c++)
if (buf[cc+c]>peak[cpeak]) peak[cpeak] = buf[cc+c];
}
vumeter = (peak[0]+peak[1]+peak[2]+peak[3]+
peak[4]+peak[5]+peak[6]+peak[7])>>3;
vumeter = (vumeter<0)?0:vumeter;
/* MAX_vumeter : width = vumeter : vubarsize
qualcuno ha un poster di euclide da regalarmi? */
vubarsize = (BAR_WIDTH*vumeter)>>14; // (/16383);
p = vubar; for(c=0;c<vubarsize;c++,p++) *p='#'; *p='\0';
vupercent = ((vumeter*100)>>14)+1;
fprintf(stderr,"\rVOL [%-69s] %3i%%\r\0",vubar,vupercent);
fwrite(buf,1,readed,stdout);
}
exit(1);
}
=== cut-here ===
corto eh ? :D
- --
jaromil ][ http://dyne.org ][ GnuPG _key__id_
EDEE F1B9 DC92 76C0 6D46 D77A 58B0 82D6 (5B6E 6D97)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9Z4J0WLCC1ltubZcRAiMZAJ9o+Kl+/r7Otgb1yUnlg0smpmxgTACgnRu6
wWKx68MHYdghrdJ+ELJ1fVo=
=iseB
-----END PGP SIGNATURE-----
---
To unsubscribe from this list: send the line "unsubscribe hackmeeting" in
the body of a message to majordomo@kyuzz.org