#!/bin/rc # compile and play a bytebeat from a file rfork e tmp = tempbytebeat^$pid o = `{sed -n 's/O=//p' /$objtype/mkfile} fn usage{ rm -f $tmp.c echo usage: $0 [file1] [file2] >[1=2] exit usage } fn sighup sigint sigterm{ rm -f $o.out $tmp.c $tmp.$o exit interrupted } > $tmp.c { echo '#include #include uint t; uchar l(void){' switch($#*){ case 0 cat || usage echo '} uchar r(void){return l();' case 1 cat $1 || usage echo '} uchar r(void){return l();' case 2 cat $1 || usage echo '} uchar r(void){' cat $2 || usage case * usage } echo '} void main(void) { uchar buf[1024], left, right; int i; for(;;){ for(i = 0; i < sizeof(buf); t++){ left = l() >> 1; right = r() >> 1; buf[i++] = left + (right >> 1); buf[i++] = right + (left >> 1); } if(write(1, buf, sizeof(buf)) != sizeof(buf)) break; } }' } $o^c $tmp.c && $o^l $tmp.$o || sigint $o.out | audio/pcmconv -iu8c2r8000 > /dev/audio