コード例 #1
0
void CSoundAnimMarker::play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundContext &context)
{
	TMarkerSoundSet::iterator first(_Sounds.begin()), last(_Sounds.end());

	for (; first != last; ++first)
	{
		USource* source = mixer->createSource((*first), true, NULL, NULL, cluster, &context);
		if (source != NULL)
		{
			source->setRelativeGain(context.RelativeGain);
			source->setPos(context.Position);
			source->play();
		}
	}
}
コード例 #2
0
/*
 * Adding a source
 */
USource *OnAddSource( const char *name, float x, float y, float z )
{
	/*
	 * Create a source with sound 'name', and set some of its initial properties, if successful
	 */
	USource *source = AudioMixer->createSource( CStringMapper::map(name) );
	if ( source != NULL )
	{
		source->setPos( CVector(x,y,z) );

		/* The initial gain, pitch and looping state are stored
		 * in the "source sounds file".
		 */
		source->setLooping(true);
		source->play(); // start playing immediately
	}
	else
	{
		nlwarning( "Sound '%s' not found", name );
	}
	return source;
}