[6151] in SIPB bug reports

home help back first fref pref prev next nref lref last post

Re: xmcd

daemon@ATHENA.MIT.EDU (John Hawkinson)
Thu Sep 26 21:09:10 1996

Date: Thu, 26 Sep 1996 20:57:12 -0400
To: Jennie Hango <jhango@MIT.EDU>
Cc: bug-sipb@MIT.EDU
In-Reply-To: "[6150] in SIPB bug reports"
From: John Hawkinson <jhawk@MIT.EDU>

> I recently got an Athena Sun4 installed in my office, and I'm trying
> to figure out xmcd (hey, first things first, right? :^).  Is there any
> way to redirect the output from the CD-ROM headphone jack to the
> built-in speakers?  The headphones work fine, but it'd be nice to
> share whatever I'm listening to with my officemates (whether they want
> to hear it or not!  :^).  

There's probably a better way than this, but...

Anyhow, yes it's possible. You may find that all that's necessary
is to muck with /usr/openwin/audiocontrol or /usr/demo/SOUND/bin/gaintool,
but I suspect that if you don't have the input audio source set to
CD, you'll lose.

I use the attached program (which I call "kreaudio") invoked usually as:

	kreaudio cd os g200 v

(that's use the cd as input Output to the Speaker, set the gain to 200,
and tell me what you're doing).

Of course, all the paramaters other than "cd" (and "v") can be adjusted
with gaintool or audiocontrol after you've set the input source.

--jhawk

/* 
Received: from munnari.OZ.AU by poblano.bbnplanet.com id aa05268;
          11 Jul 96 6:32 EDT
Received: from mundamutti.cs.mu.OZ.AU by munnari.OZ.AU with SMTP (5.83--+1.3.1+0.56)
        id KA16430; Thu, 11 Jul 1996 20:32:20 +1000 (from kre@munnari.OZ.AU)
To: John Hawkinson <jhawk@bbnplanet.com>
Subject: Re: Passthu CD audio on ss5? 
In-Reply-To: Your message of "Wed, 10 Jul 1996 22:08:58 -0400."
             <199607110208.WAA06568@all-purpose-gunk.near.net> 
Date: Thu, 11 Jul 1996 20:32:20 +1000
Message-Id: <20339.837081140@munnari.OZ.AU>
From: Robert Elz <kre@munnari.oz.au>
Status: RO

    Date:        Wed, 10 Jul 1996 22:08:58 -0400 (EDT)
    From:        John Hawkinson <jhawk@bbnplanet.com>
    Message-ID:  <199607110208.WAA06568@all-purpose-gunk.near.net>

    Is there some way to cause vat to play audio from the built-in CD player of
    such a box without physically connecting the external audio out on the cd
    player to the line in?

Yes.   (SS4 & 5 is all I know).  And assuming the internal wire is
connected of course, I have a SS4, the audio card is optional, and
wasn't installed when the workstation arrived, and had to be
installed here.   I don't deal much with hardware stuff, so someone
else did that for me, and assured me they had connected the wire
and I believed them (and they did...)
    
    I get the feeling I'm missing some critical component :-)

probably openwindows - so you can run sun's audio control panel
tool...

Me too, openwindows is disgusting.

I use this little program I made that I run from the cmd line as

        "audio cd"

to set things up the way I like it - it assumes output via
external speakers, playing CD's through the internal speaker
isn't a good way to get nice sound.

This is "audio.c" everything else should exist on a SunOS4.1.4
system (might need the SS5 audio patch included so you get the
extra .h file that they forgot...)

Sorry, no man page.   You never need to say "audio vat" (any
more), that was only needed before Van fixed the monitor gain
problem that led to the comment in the changelog that you
forwarded.   Now vat does the right thing (if vat audio arrives
the cd output is just switched off, and resumes again as soon as
vat releases the audio system).

kre
*/

#include <stdio.h>
#include <sys/ioctl.h>
#include <sun/audioio.h>

#ifndef AUDIO_INTERNAL_CD_IN
#define AUDIO_INTERNAL_CD_IN    4
#endif

#define CD      1
#define VAT     2

audio_info_t as;

main(argc, argv)
        int argc;
        char **argv;
{
        register fd;
        register in, out, gain, igain, ogain;
        register c, l;
        register prt = 0;
        register setup = 0;

        in = -1;
        out = -1;
        gain = -1;
        igain = -1;
        ogain = -1;

        while (--argc > 0) {
                argv++;
                if (strcasecmp(*argv, "cd") == 0) {
                        in = AUDIO_INTERNAL_CD_IN;
                        out = AUDIO_LINE_OUT;
                        igain = 159;
                        ogain = 255;
                        gain = 255;
                        setup = CD;
                        continue;
                }
                if (strcasecmp(*argv, "off") == 0) {
                        in = 0;
                        out = 0;
                        gain = 0;
                        continue;
                }
                if (strcasecmp(*argv, "vat") == 0) {
                        in = AUDIO_MICROPHONE;
                        out = AUDIO_SPEAKER;
                        igain = 79;
                        ogain = 176;
                        gain = 0;
                        setup = VAT;
                        continue;
                }
                while (c = *(*argv)++) {
                        switch (c) {
                        case 'i':
                                in = 0;
                                while (c = *(*argv)++) switch (c) {
                                case 'm':
                                        in = AUDIO_MICROPHONE;
                                        break;
                                case 'l':
                                        in = AUDIO_LINE_IN;
                                        break;
                                case 'c':
                                        in = AUDIO_INTERNAL_CD_IN;
                                        break;
                                case ',': case '=': case '+': case ' ':
                                        break;
                                default:
                                        fprintf(stderr, "Bad in device\n");
                                        exit(1);
                                }
                                break;

                        case 'o':
                                if (out == -1)
                                        out = 0;
                                while (c = *(*argv)++) switch (c) {
                                case 's':
                                        out |= AUDIO_SPEAKER;
                                        break;
                                case 'l':
                                        out |= AUDIO_LINE_OUT;
                                        break;
                                case 'h':
                                        out |= AUDIO_HEADPHONE;
                                        break;
                                case ',': case '=': case '+': case ' ':
                                        break;
                                default:
                                        fprintf(stderr, "Bad out device\n");
                                        exit(1);
                                }
                                break;

                        case 'g':
                                l = **argv;
                                switch (l) {
                                case 'i': case 'o': case 'm':
                                        ++*argv;
                                        break;
                                }
                                while ((c = **argv) == '=' || c == ' ')
                                        ++*argv;
                                switch (l) {
                                case 'i':
                                        igain = atoi(*argv);
                                        break;
                                case 'o':
                                        ogain = atoi(*argv);
                                        break;
                                default:
                                        gain = atoi(*argv);
                                        break;
                                }
                                break;

                        case 'v':
                                prt = 1;
                                break;

                        case '-':
                                continue;

                        default:
                                fprintf(stderr, "Bad option\n");
                                exit(1);
                        }
                        break;
                }
        }

        AUDIO_INITINFO(&as);
        if (in != -1)
                as.record.port = in;
        if (out != -1)
                as.play.port = out;
        if (gain != -1)
                as.monitor_gain = gain;
        if (igain != -1)
                as.record.gain = igain;
        if (ogain != -1)
                as.play.gain = ogain;

        switch (setup) {
        case CD:
                as.record.sample_rate = 44100;
                as.record.channels = 2;
                as.record.precision = 16;
                as.record.encoding = AUDIO_ENCODING_LINEAR;
                /*
                */

                as.play.sample_rate = 44100;
                as.play.channels = 2;
                as.play.precision = 16;
                as.play.encoding = AUDIO_ENCODING_LINEAR;
                /*
                */
                break;

        case VAT:
                /* do I care now ?  let vat set its own */
                break;
        }

        fd = -1;
        if (setup == CD)
                fd = open("/dev/audio", 2);
        if (fd < 0)
                fd = open("/dev/audioctl", 0);
        if (fd < 0)
                perror("audioctl"), exit(1);

        if (ioctl(fd, AUDIO_SETINFO, &as) < 0)
                perror("setinfo"), exit(1);

        if (in != -1 && as.record.port != in)
                fprintf(stderr, "Couldn't correctly set in port\n");
        if (out != -1 && as.play.port != out)
                fprintf(stderr, "Couldn't correctly set out port\n");
        if (gain != -1 && as.monitor_gain != gain)
                fprintf(stderr, "Couldn't correctly set gain\n");
        if (igain != -1 && as.record.gain != igain)
                fprintf(stderr, "Couldn't correctly set record gain\n");
        if (ogain != -1 && as.play.gain != ogain)
                fprintf(stderr, "Couldn't correctly set play gain\n");

        if (prt) {
                if (ioctl(fd, AUDIO_GETINFO, &as) < 0)
                        perror("sgtinfo"), exit(1);

                printf("Audio  in:");
                if (as.record.port == 0) {
                        printf(" None");
                } else {
                        l = 0;
                        if (as.record.port & AUDIO_MICROPHONE) {
                                l += 10;
                                printf(" Microphone");
                                as.record.port &= ~AUDIO_MICROPHONE;
                        }
                        if (as.record.port & AUDIO_LINE_IN) {
                                l += 5;
                                printf(" Line");
                                as.record.port &= ~AUDIO_LINE_IN;
                        }
                        if (as.record.port & AUDIO_INTERNAL_CD_IN) {
                                l += 3;
                                printf(" CD");
                                as.record.port &= ~AUDIO_INTERNAL_CD_IN;
                        }
                        if (as.record.port) {
                                l += 2; /* probably */
                                printf(" %x", as.record.port);
                        }
                        if (l < 24) {
                                while (l < 24) {
                                        putchar('\t');
                                        l += 8;
                                        l &= ~7;
                                }
                        } else
                                putchar(' ');
                        printf("(gain: %d)", as.record.gain);
                }
                printf("\nAudio out:");

                if (as.play.port == 0) {
                        printf(" None");
                } else {
                        l = 0;
                        if (as.play.port & AUDIO_HEADPHONE) {
                                l += 10;
                                printf(" Headphone");
                                as.play.port &= ~AUDIO_HEADPHONE;
                        }
                        if (as.play.port & AUDIO_LINE_OUT) {
                                l += 5;
                                printf(" Line");
                                as.play.port &= ~AUDIO_LINE_OUT;
                        }
                        if (as.play.port & AUDIO_SPEAKER) {
                                l += 8;
                                printf(" Speaker");
                                as.play.port &= ~AUDIO_SPEAKER;
                        }
                        if (as.play.port) {
                                l += 2;
                                printf(" %x", as.play.port);
                        }
                        if (l < 24) {
                                while (l < 24) {
                                        putchar('\t');
                                        l += 8;
                                        l &= ~7;
                                }
                        } else
                                putchar(' ');
                        printf("(gain: %d)", as.play.gain);
                }
                printf("\nMonitor gain:\t\t\t%d\n", as.monitor_gain);
        }

        exit(0);
}

home help back first fref pref prev next nref lref last post