Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Nov 1996 15:06:36 -0500 (EST)
From:      "John S. Dyson" <toor@dyson.iquest.net>
To:        langfod@dihelix.com (David Langford)
Cc:        toor@dyson.iquest.net, freebsd-multimedia@freebsd.org
Subject:   Re: Stereo RealAudio for FreeBSD!
Message-ID:  <199611232006.PAA05891@dyson.iquest.net>
In-Reply-To: <199611231959.JAA00839@localhost.my.domain> from "David Langford" at Nov 23, 96 09:59:53 am

next in thread | previous in thread | raw e-mail | index | archive | help
>
> OKay I forgot about branding....
> Still cannot get either version of the encoder to work for me.
> Realaudio folks seem to have forgotten to put LTA support into
> the Elf version and the a.out version gives me:
> 
I haven't been using the real-time capabilities, but have been recording
with a very simple program below onto disk:  (There are more sophisticated
ways also -- but I like very very simple tools.)


#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <machine/soundcard.h>


#define DSP "/dev/dsp"

int dspfd;
int filefd;

main(int argc, char *argv[]) {
	char buffer[256];
	int readcount;
	int toread;
	int parm;

	dspfd = open(DSP, O_RDONLY);
	if (dspfd < 0) {
		perror("dspopen");
		exit(1);
	}

	parm = 16;
	if (ioctl(dspfd, SOUND_PCM_READ_BITS, &parm)) {
		perror("ioctlrd16");
		exit(1);
	}

	parm = 16;
	if (ioctl(dspfd, SOUND_PCM_WRITE_BITS, &parm)) {
		perror("ioctlwr16");
		exit(1);
	}

	parm = 2;
	if (ioctl(dspfd, SOUND_PCM_READ_CHANNELS, &parm)) {
		perror("ioctlrd2");
		exit(1);
	}

	parm = 2;
	if (ioctl(dspfd, SOUND_PCM_WRITE_CHANNELS, &parm)) {
		perror("ioctlwr2");
		exit(1);
	}

	parm = 44100;
	if (ioctl(dspfd, SOUND_PCM_READ_RATE, &parm)) {
		perror("ioctlsp44100");
		exit(1);
	}

	parm = 44100;
	if (ioctl(dspfd, SOUND_PCM_WRITE_RATE, &parm)) {
		perror("ioctlsp44100");
		exit(1);
	}

	filefd = dup(1);

	toread = atoi(argv[1]) * 44100 * 4;
	fprintf(stderr,"%d samples\n", toread);
	while ( toread > 0) {
		readcount = sizeof buffer;
		if (readcount > toread)
			readcount = toread;
		readcount = read(dspfd, buffer, readcount);
		if (readcount < 0) {
			perror("dspread");
			exit(1);
		}		
		write(filefd, buffer, readcount);
		toread -= readcount;
	}

	exit(0);
}




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611232006.PAA05891>