commit db70dcf1b428b42e66c6c9f07d72fa52693cc51a
parent 446ab7facd925af94cf8709c7c0ad17f21c83d38
Author: zavok <an2qzavok@gmail.com>
Date: Wed, 27 Mar 2019 12:38:27 +0300
int types
Diffstat:
2 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
@@ -1,17 +1,7 @@
Pcmprint, as the name suggests, prints PCM data to stdout in what
could be considered human-readable form.
-Input data is assumed to be in "CD-Audio" format, i.e signed 16-bit
-integer, little-endian, stereo, 44100 samplerate.
-
-You can use it, for example, for live view of music wavform:
-
-* with sndio:
- tee /dev/audio0 < music.pcm | pcmprint
-* with aplay:
- mkfifo /tmp/fifo
- (tee /tmp/fifo < music.pcm | pcmrpint)&
- aplay -f cd < /tmp/fifo
+See man page for more info.
Features considered and rejected:
---------------------------------
diff --git a/pcmprint.c b/pcmprint.c
@@ -4,8 +4,8 @@
#include <string.h>
#include <fcntl.h>
-static int BLKSIZE = 1024;
-static int CHLEN = 35;
+static size_t BLKSIZE = 1024;
+static int32_t CHLEN = 35;
char *intens = "`@";
static void
@@ -15,15 +15,16 @@ usage(char *cmd)
exit(-1);
}
-static int
-norm(int v){
+static int32_t
+norm(int32_t v){
return (CHLEN + CHLEN * v / 0x7fff) / 2;
}
static void
-drawch(int min, int max)
+drawch(int32_t min, int32_t max)
{
- int i, Min, Max;
+ size_t i;
+ int32_t Min, Max;
Min = norm(min);
Max = norm(max);
for (i = 0; i < CHLEN; i++)
@@ -34,7 +35,7 @@ drawch(int min, int max)
static ulong
readblk(int f, int16_t *blk)
{
- ulong n, m;
+ size_t n, m;
m = 0;
while(m!=BLKSIZE){
n = read(f, &blk[m/2], BLKSIZE-m);
@@ -48,9 +49,10 @@ int
main(int argc, char **argv)
{
char buf[11];
- ulong i, n, m, l, s;
+ int ch;
+ size_t i, n, m, l, s;
int16_t *blk;
- int ch, f, lmin, lmax, rmin,rmax;
+ int32_t f, lmin, lmax, rmin,rmax;
f = 0;
while ((ch = getopt(argc, argv, "b:w:")) != -1){
switch (ch){