Yes, the output of the sound card is affected by several layers of volume controls. But the it is possible to use its DSP to do some, erm, "fun" things.
Here's a code snipplet. Make sure you have Alsa OSS emulation support
enabled.
Include these:
#include <linux/soundcard.h>
#include <sys/ioctl.h>
#include <fcntl.h>
then
int initSound()
{
//OSS Stuff, set the sampling rate, etc: 48000, Mono, 16bit
int fd=open("/dev/dsp", O_WRONLY); // | O_NONBLOCK);
int arg, status;
int bit, samp, ch;
arg = 16; // sample size
status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
status = ioctl(fd, SOUND_PCM_READ_BITS, &arg);
bit=arg;
arg = 2; //Number of channels, 1=mono
status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);
status = ioctl(fd, SOUND_PCM_READ_CHANNELS, &arg);
ch=arg;
arg = 48000; //Yeah. sampling rate
status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
status = ioctl(fd, SOUND_PCM_READ_RATE, &arg);
samp=arg;
//Print out what we *actually* got.. not that the program
//pays attention to these values anyway
printf("\nDSP Says:\n%dHz %dCh %dbit", samp, ch, bit);
return fd;
}
And then you can basically write to the file descriptor returned. Using
write() or whatever. Don't write one byte at a time, rather make an
array that you can fill, and when it hits about 2000 samples or
whatever, just write that to the fd. This code is from a MIDI
synthesizer I wrote, so it should work. As for getting a specific
voltage, I dont think the sound card will give you 12V. Highly doubtful.
But, throw an op-amp at it (LM386 or whatever) and you can probably get
12V out of it.
Be very careful when messing with the actual sound card wiring;
something gone wrong and you can end up letting the magic smoke out of
your DSP or computer.. and everything fried. But if you are careful, you
should be ok.
Hope this helps
Steve
On Thu, 2006-03-16 at 00:09 -0500, as wrote:
> i have never programmed a sound card- is it possible to set the
> voltage output. won't this be affected by volume control of the
> system?
>
> aravind.
signature.asc
Description: This is a digitally signed message part
