SST - SPARCstation Sound Tools - part 2 of 2

Jef Poskanzer jef at well.UUCP
Tue Nov 21 20:03:40 AEST 1989


#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	speed.c
#	speed.1
#	ulawtolin.c
#	ulawtolin.1
#	volume.c
#	volume.1
#	vox.c
#	vox.1
#	dial.c
#	dial.1
#	listen.c
#	listen.1
#	play.c
#	play.1
#	record.c
#	record.1
#	tones.c
#	tones.1
# This archive created: Mon Nov 20 22:01:24 1989
# By:	Jef Poskanzer (Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal)
export PATH; PATH=/bin:$PATH
echo shar: extracting "'speed.c'" '(1865 characters)'
if test -f 'speed.c'
then
	echo shar: will not over-write existing file "'speed.c'"
else
sed 's/^X//' << \SHAR_EOF > 'speed.c'
X/* speed.c - change the speed of a sound file
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include "libst.h"
X
X#define MYBUFSIZ 256
X#define SCALE 4096
X#define HALFSCALE 2048
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *f;
X    char mybuf[MYBUFSIZ];
X    float scale;
X    register long sscale, fractofill, fracleft, sc;
X    double atof();
X    int c, lc;
X
X    if ( argc < 2 || argc > 3 )
X	{
X	fprintf( stderr, "usage:  %s <factor> [<file>]\n", argv[0] );
X	exit( 1 );
X	}
X
X    scale = atof( argv[1] );
X    if ( scale == 0.0 )
X	{
X	fprintf( stderr, "%s: scale factor required\n", argv[0] );
X	exit( 1 );
X	}
X    scale = 1.0 / scale;
X    sscale = scale * SCALE;
X
X    if ( argc == 2 )
X	f = stdin;
X    else if ( argc == 3 )
X	{
X	f = fopen( argv[2], "r" );
X	if ( f == NULL )
X	    {
X	    perror( argv[2] );
X	    exit( 1 );
X	    }
X	}
X    setbuffer( stdout, mybuf, MYBUFSIZ );
X
X    fractofill = SCALE;
X    sc = HALFSCALE;
X    while ( (c = getc( f )) != EOF )
X	{
X	lc = st_ulaw_to_linear( c );
X	fracleft = sscale;
X	while ( fracleft >= fractofill )
X	    {
X	    sc += fractofill * lc;
X	    sc /= SCALE;
X	    LINCLIP( sc );
X	    putchar( st_linear_to_ulaw( sc ) );
X	    fracleft -= fractofill;
X	    fractofill = SCALE;
X	    }
X	if ( fracleft > 0 )
X	    {
X	    sc += fracleft * lc;
X	    fractofill -= fracleft;
X	    }
X	}
X    if ( fractofill > 0 )
X	{
X	sc += fractofill * lc;
X	sc /= SCALE;
X	LINCLIP( sc );
X	putchar( st_linear_to_ulaw( sc ) );
X	}
X
X    exit( 0 );
X    }
SHAR_EOF
if test 1865 -ne "`wc -c < 'speed.c'`"
then
	echo shar: error transmitting "'speed.c'" '(should have been 1865 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'speed.1'" '(648 characters)'
if test -f 'speed.1'
then
	echo shar: will not over-write existing file "'speed.1'"
else
sed 's/^X//' << \SHAR_EOF > 'speed.1'
X.TH speed 1 "20 November 1989"
X.SH NAME
Xspeed - change the speed of a sound file
X.SH SYNOPSIS
Xspeed <factor> [<file>]
X.SH DESCRIPTION
XSpeeds up or slows down a sound file by the specified factor.
X.SH "SEE ALSO"
Xpitch(1), volume(1)
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 648 -ne "`wc -c < 'speed.1'`"
then
	echo shar: error transmitting "'speed.1'" '(should have been 648 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'ulawtolin.c'" '(977 characters)'
if test -f 'ulawtolin.c'
then
	echo shar: will not over-write existing file "'ulawtolin.c'"
else
sed 's/^X//' << \SHAR_EOF > 'ulawtolin.c'
X/* ulawtolin.c - convert ulaw to linear
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include "libst.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *f;
X    double atof();
X    int c, lc;
X
X    if ( argc == 1 )
X	f = stdin;
X    else if ( argc == 2 )
X	{
X	f = fopen( argv[1], "r" );
X	if ( f == NULL )
X	    {
X	    perror( argv[1] );
X	    exit( 1 );
X	    }
X	}
X    else
X	{
X	fprintf( stderr, "usage:  %s [<file>]\n", argv[0] );
X	exit( 1 );
X	}
X
X    while ( (c = getc( f )) != EOF )
X	{
X	lc = st_ulaw_to_linear( c );
X	printf( "%d\n", lc );
X	}
X
X    exit( 0 );
X    }
SHAR_EOF
if test 977 -ne "`wc -c < 'ulawtolin.c'`"
then
	echo shar: error transmitting "'ulawtolin.c'" '(should have been 977 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'ulawtolin.1'" '(682 characters)'
if test -f 'ulawtolin.1'
then
	echo shar: will not over-write existing file "'ulawtolin.1'"
else
sed 's/^X//' << \SHAR_EOF > 'ulawtolin.1'
X.TH ulawtolin 1 "20 November 1989"
X.SH NAME
Xulawtolin - convert a ulaw sound file to linear
X.SH SYNOPSIS
Xulawtolin [<file>]
X.SH DESCRIPTION
XConverts a ulaw sound file into linear, printable form - ASCII numbers
Xbetween -32768 and 32767.
X.SH "SEE ALSO"
Xlintoulaw(1)
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 682 -ne "`wc -c < 'ulawtolin.1'`"
then
	echo shar: error transmitting "'ulawtolin.1'" '(should have been 682 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'volume.c'" '(1295 characters)'
if test -f 'volume.c'
then
	echo shar: will not over-write existing file "'volume.c'"
else
sed 's/^X//' << \SHAR_EOF > 'volume.c'
X/* volume.c - change the volume of a sound file
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include "libst.h"
X
X#define MYBUFSIZ 256
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *f;
X    char mybuf[MYBUFSIZ];
X    float scale;
X    double atof();
X    int c, lc;
X
X    if ( argc < 2 || argc > 3 )
X	{
X	fprintf( stderr, "usage:  %s <factor> [<file>]\n", argv[0] );
X	exit( 1 );
X	}
X
X    scale = atof( argv[1] );
X    if ( scale == 0.0 )
X	{
X	fprintf( stderr, "%s: scale factor required\n", argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	f = stdin;
X    else if ( argc == 3 )
X	{
X	f = fopen( argv[2], "r" );
X	if ( f == NULL )
X	    {
X	    perror( argv[2] );
X	    exit( 1 );
X	    }
X	}
X    setbuffer( stdout, mybuf, MYBUFSIZ );
X
X    while ( (c = getc( f )) != EOF )
X	{
X	lc = st_ulaw_to_linear( c ) * scale;
X	LINCLIP( lc );
X	putchar( st_linear_to_ulaw( lc ) );
X	}
X
X    exit( 0 );
X    }
SHAR_EOF
if test 1295 -ne "`wc -c < 'volume.c'`"
then
	echo shar: error transmitting "'volume.c'" '(should have been 1295 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'volume.1'" '(639 characters)'
if test -f 'volume.1'
then
	echo shar: will not over-write existing file "'volume.1'"
else
sed 's/^X//' << \SHAR_EOF > 'volume.1'
X.TH volume 1 "20 November 1989"
X.SH NAME
Xvolume - change the volume of a sound file
X.SH SYNOPSIS
Xvolume <factor> [<file>]
X.SH DESCRIPTION
XMultiplies the amplitude by the specified factor.
X.SH "SEE ALSO"
Xpitch(1), speed(1)
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 639 -ne "`wc -c < 'volume.1'`"
then
	echo shar: error transmitting "'volume.1'" '(should have been 639 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'vox.c'" '(1317 characters)'
if test -f 'vox.c'
then
	echo shar: will not over-write existing file "'vox.c'"
else
sed 's/^X//' << \SHAR_EOF > 'vox.c'
X/* vox.c - simple silence-deletion filter
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include "libst.h"
X
X#define abs(a) ((a) >= 0 ? (a) : -(a))
X
X#define Q_DELTA 100
X#define Q_SAMPLES 512
X#define MYBUFSIZ 256
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *f;
X    char mybuf[MYBUFSIZ];
X    int c, lc, plc, q;
X
X    if ( argc == 1 )
X	f = stdin;
X    else if ( argc == 2 )
X	{
X	f = fopen( argv[1], "r" );
X	if ( f == NULL )
X	    {
X	    perror( argv[1] );
X	    exit( 1 );
X	    }
X	}
X    else
X	{
X	fprintf( stderr, "usage:  %s [<file>]\n", argv[0] );
X	exit( 1 );
X	}
X    setbuffer( stdout, mybuf, MYBUFSIZ );
X
X    q = 0;
X    for ( plc = 0; (c = getc( f )) != EOF; plc = lc )
X	{
X	lc = st_ulaw_to_linear( c );
X	if ( abs( plc - lc ) <= Q_DELTA )
X	    q++;
X	else
X	    q = 0;
X
X	if ( q < Q_SAMPLES )
X	    putchar( (unsigned char) c );
X	else if ( q == Q_SAMPLES )
X	    fflush( stdout );
X	}
X
X    exit( 0 );
X    }
SHAR_EOF
if test 1317 -ne "`wc -c < 'vox.c'`"
then
	echo shar: error transmitting "'vox.c'" '(should have been 1317 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'vox.1'" '(670 characters)'
if test -f 'vox.1'
then
	echo shar: will not over-write existing file "'vox.1'"
else
sed 's/^X//' << \SHAR_EOF > 'vox.1'
X.TH vox 1 "20 November 1989"
X.SH NAME
Xvox - simple silence-deletion filter for sound files
X.SH SYNOPSIS
Xvox [<file>]
X.SH DESCRIPTION
XFilters input to output, but with quiet segments deleted.
XUseful for storing speech or sending it over a network or...?
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 670 -ne "`wc -c < 'vox.1'`"
then
	echo shar: error transmitting "'vox.1'" '(should have been 670 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'dial.c'" '(836 characters)'
if test -f 'dial.c'
then
	echo shar: will not over-write existing file "'dial.c'"
else
sed 's/^X//' << \SHAR_EOF > 'dial.c'
X/* dial.c - generate DTMF dialing codes on the speaker
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include <fcntl.h>
X#include "libsst.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    int sst_fd;
X
X    if ( argc != 2 )
X	{
X	fprintf( stderr, "usage:  %s <dialstring>\n", argv[0] );
X	exit( 1 );
X	}
X
X    sst_fd = sst_open( );
X
X    sst_dtmf( sst_fd, argv[1], 250000, 30000 );
X
X    sst_close( sst_fd );
X    exit( 0 );
X    }
SHAR_EOF
if test 836 -ne "`wc -c < 'dial.c'`"
then
	echo shar: error transmitting "'dial.c'" '(should have been 836 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'dial.1'" '(917 characters)'
if test -f 'dial.1'
then
	echo shar: will not over-write existing file "'dial.1'"
else
sed 's/^X//' << \SHAR_EOF > 'dial.1'
X.TH dial 1 "20 November 1989"
X.SH NAME
Xdial - generate DTMF dialing codes on the speaker
X.SH SYNOPSIS
Xdial <dialstring>
X.SH DESCRIPTION
XThe string should consist of characters from "0123456789*#ABCD".
XPunctuation from " -()+" is ignored, and "," generates a pause.
X.SH ENVIRONMENT
X.nf
XSST_PLAY - playback gain, from 0 to 99, default 75
XSST_EARPHONES - if set, send output to the earphone jack
X.fi
X.SH "SEE ALSO"
Xtones(1)
X.SH BUGS
XNeeds a better user interface, for instance to specify tone duration.
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 917 -ne "`wc -c < 'dial.1'`"
then
	echo shar: error transmitting "'dial.1'" '(should have been 917 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'listen.c'" '(1311 characters)'
if test -f 'listen.c'
then
	echo shar: will not over-write existing file "'listen.c'"
else
sed 's/^X//' << \SHAR_EOF > 'listen.c'
X/* listen.c - hardware loopback, connect microphone to speaker
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include <sys/signal.h>
X#include "libsst.h"
X
Xint sst_fd;
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    struct audio_ioctl ai;
X    int junk;
X    int sighandler();
X
X    sst_fd = sst_open( );
X    (void) signal( SIGHUP, sighandler );
X    (void) signal( SIGINT, sighandler );
X
X    ai.control = AUDIO_MUX_MCR1;
X    if ( ioctl( sst_fd, AUDIOGETREG, &ai ) < 0 )
X	{
X	perror( "GETREG MCR1" );
X	exit( 1 );
X	}
X    ai.data[0] = ( AUDIO_MUX_PORT_BA << 4 ) | AUDIO_MUX_PORT_BA;
X    if ( ioctl( sst_fd, AUDIOSETREG, &ai ) < 0 )
X	{
X	perror( "SETREG MCR1" );
X	exit( 1 );
X	}
X
X    if ( ioctl( sst_fd, AUDIOREADSTART, &junk ) < 0 )
X	{
X	perror( "AUDIOREADSTART" );
X	exit( 1 );
X	}
X
X    for ( ; ; )
X	pause( );
X
X    /* NOTREACHED */
X    }
X
Xint
Xsighandler( )
X    {
X    sst_close( sst_fd );
X    exit( 1 );
X    }
SHAR_EOF
if test 1311 -ne "`wc -c < 'listen.c'`"
then
	echo shar: error transmitting "'listen.c'" '(should have been 1311 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'listen.1'" '(892 characters)'
if test -f 'listen.1'
then
	echo shar: will not over-write existing file "'listen.1'"
else
sed 's/^X//' << \SHAR_EOF > 'listen.1'
X.TH listen 1 "20 November 1989"
X.SH NAME
Xlisten - hardware loopback, connect microphone to speaker
X.SH SYNOPSIS
Xlisten
X.SH DESCRIPTION
XConnects the microphone input to the speaker output in hardware, and
Xthen goes to sleep.
XBreak the connection by interrupting the program.
X.SH ENVIRONMENT
X.nf
XSST_RECORD - recording gain, from 0 to 99, default 75
XSST_PLAY - playback gain, from 0 to 99, default 75
XSST_EARPHONES - if set, send output to the earphone jack
X.fi
X.SH "SEE ALSO"
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 892 -ne "`wc -c < 'listen.1'`"
then
	echo shar: error transmitting "'listen.1'" '(should have been 892 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'play.c'" '(2267 characters)'
if test -f 'play.c'
then
	echo shar: will not over-write existing file "'play.c'"
else
sed 's/^X//' << \SHAR_EOF > 'play.c'
X/* play.c - play a sound file on the speaker
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <sys/file.h>
X#include <sys/signal.h>
X#include "libsst.h"
X
X#define MYBUF 256
X
Xint sst_fd;
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    int rrtn, wrtn;
X    unsigned char buf[MYBUF];
X    int file_fd;
X    int argn, loop;
X    int sighandler();
X    char *usage = "usage:  %s [-l] [<file>]\n";
X
X    sst_fd = sst_open( );
X    (void) signal( SIGHUP, sighandler );
X    (void) signal( SIGINT, sighandler );
X
X    argn = 1;
X    loop = 0;
X
X    if ( argn < argc && argv[argn][0] == '-' )
X	{
X	if ( argv[argn][1] == 'l' && argv[argn][2] == '\0' )
X	    loop = 1;
X	else
X	    {
X	    fprintf( stderr, usage, argv[0] );
X	    exit( 1 );
X	    }
X	argn++;
X	}
X    if ( argn == argc )
X	{
X	if ( loop )
X	    {
X	    fprintf( stderr, "can't loop stdin, aye!\n" );
X	    exit( 1 );
X	    }
X	file_fd = 0;
X	}
X    else
X	{
X	file_fd = open( argv[argn], O_RDONLY );
X	if ( file_fd < 0 )
X	    {
X	    perror( argv[argn] );
X	    exit( 1 );
X	    }
X	argn++;
X	}
X    if ( argn != argc )
X	{
X	fprintf( stderr, usage, argv[0] );
X	exit( 1 );
X	}
X
X    for ( ; ; )
X	{
X	rrtn = read( file_fd, buf, MYBUF );
X	if ( rrtn < 0 )
X	    {
X	    perror( "read" );
X	    exit( 1 );
X	    }
X	if ( rrtn == 0 )
X	    {
X	    if ( loop )
X		{
X		if ( lseek( file_fd, 0, L_SET ) == -1 )
X		    {
X		    perror( "lseek" );
X		    exit( 1 );
X		    }
X		continue;
X		}
X	    else
X		break;
X	    }
X
X	for ( ; ; )
X	    {
X	    wrtn = write( sst_fd, buf, rrtn );
X	    if ( wrtn < 0 )
X		{
X		perror( "write" );
X		exit( 1 );
X		}
X	    if ( wrtn != 0 )
X		break;
X	    usleep( 1000 );
X	    }
X	if ( wrtn != rrtn )
X	    {
X	    fprintf( stderr, "play: rrtn = %d, wrtn = %d\n", rrtn, wrtn );
X	    exit( 1 );
X	    }
X	}
X
X    sst_close( sst_fd );
X    exit( 0 );
X    }
X
Xint
Xsighandler( )
X    {
X    sst_close( sst_fd );
X    exit( 1 );
X    }
SHAR_EOF
if test 2267 -ne "`wc -c < 'play.c'`"
then
	echo shar: error transmitting "'play.c'" '(should have been 2267 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'play.1'" '(810 characters)'
if test -f 'play.1'
then
	echo shar: will not over-write existing file "'play.1'"
else
sed 's/^X//' << \SHAR_EOF > 'play.1'
X.TH play 1 "20 November 1989"
X.SH NAME
Xplay - play a sound file on the speaker
X.SH SYNOPSIS
Xplay [-l] [<file>]
X.SH DESCRIPTION
XPlays the specified file, or stdin.
XThe -l flag means loop - it plays the file repeatedly until interrupted.
X.SH ENVIRONMENT
X.nf
XSST_PLAY - playback gain, from 0 to 99, default 75
XSST_EARPHONES - if set, send output to the earphone jack
X.fi
X.SH "SEE ALSO"
Xrecord(1)
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 810 -ne "`wc -c < 'play.1'`"
then
	echo shar: error transmitting "'play.1'" '(should have been 810 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'record.c'" '(1472 characters)'
if test -f 'record.c'
then
	echo shar: will not over-write existing file "'record.c'"
else
sed 's/^X//' << \SHAR_EOF > 'record.c'
X/* record.c - record from the microphone input
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <sys/signal.h>
X#include "libsst.h"
X
X#define MYBUF 256
X
Xint sst_fd;
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    int rrtn, wrtn;
X    unsigned char buf[MYBUF];
X    int file_fd;
X    int sighandler();
X
X    sst_fd = sst_open( );
X    file_fd = 1;
X    (void) signal( SIGHUP, sighandler );
X    (void) signal( SIGINT, sighandler );
X
X    if ( ioctl( sst_fd, AUDIOREADSTART, &rrtn ) < 0 )
X	{
X	perror( "AUDIOREADSTART" );
X	exit( 1 );
X	}
X
X    for ( ; ; )
X	{
X	rrtn = read( sst_fd, buf, MYBUF );
X	if ( rrtn < 0 )
X	    {
X	    perror( "read" );
X	    exit( 1 );
X	    }
X	if ( rrtn == 0 )
X	    break;
X
X	wrtn = write( file_fd, buf, rrtn );
X	if ( wrtn < 0 )
X	    {
X	    perror( "write" );
X	    exit( 1 );
X	    }
X	if ( wrtn != rrtn )
X	    {
X	    fprintf( stderr, "record: rrtn = %d, wrtn = %d\n", rrtn, wrtn );
X	    exit( 1 );
X	    }
X	}
X
X    sst_close( file_fd );
X    exit( 0 );
X    }
X
Xint
Xsighandler( )
X    {
X    sst_close( sst_fd );
X    exit( 1 );
X    }
SHAR_EOF
if test 1472 -ne "`wc -c < 'record.c'`"
then
	echo shar: error transmitting "'record.c'" '(should have been 1472 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'record.1'" '(719 characters)'
if test -f 'record.1'
then
	echo shar: will not over-write existing file "'record.1'"
else
sed 's/^X//' << \SHAR_EOF > 'record.1'
X.TH record 1 "20 November 1989"
X.SH NAME
Xrecord - record a sound file from the microphone input
X.SH SYNOPSIS
Xrecord
X.SH DESCRIPTION
XRecords sound, writing it to stdout in ulaw form, until interrupted.
X.SH ENVIRONMENT
X.nf
XSST_RECORD - recording gain, from 0 to 99, default 75
X.fi
X.SH "SEE ALSO"
Xplay(1)
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 719 -ne "`wc -c < 'record.1'`"
then
	echo shar: error transmitting "'record.1'" '(should have been 719 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'tones.c'" '(1108 characters)'
if test -f 'tones.c'
then
	echo shar: will not over-write existing file "'tones.c'"
else
sed 's/^X//' << \SHAR_EOF > 'tones.c'
X/* tones.c - play sine-wave tones on the speaker
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation.  This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include <fcntl.h>
X#include "libsst.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    int sst_fd, dhz1, dhz2, thz, rhz;
X
X    if ( argc < 2 || argc > 5 )
X	{
X	fprintf( stderr, "usage:  %s <dhz1> [<dhz2> [<thz> [<rhz>]]]\n", argv[0] );
X	exit( 1 );
X	}
X    dhz1 = atoi( argv[1] );
X    dhz2 = thz = rhz = 0;
X    if ( argc > 2 )
X	{
X	dhz2 = atoi( argv[2] );
X	if ( argc > 3 )
X	    {
X	    thz = atoi( argv[3] );
X	    if ( argc > 4 )
X		{
X		rhz = atoi( argv[4] );
X		}
X	    }
X	}
X
X    sst_fd = sst_open( );
X
X    sst_tones( sst_fd, dhz1, dhz2, thz, rhz, 1000000 );
X
X    sst_close( sst_fd );
X    exit( 0 );
X    }
SHAR_EOF
if test 1108 -ne "`wc -c < 'tones.c'`"
then
	echo shar: error transmitting "'tones.c'" '(should have been 1108 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'tones.1'" '(1000 characters)'
if test -f 'tones.1'
then
	echo shar: will not over-write existing file "'tones.1'"
else
sed 's/^X//' << \SHAR_EOF > 'tones.1'
X.TH tones 1 "20 November 1989"
X.SH NAME
Xtones - play sine-wave tones on the speaker
X.SH SYNOPSIS
Xtones <dhz1> [<dhz2> [<thz> [<rhz>]]]
X.SH DESCRIPTION
XThe SPARCstation's audio chip has four different sine-wave generators:
Xtwo "DTMF generators", one "tone generator", and one "tone ringer".
XThis tool exercises them, using the specified frequencies.
X.SH ENVIRONMENT
X.nf
XSST_PLAY - playback gain, from 0 to 99, default 75
XSST_EARPHONES - if set, send output to the earphone jack
X.fi
X.SH "SEE ALSO"
Xdial(1)
X.SH BUGS
XNeeds a better user interface, for instance to specify tone duration.
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation.  This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 1000 -ne "`wc -c < 'tones.1'`"
then
	echo shar: error transmitting "'tones.1'" '(should have been 1000 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0



More information about the Alt.sources mailing list