31 #include <OgreResourceGroupManager.h>
36 const float SoundScriptInstance::PITCHDOWN_FADE_FACTOR = 3.0f;
37 const float SoundScriptInstance::PITCHDOWN_CUTOFF_FACTOR = 5.0f;
39 const SoundPtr SoundScriptInstance::SOUNDPTR_NULL;
41 SoundScriptManager::SoundScriptManager() :
45 , max_distance(500.0f)
46 , rolloff_factor(1.0f)
47 , reference_distance(7.5f)
48 , sound_manager(nullptr)
80 LOG(
"SoundScriptManager: Failed to create the Sound Manager");
88 LOG(
"SoundScriptManager: Sound Manager is disabled");
94 ResourceGroupManager::getSingleton()._registerScriptLoader(
this);
149 state_map[linkType][linkItemID][actor_id][trig] =
true;
177 if (!
getTrigState(actor_id, trig, linkType, linkItemID))
180 state_map[linkType][linkItemID][actor_id][trig] =
false;
207 if (!
getTrigState(actor_id, trig, linkType, linkItemID))
210 state_map[linkType][linkItemID][actor_id][trig] =
false;
239 trigStop(actor_id, trig, linkType, linkItemID);
241 trigStart(actor_id, trig, linkType, linkItemID);
260 return state_map[linkType][linkItemID][actor_id][trig];
289 gain = std::max(0.0f, gain);
290 gain = std::min(gain, 1.0f);
302 pitch = std::max(0.0f, pitch);
314 static Vector3 lastCameraPosition;
315 Vector3 cameraSpeed = (cam_node->getPosition() - lastCameraPosition) / dt_sec;
316 lastCameraPosition = cam_node->getPosition();
347 LOG(
"SoundScriptManager::createTemplate(): SoundScript with name [" + name +
"] already exists, skipping...");
460 if (pitchesPos != -1)
478 std::vector<String> vecparams;
480 LOG(
"SoundScriptManager: Parsing script "+stream->getName());
482 while (!stream->eof())
486 if (!(line.length() == 0 || line.substr(0, 2) ==
"//"))
492 LOG(
"SoundScriptManager: creating template "+line);
497 LOG(
"SoundScriptManager: Error, this sound script is already defined: "+line);
517 Ogre::StringVector veclineparams = StringUtil::split(line,
"\t ", 0);
521 LOG(
"Bad SoundScript attribute line: '" + line +
"' in " + stream->getName());
533 while (!stream->eof() && line !=
"}")
535 line = stream->getLine();
543 while (!stream->eof() && line !=
"{")
545 line = stream->getLine();
560 base_template(baseTemplate)
561 , file_name(filename)
562 , group_name(groupname)
564 , gain_multiplier(1.0f)
568 , has_start_sound(false)
569 , has_stop_sound(false)
571 , pitch_multiplier(1.0f)
575 , start_sound_pitch(0.0f)
576 , stop_sound_pitch(0.0f)
587 if (vec[0] == String(
"trigger_source"))
591 if (vec[1] == String(
"engine"))
596 if (vec[1] == String(
"aeroengine1"))
601 if (vec[1] == String(
"aeroengine2"))
606 if (vec[1] == String(
"aeroengine3"))
611 if (vec[1] == String(
"aeroengine4"))
616 if (vec[1] == String(
"aeroengine5"))
621 if (vec[1] == String(
"aeroengine6"))
626 if (vec[1] == String(
"aeroengine7"))
631 if (vec[1] == String(
"aeroengine8"))
636 if (vec[1] == String(
"horn"))
641 if (vec[1] == String(
"brake"))
646 if (vec[1] == String(
"pump"))
651 if (vec[1] == String(
"starter"))
656 if (vec[1] == String(
"turbo_BOV"))
661 if (vec[1] == String(
"turbo_waste_gate"))
666 if (vec[1] == String(
"turbo_back_fire"))
671 if (vec[1] == String(
"always_on"))
676 if (vec[1] == String(
"repair"))
681 if (vec[1] == String(
"air"))
686 if (vec[1] == String(
"gpws_ap_disconnect"))
691 if (vec[1] == String(
"gpws_10"))
696 if (vec[1] == String(
"gpws_20"))
701 if (vec[1] == String(
"gpws_30"))
706 if (vec[1] == String(
"gpws_40"))
711 if (vec[1] == String(
"gpws_50"))
716 if (vec[1] == String(
"gpws_100"))
721 if (vec[1] == String(
"gpws_pull_up"))
726 if (vec[1] == String(
"gpws_minimums"))
731 if (vec[1] == String(
"air_purge"))
736 if (vec[1] == String(
"shift"))
741 if (vec[1] == String(
"gear_slide"))
751 if (vec[1] == String(
"break"))
756 if (vec[1] == String(
"screetch"))
761 if (vec[1] == String(
"parking_brake"))
766 if (vec[1] == String(
"antilock"))
771 if (vec[1] == String(
"tractioncontrol"))
776 if (vec[1] == String(
"afterburner1"))
781 if (vec[1] == String(
"afterburner2"))
786 if (vec[1] == String(
"afterburner3"))
791 if (vec[1] == String(
"afterburner4"))
796 if (vec[1] == String(
"afterburner5"))
801 if (vec[1] == String(
"afterburner6"))
806 if (vec[1] == String(
"afterburner7"))
811 if (vec[1] == String(
"afterburner8"))
816 if (vec[1] == String(
"avionic_chat_01"))
821 if (vec[1] == String(
"avionic_chat_02"))
826 if (vec[1] == String(
"avionic_chat_03"))
831 if (vec[1] == String(
"avionic_chat_04"))
836 if (vec[1] == String(
"avionic_chat_05"))
841 if (vec[1] == String(
"avionic_chat_06"))
846 if (vec[1] == String(
"avionic_chat_07"))
851 if (vec[1] == String(
"avionic_chat_08"))
856 if (vec[1] == String(
"avionic_chat_09"))
861 if (vec[1] == String(
"avionic_chat_10"))
866 if (vec[1] == String(
"avionic_chat_11"))
871 if (vec[1] == String(
"avionic_chat_12"))
876 if (vec[1] == String(
"avionic_chat_13"))
881 if (vec[1] == String(
"aoa_horn"))
886 if (vec[1] == String(
"ignition"))
891 if (vec[1] == String(
"reverse_gear"))
896 if (vec[1] == String(
"turn_signal"))
901 if (vec[1] == String(
"turn_signal_tick"))
906 if (vec[1] == String(
"turn_signal_warn_tick"))
911 if (vec[1] == String(
"linked_command"))
916 if (vec[1] == String(
"main_menu"))
925 if (vec[0] == String(
"pitch_source"))
938 if (vec[0] == String(
"pitch_factors"))
951 if (vec[0] == String(
"gain_source"))
964 if (vec[0] == String(
"gain_factors"))
977 if (vec[0] == String(
"start_sound"))
987 if (vec[0] == String(
"stop_sound"))
997 if (vec[0] == String(
"sound"))
1025 if (str == String(
"none"))
1027 if (str == String(
"engine_rpm"))
1029 if (str == String(
"turbo_rpm"))
1031 if (str == String(
"aeroengine1_rpm"))
1033 if (str == String(
"aeroengine2_rpm"))
1035 if (str == String(
"aeroengine3_rpm"))
1037 if (str == String(
"aeroengine4_rpm"))
1039 if (str == String(
"aeroengine5_rpm"))
1041 if (str == String(
"aeroengine6_rpm"))
1043 if (str == String(
"aeroengine7_rpm"))
1045 if (str == String(
"aeroengine8_rpm"))
1047 if (str == String(
"wheel_speed_kmph"))
1049 if (str == String(
"injector_ratio"))
1051 if (str == String(
"torque_nm"))
1053 if (str == String(
"gearbox_rpm"))
1055 if (str == String(
"creak"))
1057 if (str == String(
"break"))
1059 if (str == String(
"screetch"))
1061 if (str == String(
"pump_rpm"))
1063 if (str == String(
"aeroengine1_throttle"))
1065 if (str == String(
"aeroengine2_throttle"))
1067 if (str == String(
"aeroengine3_throttle"))
1069 if (str == String(
"aeroengine4_throttle"))
1071 if (str == String(
"aeroengine5_throttle"))
1073 if (str == String(
"aeroengine6_throttle"))
1075 if (str == String(
"aeroengine7_throttle"))
1077 if (str == String(
"aeroengine8_throttle"))
1079 if (str == String(
"air_speed_knots"))
1081 if (str == String(
"angle_of_attack_degree"))
1083 if (str == String(
"linked_command_rate"))
1085 if (str == String(
"music_volume"))
1095 , instance_name(instancename)
1097 , sound_manager(sound_manager)
1098 , sound_link_type(soundLinkType)
1099 , sound_link_item_id(soundLinkItemId)
1101 , start_sound_pitchgain(0.0f)
1103 , stop_sound_pitchgain(0.0f)
1125 LOG(
"SoundScriptInstance: instance created: "+instancename);
1204 for (
int i = 0; i < low; i++)
1268 if (sourcepitch == 0.0f)
1367 if (
sounds[i]->isPlaying())
1459 #endif // USE_OPENAL