🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.linux
Article #59731

Re: [Q] Programming Soundblaster16 with Linux

#59731
From: Jim Peterson
Date: Mon, 04 Dec 1995 00:00
46 lines
1942 bytes
> I am trying to write some code to record sounds using a SoundBlaster 16

All you have to do to record sound is open /dev/dsp for reading.  The
program appended below will output the sound data to stdout (which can
then
be redirected to a file).  It will also optionally change the sample
rate
as specified on the command line.  The best part is that it will work
with
any sound card supported by the kernel--not just SoundBlaster 16.

A couple things to check, though.  The input sound source must be
selected
appropiately (CD/AUX/MIC).  I do this with 'xmix'.  Also, the output is
raw
data.  This can be converted to *.wav files or other formats with
programs
like 'sox'.  You may also wish to check <linux/soundcard.h> and related
files
for other ioctl() commands.

Hope this helps,
--Jim

==============================================================================
/* record.c */
/* Sample usage: 'record 16384 > data.raw' */
#include <sys/ioctl.h>
#include <linux/soundcard.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>

main(int argc, char** argv)
{
 int fd;
 int Rate;
 char c;

 fd=open("/dev/dsp",O_RDONLY);
 Rate=8192;
 if(argc>1) Rate=atoi(argv[1]);
 ioctl(fd,SNDCTL_DSP_SPEED,&Rate);
 fprintf(stderr,"Rate: %d\n",Rate);
 while(1) { read(fd,&c,sizeof(c)); printf("%c",c); }
}
Technical Details
Message-ID: <30C3BDA3.255C1D25@birch.ee.vt.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <4a01tb$qud@mirv.unsw.edu.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 102983,1051dff35589cace,start
X-Google-Attributes: gid102983,public
From: Jim Peterson <jspeter@birch.ee.vt.edu>
Subject: Re: [Q] Programming Soundblaster16 with Linux
Date: 1995/12/04
Message-ID: <30C3BDA3.255C1D25@birch.ee.vt.edu>
X-Deja-AN: 121137217
references: <4a01tb$qud@mirv.unsw.edu.au>
content-type: text/plain; charset=us-ascii
organization: Virginia Tech, Blacksburg, Virginia
mime-version: 1.0
newsgroups: aus.computers.linux
nntp-posting-user: jspeter
x-mailer: Mozilla 2.0b3 (X11; I; Linux 1.3.44 i586)