コード例 #1
0
ファイル: s_fmod.c プロジェクト: HipsterLion/SRB2
//Copy rel chan
static INT32 relcopy(INT32 handle)
{
	FSOUND_SAMPLE *fmsample = NULL;
	INT32 chan = -1;
	float pos[3];
	float vel[3];

	if (!FSOUND_3D_GetAttributes(handle,&pos[0],&vel[0]))
		if (FSOUND_GetError() != FMOD_ERR_NONE) DBG_Printf("FMOD(relcopy, FSOUND_3D_GetAttributes, Channel # %i): %s\n",handle,FMOD_ErrorString(FSOUND_GetError()));

	fmsample = FSOUND_GetCurrentSample(handle);

	if (fmsample)
	{
#ifdef REL2D
		if (!FSOUND_Sample_SetMode(fmsample, FSOUND_2D))
			DBG_Printf("FMOD(relcopy, FSOUND_Sample_SetMode, handle# %i): %s\n",handle,FMOD_ErrorString(FSOUND_GetError()));
#endif
		chan = FSOUND_PlaySoundEx(FSOUND_FREE,fmsample,NULL,true);

		if (chan == -1)
		{
			if (FSOUND_GetError() != FMOD_ERR_NONE) DBG_Printf("FMOD(relcopy, FSOUND_PlaySoundEx, handle# %i): %s\n",handle,FMOD_ErrorString(FSOUND_GetError()));
			return FSOUND_FREE;
		}
#ifdef MORESTUFF
		else
			DBG_Printf("FMOD(relcopy, Main): Copy Handle#%i to channel#%i\n",handle,chan);
#endif
	}
	else
	{
		if (FSOUND_GetError() != FMOD_ERR_NONE)
			DBG_Printf("FMOD(relcopy, FSOUND_GetCurrentSample, handle# %i): %s\n",handle,FMOD_ErrorString(FSOUND_GetError()));
		chan = FSOUND_PlaySoundEx(FSOUND_FREE,blankfmsample,NULL,true);
		//return FSOUND_FREE;
	}

	if (FSOUND_GetCurrentSample(chan))
	{

		if (!FSOUND_SetCurrentPosition(chan, 0))
			DBG_Printf("FMOD(relcopy, FSOUND_SetCurrentPosition, handle#%i, channel# %i): %s\n",handle,chan,FMOD_ErrorString(FSOUND_GetError()));
#ifndef REL2D
		if (!FSOUND_3D_SetAttributes(chan,pos,vel))
			DBG_Printf("FMOD(relcopy, FSOUND_3D_SetAttributes, handle#%i, channel#%i): %s\n",handle,chan,FMOD_ErrorString(FSOUND_GetError()));
#endif
/*
		if (!FSOUND_SetReserved(chan, TURE))
			DBG_Printf("FMOD(relcopy, FSOUND_SetReserved, handle#%i, channel# %i): %s\n",handle,chan,FMOD_ErrorString(FSOUND_GetError()));
*/
		return chan;
	}

	return FSOUND_FREE;
}
コード例 #2
0
ファイル: s_fmod.c プロジェクト: HipsterLion/SRB2
/******************************************************************************
 *
 * Creates 2D (stereo) source
 *
 ******************************************************************************/
EXPORT INT32 HWRAPI (Add2DSource) (sfx_data_t *sfx)
{
	FSOUND_SAMPLE *fmsample = NULL;
	INT32 chan = -1;

	if (!sfx)
		return chan;

	fmsample = FSOUND_Sample_Load(FSOUND_FREE, INT2CHAR(sfx->data), FSOUND_DOOMLOAD, SFXLENGTH);

	if (fmsample)
	{
		if (!FSOUND_Sample_SetDefaults(fmsample,
		 (INT32)((float)(*((UINT16 *)sfx->data+1)) * recalc_pitch(sfx->pitch)),
		 sfx->volume == -1 ? 255 : sfx->volume,
		 sfx->sep == NORMAL_SEP ? FSOUND_STEREOPAN : sfx->sep,
		 sfx->priority))
			DBG_Printf("FMOD(Add2DSource, FSOUND_Sample_SetDefaults, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError()));

		if (!FSOUND_Sample_SetMode(fmsample,FSOUND_2D))
			DBG_Printf("FMOD(Add2DSource, FSOUND_Sample_SetMode, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError()));

		chan = FSOUND_PlaySoundEx(FSOUND_FREE,fmsample,NULL,true);

		if (chan == -1)
		{
			DBG_Printf("FMOD(Add2DSource, FSOUND_PlaySoundEx, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError()));
			return chan;
		}
#ifdef MORESTUFF
		else DBG_Printf("FMOD(Add2DSource, FSOUND_PlaySoundEx): sfxid# %i is playing on channel %i\n", sfx->id,chan);
#endif
	}
	else
	{
		DBG_Printf("FMOD(Add2DSource,FSOUND_Sample_Load, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError()));
		return chan;
	}

	if (FSOUND_GetCurrentSample(chan))
	{
		if (!FSOUND_SetCurrentPosition(chan, 0))
			DBG_Printf("FMOD(Add2DSource, FSOUND_SetCurrentPosition, channel %i, sfxid# %i): %s\n", chan,sfx->id,FMOD_ErrorString(FSOUND_GetError()));
	}

	return chan;
}
コード例 #3
0
void LLAudioChannelFMOD::playSynced(LLAudioChannel *channelp)
{
	LLAudioChannelFMOD *fmod_channelp = (LLAudioChannelFMOD*)channelp;
	if (!(fmod_channelp->mChannelID && mChannelID))
	{
		// Don't have channels allocated to both the master and the slave
		return;
	}

	U32 position = FSOUND_GetCurrentPosition(fmod_channelp->mChannelID) % mCurrentBufferp->getLength();
	// Try to match the position of our sync master
	if (!FSOUND_SetCurrentPosition(mChannelID, position))
	{
		llwarns << "LLAudioChannelFMOD::playSynced unable to set current position" << llendl;
	}

	// Start us playing
	play();
}
コード例 #4
0
ファイル: s_fmod.c プロジェクト: HipsterLion/SRB2
EXPORT INT32 HWRAPI (Add3DSource) (source3D_data_t *src, sfx_data_t *sfx)
{
	FSOUND_SAMPLE *fmsample = NULL;
	INT32 chan = -1;
	float pos[3];
	float vel[3];
#ifdef MORESTUFF
	src->min_distance = MIN_DISTANCE;
	src->max_distance = MAX_DISTANCE;
#endif

	pos[0] = src->pos.x;
	pos[1] = src->pos.z;
	pos[2] = src->pos.y;
	vel[0] = src->pos.momx;
	vel[1] = src->pos.momz;
	vel[2] = src->pos.momy;
	if (sfx)
		fmsample = FSOUND_Sample_Load(FSOUND_FREE, INT2CHAR(sfx->data), FSOUND_DOOMLOAD, SFXLENGTH);
	else
		fmsample = blankfmsample;

	if (fmsample)
	{
		if (sfx && !FSOUND_Sample_SetDefaults(fmsample,
				(INT32)((*((UINT16 *)sfx->data+1))*recalc_pitch(sfx->pitch)),
				(sfx->volume == -1 ? 255 : sfx->volume),
				(sfx->sep == NORMAL_SEP ? FSOUND_STEREOPAN : sfx->sep),
				(sfx->priority)
				)
			)
			DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_SetDefaults, SFX's ID# %i): %s\n",  sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError()));
#if 0
		if (!FSOUND_Sample_SetMinMaxDistance(fmsample, src->min_distance, src->max_distance))
			DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_SetMinMaxDistance, SFX's ID# %i): %s\n", sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError()));
#endif
		chan = FSOUND_PlaySoundEx(FSOUND_FREE,fmsample,NULL,true);

		if (chan == -1)
		{
			DBG_Printf("FMOD(Add3DSource, FSOUND_PlaySoundEx, SFX's ID# %i): %s\n",sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError()));
			return chan;
		}
		else
		{
			if (!sfx)
				DBG_Printf("FMOD(Add3DSource, Main): Added blank-sound added to channel %i\n",chan);
#ifdef MORESTUFF
			else DBG_Printf("FMOD(Add3DSource, Main): Added sfxid# %i added to channel %i\n",sfx->id,chan);
#endif
		}
	}
	else
	{
		if (sfx)
			DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_Load, sfxid# %i): %s\n",sfx->id,FMOD_ErrorString(FSOUND_GetError()));
		else
			DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_Alloc): %s\n", FMOD_ErrorString(FSOUND_GetError()));

		return chan;
	}

	if (FSOUND_GetCurrentSample(chan))
	{
		if (!FSOUND_SetCurrentPosition(chan, 0))
			DBG_Printf("FMOD(Add3DSource, FSOUND_SetCurrentPosition, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError()));

		if (!FSOUND_3D_SetAttributes(chan,pos,vel))
			DBG_Printf("FMOD(Add3DSource, FSOUND_3D_SetAttributes, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError()));

		if (!FSOUND_SetReserved(chan, (signed char)src->permanent))
			DBG_Printf("FMOD(Add3DSource, FSOUND_SetReserved, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError()));

		if (src->head_relative) reladd(chan);
	}

	return chan;
}