Ejemplo n.º 1
0
void JamulSoundPurge(void)
{
	int i;

	for (i = 0; i < soundbufSize; i++)
	{
		JamulSoundDestroyBuffer(i);
	}
}
Ejemplo n.º 2
0
void JamulSoundExit(void)
{
	int i;

	if (soundbuf)
	{
		for (i = 0; i < soundbufSize; i++)
			JamulSoundDestroyBuffer(i);
		delete[] soundbuf;
	}
}
Ejemplo n.º 3
0
void JamulSoundPurge(void)
{
	int i;

	for(i=0;i<dsoundBufferCount;i++)
	{
		if(soundHandle[i]!=-1)
		{
			JamulSoundDestroyBuffer(soundHandle[i]);
			soundHandle[i]=-1;
		}
	}
}
Ejemplo n.º 4
0
void JamulSoundExit(void)
{
	int i;
	
	if(soundbuf)
	{
		for(i=0;i<dsoundBufferCount;i++)
			JamulSoundDestroyBuffer(i);
		free(soundbuf);
	}
	free(soundHandle);

	if(dsound)
		dsound->Release();	
	dsound=NULL;
}
Ejemplo n.º 5
0
void GoPlaySound(int num,long pan,long vol,byte flags,int priority)
{
	char txt[32];
	int i,best,count;

	if(soundHandle[num]==-1)
	{
		sprintf(txt,"sound\\snd%03d.wav",num);
		soundHandle[num]=JamulSoundLoad(txt);
		if(soundHandle[num]==-1)
			return;	// can't play the sound, it won't load for some reason
	}

	priority+=vol;	// the quieter a sound, the lower the priority
	if(flags&SND_MAXPRIORITY)
		priority=MAX_SNDPRIORITY;

	if(flags&SND_ONE)
	{
		for(i=0;i<MAX_SOUNDS_AT_ONCE;i++)
			if(playBuffer[i].soundNum==num)
			{
				// if you want to cut it off, or it isn't playing, then start anew
				if((flags&SND_CUTOFF) || (!(playBuffer[i].flags&SND_PLAYING)))
				{
					playBuffer[i].pan=pan;
					playBuffer[i].vol=vol;
					playBuffer[i].flags=flags|SND_PLAYING;
					playBuffer[i].priority=priority;
					JamulSoundPlay(playBuffer[i].dsHandle,playBuffer[i].pan,playBuffer[i].vol,SOUND_CUTOFF);
					return;	// good job
				}
				else
					return;	// can't be played because can't cut it off
			}
		// if you fell through to here, it isn't playing, so go ahead as normal
	}
	if(flags&SND_FEW)
	{
		count=0;
		for(i=0;i<MAX_SOUNDS_AT_ONCE;i++)
			if(playBuffer[i].soundNum==num && (playBuffer[i].flags&SND_PLAYING))
				count++;
		
		if(count>=MAX_FEW_SOUNDS)
		{
			for(i=0;i<MAX_SOUNDS_AT_ONCE;i++)
				if(playBuffer[i].soundNum==num)
				{
					if((flags&SND_CUTOFF) && (playBuffer[i].flags&SND_PLAYING))
					{
						playBuffer[i].pan=pan;
						playBuffer[i].vol=vol;
						playBuffer[i].flags=flags|SND_PLAYING;
						playBuffer[i].priority=priority;
						JamulSoundPlay(playBuffer[i].dsHandle,playBuffer[i].pan,playBuffer[i].vol,SOUND_CUTOFF);
						return;	// good job
					}
				}
			return;	// failed for some reason
		}
	}
	best=-1;
	for(i=0;i<MAX_SOUNDS_AT_ONCE;i++)
	{
		if(playBuffer[i].soundNum==-1 || (!(playBuffer[i].flags&SND_PLAYING)))
		{
			best=i;
			break;	// can't beat that
		}
		if((playBuffer[i].priority<priority) || (playBuffer[i].soundNum==num && (flags&SND_CUTOFF)))
		{
			if(best==-1 || playBuffer[i].priority<playBuffer[best].priority)
				best=i;
		}
	}
	if(best==-1)
		return;	// sound is not worthy to be played

	if(playBuffer[best].soundNum!=num)	// if it was already playing that sound, don't waste time
	{
		playBuffer[best].soundNum=num;
		if(playBuffer[best].dsHandle!=-1)
		{
			JamulSoundDestroyBuffer(playBuffer[best].dsHandle);	// slash & burn
		}
		playBuffer[best].dsHandle=JamulSoundCopy(soundHandle[num]);
	}
	else
	{
		JamulSoundRewind(playBuffer[best].dsHandle);
	}

	if(playBuffer[best].dsHandle==-1)
		return;	// can't play it
	playBuffer[best].priority=priority;
	playBuffer[best].pan=pan;
	playBuffer[best].vol=vol;
	playBuffer[best].flags=flags|SND_PLAYING;

	JamulSoundPlay(playBuffer[best].dsHandle,playBuffer[best].pan,playBuffer[best].vol,0);
}