Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CF: Sound effects for SGI IRIX



Add -DNEW_SOUND to CFLAGS and -lm -laudio to SND_LIBS in the client Makefile,
then apply the following changes to cfsndserv.c:

13a14
> #define SGI_SOUND
36a38,39
> #elif defined(SGI_SOUND)
> #include <audio.h>
347a351,421
> 
> #elif defined(SGI_SOUND)
> 
> ALconfig	soundconfig;
> ALport	soundport;
> 
> int init_audio()
> {
> 	long		params[2];
> 	
> 	/* Allocate ALconfig structure. */
> 	
> 	if ((soundconfig=ALnewconfig())==0)
> 	{
> 		fprintf(stderr,"Could not allocate ALconfig structure.\n");
> 		return -1;
> 	}
> 	
> 	/* Set number of channels */
> 	
> 	if (ALsetchannels(soundconfig,(stereo=settings.stereo)?2:1)==-1)
> 	{
> 		fprintf(stderr,"Could not set number of channels.\n");
> 		return -1; 
> 	}
> 	
> 	/* Set sample format */
> 	
> 	if (ALsetsampfmt(soundconfig,AL_SAMPFMT_TWOSCOMP)==-1)
> 	{
> 		fprintf(stderr,"Could not set audio sample format.\n");
> 		return -1; 
> 	}
> 	sign=1;
> 	
> 	/* Set sample width */
> 	
> 	if (ALsetwidth(soundconfig,(bit8=settings.bit8)?AL_SAMPLE_8:AL_SAMPLE_16)==-1)
> 	{
> 		fprintf(stderr,"Could not set audio sample width.\n");
> 		return -1;
> 	}
> 	sample_size=(stereo?2:1)*(bit8?1:2);
> 	
> 	/* Set frequency */
> 	
> 	params[0]=AL_OUTPUT_RATE;
> 	params[1]=frequency=settings.frequency;
> 	if (ALsetparams(AL_DEFAULT_DEVICE,params,2)==-1)
> 	{
> 		fprintf(stderr,"Could not set output rate of default device.\n");
> 		return -1; 
> 	}
> 	
> 	/* Open audio port */
> 
> 	if ((soundport=ALopenport("cfsndserv port","w",soundconfig))==NULL)
> 	{
> 		fprintf(stderr,"Could not open audio port.\n");
> 		return -1; 
> 	}
> 	soundfd=ALgetfd(soundport);
> 	return 0;
> }
> 
> int audio_play(int buffer,int off)
> {
> 	ALwritesamps(soundport,buffers+settings.buflen*buffer+off,(settings.buflen-off)/sample_size);
> 	return settings.buflen-off;
> }
> 
668a743,751
> #if defined(SGI_SOUND)
>       /*
>       The buffer of an audio port can hold 100000 samples. If we allow sounds to
>       be written to the port whenever there is enough room in the buffer, all
>       sounds will be played sequentially, which is wrong. We can set the
>       fillpoint to a high value to prevent this.
>       */
>       ALsetfillpoint(soundport,100000);
> #endif

It should now be possible to make cfclient (with sound enabled) and cfsndserv.

-- 
Paul Mikell
-
[you can put yourself on the announcement list only or unsubscribe altogether
by sending an email stating your wishes to crossfire-request@ifi.uio.no]