[comp.sys.mac.programmer] Help with Sound

bvsy@vax5.CIT.CORNELL.EDU (05/11/89)

Howdy,
	I'm working on a public domain version of
Tetrix and wanted to include some sounds in the game.
The following is my attempt at making some noise.  It runs
fine on the first try, but hangs the machine on
the second run (it plays the sound on the second run tho).

#include<SoundDvr.h>
#define MAXTONES 	256
main()
{
	SWSynthRec *s;
	long	bufsize;
	int i;
	
	bufsize=MAXTONES*sizeof(Tone)+sizeof(int);
	s=(SWSynthRec *)NewPtr(bufsize);
	
	s->mode = swMode;	
	for(i=0;i<MAXTONES;i++){
		s->triplets[i].count=500;
		s->triplets[i].amplitude=250-i/2;
		s->triplets[i].duration=1;
	}
	i--;
	s->triplets[i].count=0;
	s->triplets[i].amplitude=0;
	s->triplets[i].duration=0;
	
	StartSound(s,bufsize,-1L);
}