v02i002: Play: standalone sound playing fixes for sound.c (SS1), Part01/01
Charles Mcgrew
mcgrew at dartagnan.rutgers.edu
Wed Jan 10 07:56:48 AEST 1990
Submitted-by: gopstein at soleil.uucp
Posting-number: Volume 2, Issue 2
Archive-name: play-ss1
The following shar file will unpack an ed script that will convert
/usr/demo/sound/sound.c into a standalone program to play sound files
on the Sparcstation I. Unsharing will create the script "patchfile".
Then issue the following command:
ed /usr/demo/sound/sound.c < patchfile
The version of sound.c that this works with is:
-rw-r--r-- 1 bin 37759 May 25 22:58 sound.c
This will create play.c in the current directory. Just "cc -o play play.c"
to compile. Its use is "play [-v volume] soundfile" where
volume is 0-10, the default is 7. Since it doesn't use the screen, it
will work with rsh. [Or in a modified "biff" -- I always wanted a
machine to *tell* me I had mail! -CWM]
If anyone wants it, I have a quick-hack program to convert 8-bit binary
sampled audio (like the MAC uses) into the u-law format for the SS1,
but it isn't very user-friendly.
Rich Gopstein
..!rutgers!soleil!gopstein
--------------------------------Cut Here-----------------------------------
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by whoa!gopstein on Mon Nov 13 15:04:18 EST 1989
# Contents: patches
echo x - patches
sed 's/^@//' > "patches" <<'@//E*O*F patches//'
1848,1854d
1709,1833d
1705c
strcpy(Buffer.directory, ".");
@.
1666,1691d
1664d
1659d
1646c
fprintf(stderr,
@.
1643,1644d
1635d
1633a
@.
1630c
@.
1620c
fprintf(stderr,
@.
1617,1618d
1609d
1604d
1592c
fprintf(stderr,
@.
1589d
1503d
1492d
1482d
1478d
1460d
1448,1457d
1443,1446d
839,1438d
831,836d
815,817c
perror("Error opening input file");
@.
523,813d
515,521d
513d
500,511c
file_open(path)
char *path;
@.
497d
495c
play_flag = 0;
@.
493d
489d
479d
474,476d
471d
469d
465,467d
455,461d
448,453d
446d
442d
440d
435,437c
perror("audio write");
@.
431d
417,420d
409d
264,382d
258d
254c
fprintf(stderr,
@.
237d
224,235c
main_play_volume_proc(value)
@.
219,221c
/* This is the routine that is called from the main loop that writes
* sound to the device.
*
* It needs the following state data:
- cursor start and end (calculate in proc)
* - current position in the buffer
@.
215,216d
212a
main_play_volume_proc(volume);
while(play_flag) {
main_play();
@.
210,211c
audio_open();
@.
207,208c
file_open(*argv);
@.
204,205c
buffer_initialize(&Buffer);
@.
201,202c
volume = 21;
}
@.
199c
} else {
@.
197c
if (strcmp(*argv++, "-v") != 0) {
fprintf(stderr, "Usage: play [-v volume] soundfile\n");
exit(1);
} else {
volume = atoi(*argv++) * 3;
}
@.
193,195c
if (argc == 4) {
@.
187,191c
argv++;
@.
185d
171,182c
if ((argc != 2) && (argc != 4)) {
fprintf(stderr, "Usage: play [-v volume] soundfile\n");
@.
169c
int volume;
@.
167c
char **argv;
@.
164d
159,162d
134a
int play_flag = 1;
@.
109,133c
int fd;
@.
75,107d
62,72d
60d
47,58d
34,44d
22,28d
15a
#include <sys/time.h>
@.
5,14d
1,3c
/* Play.c */
/* This program will play sound files in u-law format on the */
/* Sparcstation I. It is a modification of Sun's sound.c program */
/* distributed with SunOS. These modifications were done by */
/* Richard Gopstein (..!rutgers!soleil!gopstein), September 1989 */
@.
w play.c
q
@//E*O*F patches//
chmod u=rw,g=r,o=r patches
exit 0
More information about the Comp.sources.sun
mailing list