home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio Toolkit
/
Audio_Toolkit_Walnut_Creek_September_1997.iso
/
mac
/
unix
/
linux
/
sb16agc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-29
|
1KB
|
68 lines
/* sb16agc - enable/disable AGC on Soundblaster 16
* PD by RJM 96/1/5
*
* compile with 'cc -o sb16agc sb16agc.c'
* install with 'install -o root -m 4511 sb16agc /usr/local/bin'
*
* THIS IS A REVOLTING HACK!
* (Based on dosemu debug output from 'sb16set /agc:-')
* DO NOT USE THIS *UNLESS*:
* - you have a Soundblaster 16; and
* - 'cat /dev/sndstat' says "SoundBlaster16 at 0x220 ..."
* (or in newer kernels, "Sound Blaster at 0x220 ...")
*
* Even then, I should add a disclaimer. This program works fine for
* me, but don't hold me responsible if your machine explodes. :-)
*
* Note that this only affects the mic socket - line-in is always
* free of AGC interference (not to mention being stereo rather than
* the mic socket's mono).
*/
#include <stdio.h>
#include <unistd.h>
static void inline outb(char value, unsigned short port)
{
__asm__ volatile ("outb %0,%1"
::"a" ((char) value),"d" ((unsigned short) port));
}
void die(char *str)
{
fprintf(stderr,"Couldn't %s.\n",str);
}
void usage()
{
printf("usage: sb16agc [on|off]\n");
exit(1);
}
int main(int argc,char *argv[])
{
int disable=0;
if(ioperm(0x224,2,1)==-1) die("get I/O permissions (not setuid root?)");
if(argc!=2) usage(),exit(1);
if(strcmp(argv[1],"on")==0)
disable=0;
else
if(strcmp(argv[1],"off")==0)
disable=1;
else
usage(),exit(1);
outb(0x43,0x224);
usleep(10000);
outb(disable,0x225);
exit(0);
}