Пример #1
0
bool CMusicChannelFMod::playStream()
{
	if (FSOUND_Stream_GetOpenState(_MusicStream) == -3)
	{
		nlwarning("NLSOUND FMod Driver: stream failed to open. (file not found, out of memory or other error)");
		FSOUND_Stream_Close(_MusicStream); _MusicStream = NULL; 
		return false;
	}

	// Start playing
	if ((_MusicChannel = FSOUND_Stream_PlayEx(FSOUND_FREE, _MusicStream, NULL, true)) == -1)
		return false;

	// stereo pan (as reccomended)
	FSOUND_SetPan(_MusicChannel, FSOUND_STEREOPAN);
	// update volume
	int vol255 = (int)(_Gain * 255.0f);
	FSOUND_SetVolumeAbsolute(_MusicChannel, vol255);
	// Set a callback to know if stream has ended
	_CallBackEnded = false;
	FSOUND_Stream_SetEndCallback(_MusicStream, streamEndCallBack, static_cast<void *>(this));
	// unpause
	FSOUND_SetPaused(_MusicChannel, false);

	return true;
}
Пример #2
0
/******************************************************************************
 *
 * Update volume and separation (panning) of 2D source
 *
 *****************************************************************************/
EXPORT void HWRAPI (Update2DSoundParms) (INT32 chan, INT32 vol, INT32 sep)
{
	FSOUND_SAMPLE *fmsample;

	if (chan < 0)
		return;

	fmsample = FSOUND_GetCurrentSample(chan);

	if (fmsample)
	{
		if (!FSOUND_Sample_GetMode(fmsample) & FSOUND_2D)
		{
			DBG_Printf("FMOD(Update2DSoundParms,Main): 2D Vol/Pan on 3D channel %i?\n",chan);
			//return;
		}
	}
	else
		return;

	if (!FSOUND_SetPaused(chan, true))
		DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPaused, Pause, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError()));

	if (!FSOUND_SetVolume(chan,vol))
		DBG_Printf("FMOD(Update2DSoundParms, , channel %i to volume %i): %s\n", chan,vol,FMOD_ErrorString(FSOUND_GetError()));

	if (!FSOUND_SetPan(chan, sep == NORMAL_SEP ? FSOUND_STEREOPAN : sep))
		DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPan, channel %i to sep %i): %s\n", chan,sep,FMOD_ErrorString(FSOUND_GetError()));

	if (!FSOUND_SetPaused(chan, false))
		DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPaused, Resume, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError()));
}
Пример #3
0
///////////////////////////
// Set Pan
/////////////////////////////
int CSound::Setpan(int chan, int pan)
{
	if(pan>255)
		pan = 255;

	if(pan<0)
		pan = 0;

	FSOUND_SetPan(chan, pan);
	return 0;
}
Пример #4
0
void PlayStereoFrequency( short player, short which, short freq )
{
	if( soundOn )
	{
		#ifdef UseSDLMixer
		Mix_PlayChannel(-1, sound[which], 0);
//		Mix_SetPanning(chanHandle, 0, 0);
		#else
		// FMod
		int chanHandle = FSOUND_PlaySoundEx( FSOUND_FREE, sound[which], NULL, true );
		FSOUND_SetPan( chanHandle, player? 255: 0 );
		FSOUND_SetFrequency( chanHandle, (FSOUND_GetFrequency(chanHandle) * (16 + freq)) / 16 );
	    FSOUND_SetPaused( chanHandle, false );
		#endif
	}
}
Пример #5
0
void CSoundManager::Update3D (int x, int y, int Nr)
{
	int   vol, pan;
	float xdiff, ydiff, Abstand;

	xdiff = ((pPlayer[0]->xpos + 45)  - x);
	ydiff = ((pPlayer[0]->ypos + 45)  - y);

	Abstand = float(sqrt((xdiff * xdiff) + (ydiff * ydiff)));

	vol = (int)((100-float(Abstand/6.0f)) / 100.0f * pSoundManager->its_GlobalSoundVolume);

	if (vol < 0)
		vol = 0;
	else

	// neuer Wert ist nicht leiser als der alte?

	{
		// Sound links oder rechts vom Spieler ?
		if (x < pPlayer[0]->xpos + 45)
		{
			pan = 128 - (100 - vol);
			if (pan < 0)
				pan = 0;
		}
		else
		{
			pan = 128 + (100 - vol);
			if (pan > 255)
				pan = 255;
		}

		
		FSOUND_SetVolume (its_Sounds[Nr]->Channel, vol);
		FSOUND_SetPan	 (its_Sounds[Nr]->Channel, 128);		
	}
}
Пример #6
0
bool CSoundManager::PlayWave(int Vol, int Pan, int Freq, int Nr)
{
	if (false == InitSuccessfull)
		return false;

	int Channel;		// Benutzter Channel

	// hört man den Sound überhaupt ?
	//
	if(Vol == 0 ||
		its_GlobalSoundVolume == 0)
		return false;

	if(its_Sounds[Nr] == NULL)
		return false;

	// Sound spielen
	//
	Channel = FSOUND_PlaySound   (FSOUND_FREE, its_Sounds[Nr]->SoundData);

	// Kein freier Channel gefunden ?
	//
	if (Channel == -1)
		return false;

	its_Sounds[Nr]->Channel   = Channel;
	its_Sounds[Nr]->isPlaying = true;;

	// Und Werte für den Channel, in dem er gespielt wird, setzen
	//
	FSOUND_SetFrequency(Channel, Freq);
	FSOUND_SetVolume   (Channel, int(its_GlobalSoundVolume*Vol/100.0f*2.55f));
	FSOUND_SetPan	   (Channel, Pan);

	return true;
} // PlayWave