pcmprint

CLI PCM visualiser
git clone git://nsmpr.xyz/pcmprint.git
Log | Files | Refs | README

commit 446ab7facd925af94cf8709c7c0ad17f21c83d38
parent a19f169d6b1c49377b6d61bcad47440d72e886a6
Author: zavok <an2qzavok@gmail.com>
Date:   Fri, 22 Mar 2019 00:05:56 +0300

work on man page

Diffstat:
Apcmprint.1 | 45+++++++++++++++++++++++++++++++++++++++++++++
Mpcmprint.c | 8++++----
Dpcmprint.mdoc | 20--------------------
3 files changed, 49 insertions(+), 24 deletions(-)

diff --git a/pcmprint.1 b/pcmprint.1 @@ -0,0 +1,45 @@ +.Dd $Mdocdate: March 20 2019 $ +.Dt PCMPRINT 1 +.Os +.Sh NAME +.Nm pcmprint +.Nd prints PCM data into stdout +.Sh SYNOPSIS +.Nm pcmprint +.Op Fl b Ar blocksize +.Op Fl w Ar width +.Op Ar file +.Sh DESCRIPTION +.Nm +reads input (either stdin or file, if specified) and prints to stdout lines visualising the signal. +Input data is assumed to be RAW PCM, signed, 16-bit, little-endian, stereo, with sampling rate of 44100 Hz. +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl b Ar blocksize +specifies size of the sample block to operate on. +Size of the block is assumed to be in sampling frames, 4 bytes per frame. +Default value is 1024. +.It Fl v Ar width +specifies width of the printed channel on the output. +Default value is 35 characters, which with 2 channels and hardcoded 10 characters of separation fits nicely into standard 80-columns terminal. +.Sh EXIT STATUS +.Ex -std pcmprint +.Sh EXAMPLES +Use +.Nm +together with +.Xr tee 1 +to look at audio shape while it's playing: + +for +.Xr sndio 7 : +.Bd -literal -offset indent +$ tee /dev/audio0 < music.raw | pcmprint +.Ed + +for alsa: +.Bd -literal -offset indent +$ mkfifo /tmp/fifo +$ (tee /tmp/fifo < music.raw | pcmprint) & +$ aplay -f cd < /tmp/fifo +.Ed diff --git a/pcmprint.c b/pcmprint.c @@ -5,7 +5,7 @@ #include <fcntl.h> static int BLKSIZE = 1024; -static int CHLEN = 33; +static int CHLEN = 35; char *intens = "`@"; static void @@ -58,14 +58,14 @@ main(int argc, char **argv) BLKSIZE = atoi(optarg); if (BLKSIZE <= 0){ dprintf(2, "Error: -b too small: %d\n", BLKSIZE); - exit(-1); + exit(1); } break; case 'w': CHLEN = atoi(optarg); if (CHLEN <= 0){ dprintf(2, "Error: -w too small: %d\n", CHLEN); - exit(-1); + exit(1); } break; default: @@ -77,7 +77,7 @@ main(int argc, char **argv) f = open(argv[optind], O_RDONLY); if (f == -1) { dprintf(2, "Error: can't open %s\n", argv[optind]); - exit(-1); + exit(1); } } BLKSIZE = BLKSIZE * 4; /*2 channels x 2 bytes*/ diff --git a/pcmprint.mdoc b/pcmprint.mdoc @@ -1,20 +0,0 @@ -.Dd $Mdocdate: March 20 2019 $ -.Dt PCMPRINT 1 -.Os -.Sh NAME -.Nm pcmprint -.Nd prints PCM data into stdout -.Sh SYNOPSIS -.Nm pcmprint -.Op Fl b Ar blocksize -.Op Fl w Ar width -.Op Ar file -.Sh DESCRIPTION -.Nm -reads input (either stdin or file, if specified) and prints to stdout lines visualising the signal. -Input data is assumed to be RAW PCM, signed, 16-bit, little-endian, stereo, with sampling rate of 44100 Hz. -.Sh OPTIONS -.Bl -tag -width Ds -.It Fl b Ar blocksize -specifies size of the block to operate on. -Size of the block is assumed to be in sampling frames, 4 bytes per frame.