--- Begin Message ---
- To: n.bailey@elec.gla.ac.uk
- Subject: Program only runns when esd is unnice
- From: ""Greg Mitchell <9704159m\"@student.gla.ac.uk>"
- Date: Fri, 24 Nov 2000 17:54:31 +0000
- Message-id: <3A1EAB57.E911B981@student.gla.ac.uk>
The following source runs fine on a (very old) i386 box, but won't work
without interruptions in the sound generated on the Mac G4s in the Music
Technology lab. Can you see what is going on?
Greg.
#include <esd.h>
#include "sine.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/soundcard.h>
int main()
{
int count;
int out_sock;
int play_format = ESD_MONO | ESD_BITS16 | ESD_STREAM | ESD_PLAY;
short table[88200];
short *cycle;
gen(table);
/* tries to use esd uses /dev/dsp if necessary*/
out_sock = esd_play_stream_fallback(play_format,
44100,
NULL,
"sinewave ");
if (out_sock <= 0)
{
fprintf(stderr,"oh dear, its broken");
}
else
{
printf("%d\n",write(out_sock, table ,88200*sizeof(short) ));
}
close (out_sock);
}
void gen(short *cycle);
#include <stdio.h>
#include <math.h>
void gen(short *cycle)
{
int count;
double wave;
for(count=0;count<88200;count++)
{
wave = sin(fmod((count*M_PI)/50,(2*M_PI)));
*cycle=30000*(wave);
/* printf (" %i\n ",*cycle)*/;
cycle++;
}
}
--- End Message ---