예제 #1
0
PanTrackNode::~PanTrackNode() {
	SideFX *fx = _engine->getScriptManager()->getSideFX(_slot);
	if (fx && fx->getType() == SIDEFX_AUDIO) {
		MusicNodeBASE *mus = (MusicNodeBASE *)fx;
		mus->unsetPanTrack();
	}
}
예제 #2
0
PanTrackNode::~PanTrackNode() {
	ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_slot);
	if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
		MusicNodeBASE *mus = (MusicNodeBASE *)fx;
		mus->unsetPanTrack();
	}
}
예제 #3
0
bool ActionAttenuate::execute() {
	ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key);
	if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
		MusicNodeBASE *mus = (MusicNodeBASE *)fx;
		mus->setVolume(255 * (10000 - abs(_attenuation)) / 10000 );
	}
	return true;
}
예제 #4
0
PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
	: ScriptingEffect(engine, key, SCRIPTING_EFFECT_PANTRACK) {
	_slot = slot;

	ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(slot);
	if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
		MusicNodeBASE *mus = (MusicNodeBASE *)fx;
		mus->setPanTrack(pos);
	}
}
예제 #5
0
PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
	: SideFX(engine, key, SIDEFX_PANTRACK) {
	_slot = slot;

	SideFX *fx = _engine->getScriptManager()->getSideFX(slot);
	if (fx && fx->getType() == SIDEFX_AUDIO) {
		MusicNodeBASE *mus = (MusicNodeBASE *)fx;
		mus->setPanTrack(pos);
	}
}
예제 #6
0
bool PanTrackNode::process(uint32 deltaTimeInMillis) {
	ScriptManager * scriptManager = _engine->getScriptManager();
	ScriptingEffect *fx = scriptManager->getSideFX(_slot);
	if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
		MusicNodeBASE *mus = (MusicNodeBASE *)fx;

		int curPos = scriptManager->getStateValue(StateKey_ViewPos);
		int16 _width = _engine->getRenderManager()->getBkgSize().x;
		int16 _halfWidth = _width / 2;
		int16 _quarterWidth = _width / 4;

		int tmp = 0;
		if (curPos <= _position)
			tmp = _position - curPos;
		else
			tmp = _position - curPos + _width;

		int balance = 0;

		if (tmp > _halfWidth)
			tmp -= _width;

		if (tmp > _quarterWidth) {
			balance = 1;
			tmp = _halfWidth - tmp;
		} else if (tmp < -_quarterWidth) {
			balance = -1;
			tmp = -_halfWidth - tmp;
		}

		// Originally it's value -90...90 but we use -127...127 and therefore 360 replaced by 508
		mus->setBalance( (508 * tmp) / _width );

		tmp = (360 * tmp) / _width;

		int deltaVol = balance;

		// This value sets how fast volume goes off than sound source back of you
		// By this value we can hack some "bugs" have place in originall game engine like beat sound in ZGI-dc10
		int volumeCorrection = 2;

		if (_engine->getGameId() == GID_GRANDINQUISITOR) {
			if (scriptManager->getCurrentLocation() == "dc10")
				volumeCorrection = 5;
		}

		if (deltaVol != 0)
			deltaVol = (mus->getVolume() * volumeCorrection) * (90 - tmp * balance) / 90;
		if (deltaVol > 255)
			deltaVol = 255;

		mus->setDeltaVolume(deltaVol);
	}
	return false;
}
예제 #7
0
bool ActionCrossfade::execute() {
	if (_keyOne) {
		ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyOne);
		if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
			MusicNodeBASE *mus = (MusicNodeBASE *)fx;
			if (_oneStartVolume >= 0)
				mus->setVolume((_oneStartVolume * 255) / 100);

			mus->setFade(_timeInMillis, (_oneEndVolume * 255) / 100);
		}
	}

	if (_keyTwo) {
		ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyTwo);
		if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
			MusicNodeBASE *mus = (MusicNodeBASE *)fx;
			if (_twoStartVolume >= 0)
				mus->setVolume((_twoStartVolume * 255) / 100);

			mus->setFade(_timeInMillis, (_twoEndVolume * 255) / 100);
		}
	}
	return true;
}