RigsofRods
Soft-body Physics Simulation
SoundScriptManager.cpp
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5 
6  For more information, see http://www.rigsofrods.org/
7 
8  Rigs of Rods is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License version 3, as
10  published by the Free Software Foundation.
11 
12  Rigs of Rods is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifdef USE_OPENAL
22 
23 #include "SoundScriptManager.h"
24 
25 #include "Actor.h"
26 #include "CameraManager.h"
27 #include "Sound.h"
28 #include "SoundManager.h"
29 #include "Utils.h"
30 
31 #include <OgreResourceGroupManager.h>
32 
33 using namespace Ogre;
34 using namespace RoR;
35 
36 const float SoundScriptInstance::PITCHDOWN_FADE_FACTOR = 3.0f;
37 const float SoundScriptInstance::PITCHDOWN_CUTOFF_FACTOR = 5.0f;
38 
39 const SoundPtr SoundScriptInstance::SOUNDPTR_NULL; // Dummy value to be returned as const reference.
40 
41 SoundScriptManager::SoundScriptManager() :
42  disabled(true)
43  , loading_base(false)
44  , instance_counter(0)
45  , max_distance(500.0f)
46  , rolloff_factor(1.0f)
47  , reference_distance(7.5f)
48  , sound_manager(nullptr)
49 {
50  for (int i = 0; i < SS_MAX_TRIG; i++)
51  {
52  free_trigs[i] = 0;
53  }
54 
55  for (int i = 0; i < SS_MAX_MOD; i++)
56  {
57  free_pitches[i] = 0;
58  free_gains[i] = 0;
59  }
60 
61  // TODO: there is a memory corruption going on here, need to fix
62  for (int i = 0; i < SS_MAX_TRIG * MAX_INSTANCES_PER_GROUP; i++)
63  {
64  trigs[i] = 0;
65  }
66 
67  for (int i = 0; i < SS_MAX_MOD * MAX_INSTANCES_PER_GROUP; i++)
68  {
69  pitches[i] = 0;
70  gains[i] = 0;
71  }
72 
73  // reset all states
74  state_map.clear();
75 
77 
78  if (!sound_manager)
79  {
80  LOG("SoundScriptManager: Failed to create the Sound Manager");
81  return;
82  }
83 
85 
86  if (disabled)
87  {
88  LOG("SoundScriptManager: Sound Manager is disabled");
89  return;
90  }
91 
92  LOG("SoundScriptManager: Sound Manager started with " + TOSTRING(sound_manager->getNumHardwareSources())+" sources");
93  script_patterns.push_back("*.soundscript");
94  ResourceGroupManager::getSingleton()._registerScriptLoader(this);
95 }
96 
98 {
99  if (sound_manager != nullptr)
100  delete sound_manager;
101 }
102 
103 void SoundScriptManager::trigOnce(const ActorPtr& actor, int trig, int linkType, int linkItemID)
104 {
105  if (disabled)
106  return;
107 
108  if (actor)
109  {
110  trigOnce(actor->ar_instance_id, trig, linkType, linkItemID);
111  }
112 }
113 
114 void SoundScriptManager::trigOnce(int actor_id, int trig, int linkType, int linkItemID)
115 {
116  if (disabled)
117  return;
118 
119  for (int i = 0; i < free_trigs[trig]; i++)
120  {
121  // cycle through all instance groups
122  const SoundScriptInstancePtr& inst = trigs[trig + i * SS_MAX_TRIG];
123 
124  if (inst && inst->actor_id == actor_id && inst->sound_link_type == linkType && inst->sound_link_item_id == linkItemID)
125  {
126  inst->runOnce();
127  }
128  }
129 }
130 
131 void SoundScriptManager::trigStart(const ActorPtr& actor, int trig, int linkType, int linkItemID)
132 {
133  if (disabled)
134  return;
135 
136  if (actor)
137  {
138  trigStart(actor->ar_instance_id, trig, linkType, linkItemID);
139  }
140 }
141 
142 void SoundScriptManager::trigStart(int actor_id, int trig, int linkType, int linkItemID)
143 {
144  if (disabled)
145  return;
146  if (getTrigState(actor_id, trig, linkType, linkItemID))
147  return;
148 
149  state_map[linkType][linkItemID][actor_id][trig] = true;
150 
151  for (int i = 0; i < free_trigs[trig]; i++)
152  {
153  const SoundScriptInstancePtr& inst = trigs[trig + i * SS_MAX_TRIG];
154 
155  if (inst && inst->actor_id == actor_id && inst->sound_link_type == linkType && inst->sound_link_item_id == linkItemID)
156  {
157  inst->start();
158  }
159  }
160 }
161 
162 void SoundScriptManager::trigStop(const ActorPtr& actor, int trig, int linkType, int linkItemID)
163 {
164  if (disabled)
165  return;
166 
167  if (actor)
168  {
169  trigStop(actor->ar_instance_id, trig, linkType, linkItemID);
170  }
171 }
172 
173 void SoundScriptManager::trigStop(int actor_id, int trig, int linkType, int linkItemID)
174 {
175  if (disabled)
176  return;
177  if (!getTrigState(actor_id, trig, linkType, linkItemID))
178  return;
179 
180  state_map[linkType][linkItemID][actor_id][trig] = false;
181  for (int i = 0; i < free_trigs[trig]; i++)
182  {
183  const SoundScriptInstancePtr& inst = trigs[trig + i * SS_MAX_TRIG];
184 
185  if (inst && inst->actor_id == actor_id && inst->sound_link_type == linkType && inst->sound_link_item_id == linkItemID)
186  {
187  inst->stop();
188  }
189  }
190 }
191 
192 void SoundScriptManager::trigKill(const ActorPtr& actor, int trig, int linkType, int linkItemID)
193 {
194  if (disabled)
195  return;
196 
197  if (actor)
198  {
199  trigKill(actor->ar_instance_id, trig, linkType, linkItemID);
200  }
201 }
202 
203 void SoundScriptManager::trigKill(int actor_id, int trig, int linkType, int linkItemID)
204 {
205  if (disabled)
206  return;
207  if (!getTrigState(actor_id, trig, linkType, linkItemID))
208  return;
209 
210  state_map[linkType][linkItemID][actor_id][trig] = false;
211  for (int i = 0; i < free_trigs[trig]; i++)
212  {
213  const SoundScriptInstancePtr& inst = trigs[trig + i * SS_MAX_TRIG];
214 
215  if (inst && inst->actor_id == actor_id && inst->sound_link_type == linkType && inst->sound_link_item_id == linkItemID)
216  {
217  inst->kill();
218  }
219  }
220 }
221 
222 void SoundScriptManager::trigToggle(const ActorPtr& actor, int trig, int linkType, int linkItemID)
223 {
224  if (disabled)
225  return;
226 
227  if (actor)
228  {
229  trigToggle(actor->ar_instance_id, trig, linkType, linkItemID);
230  }
231 }
232 
233 void SoundScriptManager::trigToggle(int actor_id, int trig, int linkType, int linkItemID)
234 {
235  if (disabled)
236  return;
237 
238  if (getTrigState(actor_id, trig, linkType, linkItemID))
239  trigStop(actor_id, trig, linkType, linkItemID);
240  else
241  trigStart(actor_id, trig, linkType, linkItemID);
242 }
243 
244 bool SoundScriptManager::getTrigState(const ActorPtr& actor, int trig, int linkType, int linkItemID)
245 {
246  if (disabled)
247  return false;
248 
249  if (actor)
250  return getTrigState(actor->ar_instance_id, trig, linkType, linkItemID);
251  else
252  return false;
253 }
254 
255 bool SoundScriptManager::getTrigState(int actor_id, int trig, int linkType, int linkItemID)
256 {
257  if (disabled)
258  return false;
259 
260  return state_map[linkType][linkItemID][actor_id][trig];
261 }
262 
263 void SoundScriptManager::modulate(const ActorPtr& actor, int mod, float value, int linkType, int linkItemID)
264 {
265  if (disabled)
266  return;
267 
268  if (actor)
269  {
270  modulate(actor->ar_instance_id, mod, value, linkType, linkItemID);
271  }
272 }
273 
274 void SoundScriptManager::modulate(int actor_id, int mod, float value, int linkType, int linkItemID)
275 {
276  if (disabled)
277  return;
278 
279  if (mod >= SS_MAX_MOD)
280  return;
281 
282  for (int i = 0; i < free_gains[mod]; i++)
283  {
284  const SoundScriptInstancePtr& inst = gains[mod + i * SS_MAX_MOD];
285  if (inst && inst->actor_id == actor_id && inst->sound_link_type == linkType && inst->sound_link_item_id == linkItemID)
286  {
287  // this one requires modulation
288  float gain = value * value * inst->templ->gain_square + value * inst->templ->gain_multiplier + inst->templ->gain_offset;
289  gain = std::max(0.0f, gain);
290  gain = std::min(gain, 1.0f);
291  inst->setGain(gain);
292  }
293  }
294 
295  for (int i = 0; i < free_pitches[mod]; i++)
296  {
297  const SoundScriptInstancePtr& inst = pitches[mod + i * SS_MAX_MOD];
298  if (inst && inst->actor_id == actor_id && inst->sound_link_type == linkType && inst->sound_link_item_id == linkItemID)
299  {
300  // this one requires modulation
301  float pitch = value * value * inst->templ->pitch_square + value * inst->templ->pitch_multiplier + inst->templ->pitch_offset;
302  pitch = std::max(0.0f, pitch);
303  inst->setPitch(pitch);
304  }
305  }
306 }
307 
308 void SoundScriptManager::update(float dt_sec)
309 {
310  if (App::sim_state->getEnum<SimState>() == SimState::RUNNING ||
311  App::sim_state->getEnum<SimState>() == SimState::EDITOR_MODE)
312  {
313  Ogre::SceneNode* cam_node = App::GetCameraManager()->GetCameraNode();
314  static Vector3 lastCameraPosition;
315  Vector3 cameraSpeed = (cam_node->getPosition() - lastCameraPosition) / dt_sec;
316  lastCameraPosition = cam_node->getPosition();
317  Ogre::Vector3 upVector = App::GetCameraManager()->GetCameraNode()->getOrientation() * Ogre::Vector3::UNIT_Y;
318  // Direction points down -Z by default (adapted from Ogre::Camera)
319  Ogre::Vector3 cameraDir = App::GetCameraManager()->GetCameraNode()->getOrientation() * -Ogre::Vector3::UNIT_Z;
320  this->setCamera(App::GetCameraManager()->GetCameraNode()->getPosition(), cameraDir, upVector, cameraSpeed);
321  }
322 }
323 
324 void SoundScriptManager::setCamera(Vector3 position, Vector3 direction, Vector3 up, Vector3 velocity)
325 {
326  if (disabled)
327  return;
328  sound_manager->setCamera(position, direction, up, velocity);
329 }
330 
331 const StringVector& SoundScriptManager::getScriptPatterns(void) const
332 {
333  return script_patterns;
334 }
335 
337 {
338  // load late
339  return 1000.0f;
340 }
341 
342 SoundScriptTemplatePtr SoundScriptManager::createTemplate(String name, String groupname, String filename)
343 {
344  // first, search if there is a template name collision
345  if (templates.find(name) != templates.end())
346  {
347  LOG("SoundScriptManager::createTemplate(): SoundScript with name [" + name + "] already exists, skipping...");
348  return nullptr;
349  }
350 
351  SoundScriptTemplatePtr ssi = new SoundScriptTemplate(name, groupname, filename, loading_base);
352  templates[name] = ssi;
353  return ssi;
354 }
355 
356 SoundScriptInstancePtr SoundScriptManager::createInstance(Ogre::String templatename, int actor_id, int soundLinkType, int soundLinkItemId)
357 {
358  //first, search template
359  SoundScriptTemplatePtr templ = NULL;
360 
361  if (templates.find(templatename) == templates.end())
362  {
363  return NULL; // found no template with this name
364  }
365 
366  templ = templates[templatename];
367 
368  if (templ->trigger_source == SS_TRIG_NONE)
369  {
370  return NULL; // invalid template!
371  }
372 
376  {
377  LOG("SoundScriptManager: Reached MAX_INSTANCES_PER_GROUP limit (" + TOSTRING(MAX_INSTANCES_PER_GROUP) + ")");
378  return NULL; // reached limit!
379  }
380 
381  SoundScriptInstancePtr inst = new SoundScriptInstance(actor_id, templ, sound_manager, templ->file_name + "-" + TOSTRING(actor_id) + "-" + TOSTRING(instance_counter), soundLinkType, soundLinkItemId);
382  instances.push_back(inst);
384 
385  // register to lookup tables
386  trigs[templ->trigger_source + free_trigs[templ->trigger_source] * SS_MAX_TRIG] = inst;
387  free_trigs[templ->trigger_source]++;
388 
389  if (templ->gain_source != SS_MOD_NONE)
390  {
391  gains[templ->gain_source + free_gains[templ->gain_source] * SS_MAX_MOD] = inst;
392  free_gains[templ->gain_source]++;
393  }
394  if (templ->pitch_source != SS_MOD_NONE)
395  {
396  pitches[templ->pitch_source + free_pitches[templ->pitch_source] * SS_MAX_MOD] = inst;
397  free_pitches[templ->pitch_source]++;
398  }
399 
400  // SoundTrigger: SS_TRIG_ALWAYSON
401  if (templ->trigger_source == SS_TRIG_ALWAYSON)
402  {
403  inst->start();
404  }
405 
406  return inst;
407 }
408 
410 {
411  // Find lookup table entries
412  int trigsPos = -1;
413  for (int i = 0; i < free_trigs[ssi->templ->trigger_source]; i++)
414  {
415  if (trigs[ssi->templ->trigger_source + i * SS_MAX_TRIG] == ssi)
416  {
417  trigsPos = i;
418  }
419  }
420 
421  int gainsPos = -1;
422  for (int i = 0; i < free_gains[ssi->templ->gain_source]; i++)
423  {
424  if (gains[ssi->templ->gain_source + i * SS_MAX_MOD] == ssi)
425  {
426  gainsPos = i;
427  }
428  }
429 
430  int pitchesPos = -1;
431  for (int i = 0; i < free_gains[ssi->templ->pitch_source]; i++)
432  {
433  if (pitches[ssi->templ->pitch_source + i * SS_MAX_MOD] == ssi)
434  {
435  pitchesPos = i;
436  }
437  }
438 
439  // Erase lookup entries
440  if (trigsPos != -1)
441  {
442  for (int i = trigsPos + 1; i < free_trigs[ssi->templ->trigger_source]; i++)
443  {
444  trigs[ssi->templ->trigger_source + (i - 1) * SS_MAX_TRIG]
445  = trigs[ssi->templ->trigger_source + i * SS_MAX_TRIG];
446  }
448  }
449 
450  if (gainsPos != -1)
451  {
452  for (int i = gainsPos + 1; i < free_gains[ssi->templ->gain_source]; i++)
453  {
454  gains[ssi->templ->gain_source + (i - 1) * SS_MAX_MOD]
455  = gains[ssi->templ->gain_source + i * SS_MAX_MOD];
456  }
457  free_gains[ssi->templ->gain_source]--;
458  }
459 
460  if (pitchesPos != -1)
461  {
462  for (int i = pitchesPos + 1; i < free_pitches[ssi->templ->pitch_source]; i++)
463  {
464  pitches[ssi->templ->pitch_source + (i - 1) * SS_MAX_MOD]
465  = pitches[ssi->templ->pitch_source + i * SS_MAX_MOD];
466  }
468  }
469 
470  // Finally remove the instance from list
471  EraseIf(instances, [ssi](const SoundScriptInstancePtr& instance) { return ssi == instance; });
472 }
473 
474 void SoundScriptManager::parseScript(DataStreamPtr& stream, const String& groupName)
475 {
476  SoundScriptTemplatePtr sst = nullptr;
477  String line = "";
478  std::vector<String> vecparams;
479 
480  LOG("SoundScriptManager: Parsing script "+stream->getName());
481 
482  while (!stream->eof())
483  {
484  line = SanitizeUtf8String(stream->getLine());
485  // ignore comments & blanks
486  if (!(line.length() == 0 || line.substr(0, 2) == "//"))
487  {
488  if (!sst)
489  {
490  // no current SoundScript
491  // so first valid data should be a SoundScript name
492  LOG("SoundScriptManager: creating template "+line);
493  sst = createTemplate(line, groupName, stream->getName());
494  if (!sst)
495  {
496  // there is a name collision for this Sound Script
497  LOG("SoundScriptManager: Error, this sound script is already defined: "+line);
498  skipToNextOpenBrace(stream);
499  skipToNextCloseBrace(stream);
500  continue;
501  }
502  // skip to and over next {
503  skipToNextOpenBrace(stream);
504  }
505  else
506  {
507  // already in a ss
508  if (line == "}")
509  {
510  // finished ss
511  sst = 0;
512  }
513  else
514  {
515  // attribute
516  // split params on space
517  Ogre::StringVector veclineparams = StringUtil::split(line, "\t ", 0);
518 
519  if (!sst->setParameter(veclineparams))
520  {
521  LOG("Bad SoundScript attribute line: '" + line + "' in " + stream->getName());
522  }
523  }
524  }
525  }
526  }
527 }
528 
529 void SoundScriptManager::skipToNextCloseBrace(DataStreamPtr& stream)
530 {
531  String line = "";
532 
533  while (!stream->eof() && line != "}")
534  {
535  line = stream->getLine();
536  }
537 }
538 
539 void SoundScriptManager::skipToNextOpenBrace(DataStreamPtr& stream)
540 {
541  String line = "";
542 
543  while (!stream->eof() && line != "{")
544  {
545  line = stream->getLine();
546  }
547 }
548 
550 {
551  if (state)
553  else
555 }
556 
557 //=====================================================================
558 
559 SoundScriptTemplate::SoundScriptTemplate(String name, String groupname, String filename, bool baseTemplate) :
560  base_template(baseTemplate)
561  , file_name(filename)
562  , group_name(groupname)
563  , free_sound(0)
564  , gain_multiplier(1.0f)
565  , gain_offset(0.0f)
566  , gain_source(SS_MOD_NONE)
567  , gain_square(0.0f)
568  , has_start_sound(false)
569  , has_stop_sound(false)
570  , name(name)
571  , pitch_multiplier(1.0f)
572  , pitch_offset(0.0f)
573  , pitch_source(SS_MOD_NONE)
574  , pitch_square(0.0f)
575  , start_sound_pitch(0.0f)
576  , stop_sound_pitch(0.0f)
577  , trigger_source(SS_TRIG_NONE)
578  , unpitchable(false)
579 {
580 }
581 
582 bool SoundScriptTemplate::setParameter(Ogre::StringVector vec)
583 {
584  if (vec.empty())
585  return false;
586 
587  if (vec[0] == String("trigger_source"))
588  {
589  if (vec.size() < 2)
590  return false;
591  if (vec[1] == String("engine"))
592  {
594  return true;
595  };
596  if (vec[1] == String("aeroengine1"))
597  {
599  return true;
600  };
601  if (vec[1] == String("aeroengine2"))
602  {
604  return true;
605  };
606  if (vec[1] == String("aeroengine3"))
607  {
609  return true;
610  };
611  if (vec[1] == String("aeroengine4"))
612  {
614  return true;
615  };
616  if (vec[1] == String("aeroengine5"))
617  {
619  return true;
620  };
621  if (vec[1] == String("aeroengine6"))
622  {
624  return true;
625  };
626  if (vec[1] == String("aeroengine7"))
627  {
629  return true;
630  };
631  if (vec[1] == String("aeroengine8"))
632  {
634  return true;
635  };
636  if (vec[1] == String("horn"))
637  {
639  return true;
640  };
641  if (vec[1] == String("brake"))
642  {
644  return true;
645  };
646  if (vec[1] == String("pump"))
647  {
649  return true;
650  };
651  if (vec[1] == String("starter"))
652  {
654  return true;
655  };
656  if (vec[1] == String("turbo_BOV"))
657  {
659  return true;
660  };
661  if (vec[1] == String("turbo_waste_gate"))
662  {
664  return true;
665  };
666  if (vec[1] == String("turbo_back_fire"))
667  {
669  return true;
670  };
671  if (vec[1] == String("always_on"))
672  {
674  return true;
675  };
676  if (vec[1] == String("repair"))
677  {
679  return true;
680  };
681  if (vec[1] == String("air"))
682  {
684  return true;
685  };
686  if (vec[1] == String("gpws_ap_disconnect"))
687  {
689  return true;
690  };
691  if (vec[1] == String("gpws_10"))
692  {
694  return true;
695  };
696  if (vec[1] == String("gpws_20"))
697  {
699  return true;
700  };
701  if (vec[1] == String("gpws_30"))
702  {
704  return true;
705  };
706  if (vec[1] == String("gpws_40"))
707  {
709  return true;
710  };
711  if (vec[1] == String("gpws_50"))
712  {
714  return true;
715  };
716  if (vec[1] == String("gpws_100"))
717  {
719  return true;
720  };
721  if (vec[1] == String("gpws_pull_up"))
722  {
724  return true;
725  };
726  if (vec[1] == String("gpws_minimums"))
727  {
729  return true;
730  };
731  if (vec[1] == String("air_purge"))
732  {
734  return true;
735  };
736  if (vec[1] == String("shift"))
737  {
739  return true;
740  };
741  if (vec[1] == String("gear_slide"))
742  {
744  return true;
745  };
746  if (vec[1] == String("creak") && App::audio_enable_creak->getBool())
747  {
749  return true;
750  };
751  if (vec[1] == String("break"))
752  {
754  return true;
755  };
756  if (vec[1] == String("screetch"))
757  {
759  return true;
760  };
761  if (vec[1] == String("parking_brake"))
762  {
764  return true;
765  };
766  if (vec[1] == String("antilock"))
767  {
769  return true;
770  };
771  if (vec[1] == String("tractioncontrol"))
772  {
774  return true;
775  };
776  if (vec[1] == String("afterburner1"))
777  {
779  return true;
780  };
781  if (vec[1] == String("afterburner2"))
782  {
784  return true;
785  };
786  if (vec[1] == String("afterburner3"))
787  {
789  return true;
790  };
791  if (vec[1] == String("afterburner4"))
792  {
794  return true;
795  };
796  if (vec[1] == String("afterburner5"))
797  {
799  return true;
800  };
801  if (vec[1] == String("afterburner6"))
802  {
804  return true;
805  };
806  if (vec[1] == String("afterburner7"))
807  {
809  return true;
810  };
811  if (vec[1] == String("afterburner8"))
812  {
814  return true;
815  };
816  if (vec[1] == String("avionic_chat_01"))
817  {
819  return true;
820  };
821  if (vec[1] == String("avionic_chat_02"))
822  {
824  return true;
825  };
826  if (vec[1] == String("avionic_chat_03"))
827  {
829  return true;
830  };
831  if (vec[1] == String("avionic_chat_04"))
832  {
834  return true;
835  };
836  if (vec[1] == String("avionic_chat_05"))
837  {
839  return true;
840  };
841  if (vec[1] == String("avionic_chat_06"))
842  {
844  return true;
845  };
846  if (vec[1] == String("avionic_chat_07"))
847  {
849  return true;
850  };
851  if (vec[1] == String("avionic_chat_08"))
852  {
854  return true;
855  };
856  if (vec[1] == String("avionic_chat_09"))
857  {
859  return true;
860  };
861  if (vec[1] == String("avionic_chat_10"))
862  {
864  return true;
865  };
866  if (vec[1] == String("avionic_chat_11"))
867  {
869  return true;
870  };
871  if (vec[1] == String("avionic_chat_12"))
872  {
874  return true;
875  };
876  if (vec[1] == String("avionic_chat_13"))
877  {
879  return true;
880  };
881  if (vec[1] == String("aoa_horn"))
882  {
884  return true;
885  };
886  if (vec[1] == String("ignition"))
887  {
889  return true;
890  };
891  if (vec[1] == String("reverse_gear"))
892  {
894  return true;
895  };
896  if (vec[1] == String("turn_signal"))
897  {
899  return true;
900  };
901  if (vec[1] == String("turn_signal_tick"))
902  {
904  return true;
905  };
906  if (vec[1] == String("turn_signal_warn_tick"))
907  {
909  return true;
910  };
911  if (vec[1] == String("linked_command"))
912  {
914  return true;
915  };
916  if (vec[1] == String("main_menu"))
917  {
919  return true;
920  };
921 
922  return false;
923  }
924 
925  if (vec[0] == String("pitch_source"))
926  {
927  if (vec.size() < 2)
928  return false;
929  int mod = parseModulation(vec[1]);
930  if (mod >= 0)
931  {
932  pitch_source = mod;
933  return true;
934  }
935  return false;
936  }
937 
938  if (vec[0] == String("pitch_factors"))
939  {
940  if (vec.size() < 3)
941  return false;
942  pitch_offset = StringConverter::parseReal(vec[1]);
943  pitch_multiplier = StringConverter::parseReal(vec[2]);
944  if (vec.size() == 4)
945  {
946  pitch_square = StringConverter::parseReal(vec[3]);
947  }
948  return true;
949  }
950 
951  if (vec[0] == String("gain_source"))
952  {
953  if (vec.size() < 2)
954  return false;
955  int mod = parseModulation(vec[1]);
956  if (mod >= 0)
957  {
958  gain_source = mod;
959  return true;
960  }
961  return false;
962  }
963 
964  if (vec[0] == String("gain_factors"))
965  {
966  if (vec.size() < 3)
967  return false;
968  gain_offset = StringConverter::parseReal(vec[1]);
969  gain_multiplier = StringConverter::parseReal(vec[2]);
970  if (vec.size() == 4)
971  {
972  gain_square = StringConverter::parseReal(vec[3]);
973  }
974  return true;
975  }
976 
977  if (vec[0] == String("start_sound"))
978  {
979  if (vec.size() < 3)
980  return false;
981  start_sound_pitch = StringConverter::parseReal(vec[1]); // unparsable (e.g. "unpitched") will result in value 0.0
982  start_sound_name = vec[2];
983  has_start_sound = true;
984  return true;
985  }
986 
987  if (vec[0] == String("stop_sound"))
988  {
989  if (vec.size() < 3)
990  return false;
991  stop_sound_pitch = StringConverter::parseReal(vec[1]); // unparsable (e.g. "unpitched") will result in value 0.0
992  stop_sound_name = vec[2];
993  has_stop_sound = true;
994  return true;
995  }
996 
997  if (vec[0] == String("sound"))
998  {
999  if (vec.size() < 3)
1000  return false;
1002  {
1003  LOG("SoundScriptManager: Reached MAX_SOUNDS_PER_SCRIPT limit (" + TOSTRING(MAX_SOUNDS_PER_SCRIPT) + ")");
1004  return false;
1005  }
1006  sound_pitches[free_sound] = StringConverter::parseReal(vec[1]); // unparsable (e.g. "unpitched") will result in value 0.0
1007  if (sound_pitches[free_sound] == 0)
1008  {
1009  unpitchable = true;
1010  }
1012  {
1013  return false;
1014  }
1015  sound_names[free_sound] = vec[2];
1016  free_sound++;
1017  return true;
1018  }
1019 
1020  return false;
1021 }
1022 
1024 {
1025  if (str == String("none"))
1026  return SS_MOD_NONE;
1027  if (str == String("engine_rpm"))
1028  return SS_MOD_ENGINE;
1029  if (str == String("turbo_rpm"))
1030  return SS_MOD_TURBO;
1031  if (str == String("aeroengine1_rpm"))
1032  return SS_MOD_AEROENGINE1;
1033  if (str == String("aeroengine2_rpm"))
1034  return SS_MOD_AEROENGINE2;
1035  if (str == String("aeroengine3_rpm"))
1036  return SS_MOD_AEROENGINE3;
1037  if (str == String("aeroengine4_rpm"))
1038  return SS_MOD_AEROENGINE4;
1039  if (str == String("aeroengine5_rpm"))
1040  return SS_MOD_AEROENGINE5;
1041  if (str == String("aeroengine6_rpm"))
1042  return SS_MOD_AEROENGINE6;
1043  if (str == String("aeroengine7_rpm"))
1044  return SS_MOD_AEROENGINE7;
1045  if (str == String("aeroengine8_rpm"))
1046  return SS_MOD_AEROENGINE8;
1047  if (str == String("wheel_speed_kmph"))
1048  return SS_MOD_WHEELSPEED;
1049  if (str == String("injector_ratio"))
1050  return SS_MOD_INJECTOR;
1051  if (str == String("torque_nm"))
1052  return SS_MOD_TORQUE;
1053  if (str == String("gearbox_rpm"))
1054  return SS_MOD_GEARBOX;
1055  if (str == String("creak"))
1056  return SS_MOD_CREAK;
1057  if (str == String("break"))
1058  return SS_MOD_BREAK;
1059  if (str == String("screetch"))
1060  return SS_MOD_SCREETCH;
1061  if (str == String("pump_rpm"))
1062  return SS_MOD_PUMP;
1063  if (str == String("aeroengine1_throttle"))
1064  return SS_MOD_THROTTLE1;
1065  if (str == String("aeroengine2_throttle"))
1066  return SS_MOD_THROTTLE2;
1067  if (str == String("aeroengine3_throttle"))
1068  return SS_MOD_THROTTLE3;
1069  if (str == String("aeroengine4_throttle"))
1070  return SS_MOD_THROTTLE4;
1071  if (str == String("aeroengine5_throttle"))
1072  return SS_MOD_THROTTLE5;
1073  if (str == String("aeroengine6_throttle"))
1074  return SS_MOD_THROTTLE6;
1075  if (str == String("aeroengine7_throttle"))
1076  return SS_MOD_THROTTLE7;
1077  if (str == String("aeroengine8_throttle"))
1078  return SS_MOD_THROTTLE8;
1079  if (str == String("air_speed_knots"))
1080  return SS_MOD_AIRSPEED;
1081  if (str == String("angle_of_attack_degree"))
1082  return SS_MOD_AOA;
1083  if (str == String("linked_command_rate"))
1085  if (str == String("music_volume"))
1086  return SS_MOD_MUSIC_VOLUME;
1087 
1088  return -1;
1089 }
1090 
1091 //====================================================================
1092 
1093 SoundScriptInstance::SoundScriptInstance(int actor_id, SoundScriptTemplatePtr templ, SoundManager* sound_manager, String instancename, int soundLinkType, int soundLinkItemId) :
1094  actor_id(actor_id)
1095  , instance_name(instancename)
1096  , templ(templ)
1097  , sound_manager(sound_manager)
1098  , sound_link_type(soundLinkType)
1099  , sound_link_item_id(soundLinkItemId)
1100  , start_sound(NULL)
1101  , start_sound_pitchgain(0.0f)
1102  , stop_sound(NULL)
1103  , stop_sound_pitchgain(0.0f)
1104  , lastgain(1.0f)
1105 {
1106  // create sounds
1107  if (templ->has_start_sound)
1108  {
1110  }
1111 
1112  if (templ->has_stop_sound)
1113  {
1115  }
1116 
1117  for (int i = 0; i < templ->free_sound; i++)
1118  {
1120  }
1121 
1122  setPitch(0.0f);
1123  setGain(1.0f);
1124 
1125  LOG("SoundScriptInstance: instance created: "+instancename);
1126 }
1127 
1129 {
1130  if (start_sound)
1131  {
1133 
1134  if (start_sound_pitchgain != 0.0f && templ->start_sound_pitch != 0.0f)
1135  {
1137  }
1138  }
1139 
1140  if (templ->free_sound)
1141  {
1142  // searching the interval
1143  int up = 0;
1144 
1145  for (up = 0; up < templ->free_sound; up++)
1146  {
1147  if (templ->sound_pitches[up] > value)
1148  {
1149  break;
1150  }
1151  }
1152 
1153  if (up == 0)
1154  {
1155  // low sound case
1157 
1158  if (sounds_pitchgain[0] != 0.0f && templ->sound_pitches[0] != 0.0f && sounds[0])
1159  {
1160  sounds[0]->setPitch(value / templ->sound_pitches[0]);
1161  }
1162 
1163  for (int i = 1; i < templ->free_sound; i++)
1164  {
1165  if (templ->sound_pitches[i] != 0.0f)
1166  {
1167  sounds_pitchgain[i] = 0.0f;
1168  // pause?
1169  }
1170  else
1171  {
1172  sounds_pitchgain[i] = 1.0f; // unpitched
1173  }
1174  }
1175  }
1176  else if (up == templ->free_sound)
1177  {
1178  // high sound case
1179  for (int i = 0; i < templ->free_sound - 1; i++)
1180  {
1181  if (templ->sound_pitches[i] != 0.0f)
1182  {
1183  sounds_pitchgain[i] = 0.0f;
1184  // pause?
1185  }
1186  else
1187  {
1188  sounds_pitchgain[i] = 1.0f; // unpitched
1189  }
1190  }
1191 
1192  sounds_pitchgain[templ->free_sound - 1] = 1.0f;
1193 
1194  if (templ->sound_pitches[templ->free_sound - 1] != 0.0f && sounds[templ->free_sound - 1])
1195  {
1197  }
1198  }
1199  else
1200  {
1201  // middle sound case
1202  int low = up - 1;
1203 
1204  for (int i = 0; i < low; i++)
1205  {
1206  if (templ->sound_pitches[i] != 0.0f)
1207  {
1208  sounds_pitchgain[i] = 0.0f;
1209  // pause?
1210  }
1211  else
1212  {
1213  sounds_pitchgain[i] = 1.0f; // unpitched
1214  }
1215  }
1216 
1217  if (templ->sound_pitches[low] != 0.0f && sounds[low])
1218  {
1219  sounds_pitchgain[low] = (templ->sound_pitches[up] - value) / (templ->sound_pitches[up] - templ->sound_pitches[low]);
1220  sounds[low]->setPitch(value / templ->sound_pitches[low]);
1221  }
1222  else
1223  {
1224  sounds_pitchgain[low] = 1.0f; // unpitched
1225  }
1226 
1227  if (templ->sound_pitches[up] != 0.0f && sounds[up])
1228  {
1229  sounds_pitchgain[up] = (value - templ->sound_pitches[low]) / (templ->sound_pitches[up] - templ->sound_pitches[low]);
1230  sounds[up]->setPitch(value / templ->sound_pitches[up]);
1231  }
1232  else
1233  {
1234  sounds_pitchgain[up] = 1.0f; // unpitched
1235  }
1236 
1237  for (int i = up + 1; i < templ->free_sound; i++)
1238  {
1239  if (templ->sound_pitches[i] != 0.0f)
1240  {
1241  sounds_pitchgain[i] = 0.0f;
1242  // pause?
1243  }
1244  else
1245  {
1246  sounds_pitchgain[i] = 1.0f; // unpitched
1247  }
1248  }
1249  }
1250  }
1251 
1252  if (stop_sound)
1253  {
1255 
1256  if (stop_sound_pitchgain != 0.0f && templ->stop_sound_pitch != 0.0f)
1257  {
1259  }
1260  }
1261 
1262  // propagate new gains
1263  setGain(lastgain);
1264 }
1265 
1266 float SoundScriptInstance::pitchgain_cutoff(float sourcepitch, float targetpitch)
1267 {
1268  if (sourcepitch == 0.0f)
1269  {
1270  return 1.0f; // unpitchable
1271  }
1272 
1273  if (targetpitch > sourcepitch / PITCHDOWN_FADE_FACTOR)
1274  {
1275  return 1.0f; // pass
1276  }
1277 
1278  if (targetpitch < sourcepitch / PITCHDOWN_CUTOFF_FACTOR)
1279  {
1280  return 0.0f; // cutoff
1281  }
1282 
1283  // linear fading
1284  return (targetpitch - sourcepitch / PITCHDOWN_CUTOFF_FACTOR) / (sourcepitch / PITCHDOWN_FADE_FACTOR - sourcepitch / PITCHDOWN_CUTOFF_FACTOR);
1285 }
1286 
1288 {
1289  if (start_sound)
1290  {
1292  }
1293 
1294  for (int i = 0; i < templ->free_sound; i++)
1295  {
1296  if (sounds[i])
1297  {
1298  sounds[i]->setGain(value * sounds_pitchgain[i]);
1299  }
1300  }
1301 
1302  if (stop_sound)
1303  {
1305  }
1306 
1307  lastgain = value;
1308 }
1309 
1311 {
1312  if (start_sound)
1313  {
1314  start_sound->setPosition(pos);
1315  }
1316 
1317  for (int i = 0; i < templ->free_sound; i++)
1318  {
1319  if (sounds[i])
1320  {
1321  sounds[i]->setPosition(pos);
1322  }
1323  }
1324 
1325  if (stop_sound)
1326  {
1327  stop_sound->setPosition(pos);
1328  }
1329 }
1330 
1331 void SoundScriptInstance::setVelocity(Vector3 velocity)
1332 {
1333  if (start_sound)
1334  {
1335  start_sound->setVelocity(velocity);
1336  }
1337 
1338  for (int i = 0; i < templ->free_sound; i++)
1339  {
1340  if (sounds[i])
1341  {
1342  sounds[i]->setVelocity(velocity);
1343  }
1344  }
1345 
1346  if (stop_sound)
1347  {
1348  stop_sound->setVelocity(velocity);
1349  }
1350 }
1351 
1353 {
1354  if (start_sound)
1355  {
1356  if (start_sound->isPlaying())
1357  {
1358  return;
1359  }
1360  start_sound->play();
1361  }
1362 
1363  for (int i = 0; i < templ->free_sound; i++)
1364  {
1365  if (sounds[i])
1366  {
1367  if (sounds[i]->isPlaying())
1368  {
1369  continue;
1370  }
1371  sounds[i]->setLoop(false);
1372  sounds[i]->play();
1373  }
1374  }
1375 
1376  if (stop_sound)
1377  {
1378  if (stop_sound->isPlaying())
1379  {
1380  return;
1381  }
1382  stop_sound->play();
1383  }
1384 }
1385 
1387 {
1388  if (start_sound)
1389  {
1390  start_sound->stop();
1391  //start_sound->setLoop(true);
1392  start_sound->play();
1393  }
1394 
1395  for (int i = 0; i < templ->free_sound; i++)
1396  {
1397  if (sounds[i])
1398  {
1399  sounds[i]->setLoop(true);
1400  sounds[i]->play();
1401  }
1402  }
1403 }
1404 
1406 {
1407  for (int i = 0; i < templ->free_sound; i++)
1408  {
1409  if (sounds[i])
1410  sounds[i]->stop();
1411  }
1412 
1413  if (stop_sound)
1414  {
1415  stop_sound->stop();
1416  stop_sound->play();
1417  }
1418 }
1419 
1421 {
1422  for (int i = 0; i < templ->free_sound; i++)
1423  {
1424  if (sounds[i])
1425  sounds[i]->stop();
1426  }
1427 
1428  if (start_sound)
1429  start_sound->stop();
1430 
1431  if (stop_sound)
1432  {
1433  stop_sound->stop();
1434  stop_sound->play();
1435  }
1436 }
1437 
1439 {
1440  if (start_sound)
1441  {
1442  start_sound->setEnabled(e);
1443  }
1444 
1445  if (stop_sound)
1446  {
1447  stop_sound->setEnabled(e);
1448  }
1449 
1450  for (int i = 0; i < templ->free_sound; i++)
1451  {
1452  if (sounds[i])
1453  {
1454  sounds[i]->setEnabled(e);
1455  }
1456  }
1457 }
1458 
1459 #endif // USE_OPENAL
RoR::SS_TRIG_AVICHAT09
@ SS_TRIG_AVICHAT09
Definition: SoundScriptManager.h:113
RoR::SoundScriptManager::templates
std::map< Ogre::String, SoundScriptTemplatePtr > templates
Definition: SoundScriptManager.h:352
RoR::SS_TRIG_GPWS_40
@ SS_TRIG_GPWS_40
Definition: SoundScriptManager.h:73
RoR::SoundManager::pauseAllSounds
void pauseAllSounds()
Definition: SoundManager.cpp:329
RoR::SS_MOD_THROTTLE7
@ SS_MOD_THROTTLE7
Definition: SoundScriptManager.h:145
RoR::SoundScriptInstance::sound_link_item_id
int sound_link_item_id
Definition: SoundScriptManager.h:290
RoR::SS_TRIG_GPWS_APDISCONNECT
@ SS_TRIG_GPWS_APDISCONNECT
Definition: SoundScriptManager.h:69
RoR::SS_TRIG_AVICHAT06
@ SS_TRIG_AVICHAT06
Definition: SoundScriptManager.h:110
RoR::SoundScriptManager::gains
std::array< SoundScriptInstancePtr, SS_MAX_MOD *MAX_INSTANCES_PER_GROUP > gains
Definition: SoundScriptManager.h:363
Sound.h
RoR::SS_TRIG_CREAK
@ SS_TRIG_CREAK
Definition: SoundScriptManager.h:81
RoR::SoundScriptInstance::start
void start()
Definition: SoundScriptManager.cpp:1386
RoR::SoundScriptInstance::pitchgain_cutoff
float pitchgain_cutoff(float sourcepitch, float targetpitch)
Definition: SoundScriptManager.cpp:1266
RoR::MAX_INSTANCES_PER_GROUP
@ MAX_INSTANCES_PER_GROUP
Definition: SoundScriptManager.h:49
RoR::SS_TRIG_AEROENGINE8
@ SS_TRIG_AEROENGINE8
Definition: SoundScriptManager.h:96
RoR::SoundManager
Definition: SoundManager.h:44
RoR::SS_MOD_THROTTLE6
@ SS_MOD_THROTTLE6
Definition: SoundScriptManager.h:144
RoR::SS_TRIG_AVICHAT04
@ SS_TRIG_AVICHAT04
Definition: SoundScriptManager.h:108
RoR::SS_MOD_AEROENGINE1
@ SS_MOD_AEROENGINE1
Definition: SoundScriptManager.h:127
RoR::SS_TRIG_AFTERBURNER6
@ SS_TRIG_AFTERBURNER6
Definition: SoundScriptManager.h:90
RoR::SoundScriptManager::setCamera
void setCamera(Ogre::Vector3 position, Ogre::Vector3 direction, Ogre::Vector3 up, Ogre::Vector3 velocity)
Definition: SoundScriptManager.cpp:324
RoR::Sound::setEnabled
void setEnabled(bool e)
Definition: Sound.cpp:99
RoR::SS_TRIG_TURN_SIGNAL_TICK
@ SS_TRIG_TURN_SIGNAL_TICK
Definition: SoundScriptManager.h:101
RoR::SS_MOD_AEROENGINE5
@ SS_MOD_AEROENGINE5
Definition: SoundScriptManager.h:147
RoR::SS_TRIG_ALB_ACTIVE
@ SS_TRIG_ALB_ACTIVE
Definition: SoundScriptManager.h:103
RoR::App::GetCameraManager
CameraManager * GetCameraManager()
Definition: Application.cpp:274
RoR::SS_TRIG_AEROENGINE2
@ SS_TRIG_AEROENGINE2
Definition: SoundScriptManager.h:56
RoR::SoundScriptManager::trigKill
void trigKill(int actor_id, int trig, int linkType=SL_DEFAULT, int linkItemID=-1)
Definition: SoundScriptManager.cpp:203
RoR::SoundScriptManager::getTrigState
bool getTrigState(int actor_id, int trig, int linkType=SL_DEFAULT, int linkItemID=-1)
Definition: SoundScriptManager.cpp:255
RoR::SoundScriptInstance::lastgain
float lastgain
Definition: SoundScriptManager.h:286
RoR::Actor::ar_instance_id
ActorInstanceID_t ar_instance_id
Static attr; session-unique ID.
Definition: Actor.h:365
RoR::SoundScriptInstance::setPitch
void setPitch(float value)
Definition: SoundScriptManager.cpp:1128
RoR::SS_TRIG_AEROENGINE6
@ SS_TRIG_AEROENGINE6
Definition: SoundScriptManager.h:94
RoR::SS_TRIG_ENGINE
@ SS_TRIG_ENGINE
Definition: SoundScriptManager.h:54
RoR::SoundScriptManager::instance_counter
int instance_counter
Definition: SoundScriptManager.h:349
RoR::SoundScriptManager::removeInstance
void removeInstance(const SoundScriptInstancePtr &ssi)
Definition: SoundScriptManager.cpp:409
RoR::SoundScriptManager::trigOnce
void trigOnce(int actor_id, int trig, int linkType=SL_DEFAULT, int linkItemID=-1)
Definition: SoundScriptManager.cpp:114
RoR::SoundScriptTemplate
Definition: SoundScriptManager.h:176
RoR::SS_TRIG_GPWS_MINIMUMS
@ SS_TRIG_GPWS_MINIMUMS
Definition: SoundScriptManager.h:77
RoR::SS_TRIG_BRAKE
@ SS_TRIG_BRAKE
Definition: SoundScriptManager.h:60
RoR::SS_TRIG_AFTERBURNER5
@ SS_TRIG_AFTERBURNER5
Definition: SoundScriptManager.h:89
RoR::SoundScriptInstance::setVelocity
void setVelocity(Ogre::Vector3 velo)
Definition: SoundScriptManager.cpp:1331
RoR::SoundScriptManager::free_gains
std::array< int, SS_MAX_MOD > free_gains
Definition: SoundScriptManager.h:362
RoR::SoundScriptInstance::stop
void stop()
Definition: SoundScriptManager.cpp:1405
RoR::SS_TRIG_TURBOBACKFIRE
@ SS_TRIG_TURBOBACKFIRE
Definition: SoundScriptManager.h:65
SoundManager.h
RoR::SoundScriptInstance::sound_manager
SoundManager * sound_manager
Definition: SoundScriptManager.h:279
RoR::SimState::EDITOR_MODE
@ EDITOR_MODE
Hacky, but whatever... added by Ulteq, 2016.
RoR::SS_TRIG_AFTERBURNER2
@ SS_TRIG_AFTERBURNER2
Definition: SoundScriptManager.h:86
RoR::SanitizeUtf8String
std::string SanitizeUtf8String(std::string const &str_in)
Definition: Utils.cpp:117
RoR::Sound::setPosition
void setPosition(Ogre::Vector3 pos)
Definition: Sound.cpp:152
RoR::SS_TRIG_AVICHAT03
@ SS_TRIG_AVICHAT03
Definition: SoundScriptManager.h:107
RoR::MAX_SOUNDS_PER_SCRIPT
@ MAX_SOUNDS_PER_SCRIPT
Definition: SoundScriptManager.h:48
CameraManager.h
RoR::SoundScriptInstance::PITCHDOWN_FADE_FACTOR
static const float PITCHDOWN_FADE_FACTOR
Definition: SoundScriptManager.h:267
RoR::SS_MOD_PUMP
@ SS_MOD_PUMP
Definition: SoundScriptManager.h:138
RoR::SS_TRIG_TURBOWASTEGATE
@ SS_TRIG_TURBOWASTEGATE
Definition: SoundScriptManager.h:64
RoR::SS_MOD_AEROENGINE4
@ SS_MOD_AEROENGINE4
Definition: SoundScriptManager.h:130
RoR::SoundScriptManager::setEnabled
void setEnabled(bool state)
Definition: SoundScriptManager.cpp:549
RoR::SS_TRIG_AEROENGINE3
@ SS_TRIG_AEROENGINE3
Definition: SoundScriptManager.h:57
RoR::SoundScriptManager::sound_manager
SoundManager * sound_manager
Definition: SoundScriptManager.h:369
RoR::SS_TRIG_TC_ACTIVE
@ SS_TRIG_TC_ACTIVE
Definition: SoundScriptManager.h:104
RoR::SS_MOD_AEROENGINE8
@ SS_MOD_AEROENGINE8
Definition: SoundScriptManager.h:150
RoR::SS_TRIG_GPWS_PULLUP
@ SS_TRIG_GPWS_PULLUP
Definition: SoundScriptManager.h:76
RoR::Sound::setLoop
void setLoop(bool loop)
Definition: Sound.cpp:134
RoR::SS_TRIG_PUMP
@ SS_TRIG_PUMP
Definition: SoundScriptManager.h:61
RoR::SS_MOD_AOA
@ SS_MOD_AOA
Definition: SoundScriptManager.h:152
RoR::SS_MOD_GEARBOX
@ SS_MOD_GEARBOX
Definition: SoundScriptManager.h:134
RoR::SoundScriptInstance::sound_link_type
int sound_link_type
Definition: SoundScriptManager.h:289
RoR::SoundScriptTemplate::gain_square
float gain_square
Definition: SoundScriptManager.h:219
RoR::SS_TRIG_AVICHAT11
@ SS_TRIG_AVICHAT11
Definition: SoundScriptManager.h:115
RoR::SS_TRIG_MAIN_MENU
@ SS_TRIG_MAIN_MENU
Definition: SoundScriptManager.h:119
RoR::SS_MOD_AEROENGINE2
@ SS_MOD_AEROENGINE2
Definition: SoundScriptManager.h:128
RoR::SoundScriptTemplate::file_name
Ogre::String file_name
Definition: SoundScriptManager.h:209
RoR::App::sim_state
CVar * sim_state
Definition: Application.cpp:96
RoR::SoundScriptTemplate::start_sound_pitch
float start_sound_pitch
Definition: SoundScriptManager.h:230
RoR::CameraManager::GetCameraNode
Ogre::SceneNode * GetCameraNode()
Definition: CameraManager.h:63
Utils.h
RoR::SoundScriptInstance::setGain
void setGain(float value)
Definition: SoundScriptManager.cpp:1287
RoR::Sound::isPlaying
bool isPlaying()
Definition: Sound.cpp:88
RoR::SS_MOD_MUSIC_VOLUME
@ SS_MOD_MUSIC_VOLUME
Definition: SoundScriptManager.h:154
RefCountingObjectPtr< Sound >
RoR::SS_TRIG_SCREETCH
@ SS_TRIG_SCREETCH
Definition: SoundScriptManager.h:83
RoR::SS_TRIG_TURN_SIGNAL_WARN_TICK
@ SS_TRIG_TURN_SIGNAL_WARN_TICK
Definition: SoundScriptManager.h:102
Actor.h
RoR::SS_TRIG_AFTERBURNER4
@ SS_TRIG_AFTERBURNER4
Definition: SoundScriptManager.h:88
RoR::SoundScriptTemplate::sound_names
Ogre::String sound_names[MAX_SOUNDS_PER_SCRIPT]
Definition: SoundScriptManager.h:227
RoR::App::audio_enable_creak
CVar * audio_enable_creak
Definition: Application.cpp:209
RoR::SS_MOD_INJECTOR
@ SS_MOD_INJECTOR
Definition: SoundScriptManager.h:132
RoR::Sound::setPitch
void setPitch(float pitch)
Definition: Sound.cpp:143
RoR::SS_TRIG_REVERSE_GEAR
@ SS_TRIG_REVERSE_GEAR
Definition: SoundScriptManager.h:99
RoR::SoundManager::createSound
SoundPtr createSound(Ogre::String filename, Ogre::String resource_group_name="")
Definition: SoundManager.cpp:354
RoR::SoundScriptTemplate::gain_source
int gain_source
Definition: SoundScriptManager.h:220
RoR::SoundScriptManager::createTemplate
SoundScriptTemplatePtr createTemplate(Ogre::String name, Ogre::String groupname, Ogre::String filename)
Definition: SoundScriptManager.cpp:342
RoR::SoundScriptManager::~SoundScriptManager
~SoundScriptManager()
Definition: SoundScriptManager.cpp:97
RoR::SoundScriptInstance::kill
void kill()
Definition: SoundScriptManager.cpp:1420
RoR::SoundScriptInstance::PITCHDOWN_CUTOFF_FACTOR
static const float PITCHDOWN_CUTOFF_FACTOR
Definition: SoundScriptManager.h:268
TOSTRING
#define TOSTRING(x)
Definition: Application.h:56
RoR::SS_TRIG_GPWS_10
@ SS_TRIG_GPWS_10
Definition: SoundScriptManager.h:70
RoR::SS_TRIG_PARK
@ SS_TRIG_PARK
Definition: SoundScriptManager.h:84
RoR::SS_TRIG_LINKED_COMMAND
@ SS_TRIG_LINKED_COMMAND
Definition: SoundScriptManager.h:118
RoR::SS_TRIG_AVICHAT13
@ SS_TRIG_AVICHAT13
Definition: SoundScriptManager.h:117
RoR::SoundScriptManager::parseScript
void parseScript(Ogre::DataStreamPtr &stream, const Ogre::String &groupName)
Definition: SoundScriptManager.cpp:474
RoR::SoundScriptTemplate::SoundScriptTemplate
SoundScriptTemplate(Ogre::String name, Ogre::String groupname, Ogre::String filename, bool baseTemplate)
Definition: SoundScriptManager.cpp:559
RoR::SoundManager::getNumHardwareSources
int getNumHardwareSources()
Definition: SoundManager.h:65
RoR::SS_MOD_TURBO
@ SS_MOD_TURBO
Definition: SoundScriptManager.h:126
RoR::SoundScriptTemplate::unpitchable
bool unpitchable
Definition: SoundScriptManager.h:215
RoR::SoundScriptTemplate::pitch_source
int pitch_source
Definition: SoundScriptManager.h:225
RoR::SS_TRIG_AIR_PURGE
@ SS_TRIG_AIR_PURGE
Definition: SoundScriptManager.h:78
RoR::SoundScriptManager::disabled
bool disabled
Definition: SoundScriptManager.h:344
RoR::SoundScriptTemplate::gain_offset
float gain_offset
Definition: SoundScriptManager.h:218
RoR::SS_MOD_THROTTLE1
@ SS_MOD_THROTTLE1
Definition: SoundScriptManager.h:139
RoR::SoundScriptTemplate::sound_pitches
float sound_pitches[MAX_SOUNDS_PER_SCRIPT]
Definition: SoundScriptManager.h:228
RoR::SoundManager::resumeAllSounds
void resumeAllSounds()
Definition: SoundManager.cpp:337
RoR::SS_TRIG_AEROENGINE1
@ SS_TRIG_AEROENGINE1
Definition: SoundScriptManager.h:55
RoR::SoundScriptManager::skipToNextCloseBrace
void skipToNextCloseBrace(Ogre::DataStreamPtr &chunk)
Definition: SoundScriptManager.cpp:529
RoR::SoundScriptTemplate::free_sound
int free_sound
Definition: SoundScriptManager.h:235
RoR::SoundScriptTemplate::pitch_multiplier
float pitch_multiplier
Definition: SoundScriptManager.h:222
RoR::SS_MAX_MOD
@ SS_MAX_MOD
Definition: SoundScriptManager.h:155
RoR::SoundScriptTemplate::stop_sound_name
Ogre::String stop_sound_name
Definition: SoundScriptManager.h:231
RoR::SS_TRIG_AIR
@ SS_TRIG_AIR
Definition: SoundScriptManager.h:68
RoR::SS_TRIG_AVICHAT01
@ SS_TRIG_AVICHAT01
Definition: SoundScriptManager.h:105
RoR::SS_TRIG_ALWAYSON
@ SS_TRIG_ALWAYSON
Definition: SoundScriptManager.h:66
RoR::SS_MOD_WHEELSPEED
@ SS_MOD_WHEELSPEED
Definition: SoundScriptManager.h:131
RoR::SS_TRIG_GPWS_50
@ SS_TRIG_GPWS_50
Definition: SoundScriptManager.h:74
RoR::SoundScriptManager::createInstance
SoundScriptInstancePtr createInstance(Ogre::String templatename, int actor_id, int soundLinkType=SL_DEFAULT, int soundLinkItemId=-1)
Definition: SoundScriptManager.cpp:356
RoR::SoundScriptInstance::runOnce
void runOnce()
Definition: SoundScriptManager.cpp:1352
SoundScriptManager.h
RoR::SS_MOD_THROTTLE3
@ SS_MOD_THROTTLE3
Definition: SoundScriptManager.h:141
RoR::SoundScriptTemplate::stop_sound_pitch
float stop_sound_pitch
Definition: SoundScriptManager.h:232
RoR::SoundScriptInstance::setEnabled
void setEnabled(bool e)
Definition: SoundScriptManager.cpp:1438
RoR::SS_MOD_NONE
@ SS_MOD_NONE
Definition: SoundScriptManager.h:124
RoR::SS_TRIG_AEROENGINE4
@ SS_TRIG_AEROENGINE4
Definition: SoundScriptManager.h:58
RoR::SS_MOD_LINKED_COMMANDRATE
@ SS_MOD_LINKED_COMMANDRATE
Definition: SoundScriptManager.h:153
RoR::SS_MOD_SCREETCH
@ SS_MOD_SCREETCH
Definition: SoundScriptManager.h:137
RoR::SS_TRIG_GPWS_30
@ SS_TRIG_GPWS_30
Definition: SoundScriptManager.h:72
RoR::SS_MAX_TRIG
@ SS_MAX_TRIG
Definition: SoundScriptManager.h:120
RoR::SoundScriptTemplate::pitch_offset
float pitch_offset
Definition: SoundScriptManager.h:223
RoR::SS_TRIG_GPWS_20
@ SS_TRIG_GPWS_20
Definition: SoundScriptManager.h:71
RoR::SoundScriptTemplate::has_stop_sound
bool has_stop_sound
Definition: SoundScriptManager.h:214
RoR::SS_MOD_AEROENGINE7
@ SS_MOD_AEROENGINE7
Definition: SoundScriptManager.h:149
RoR::Sound::setGain
void setGain(float gain)
Definition: Sound.cpp:125
RoR::SoundScriptManager::free_trigs
std::array< int, SS_MAX_TRIG > free_trigs
Definition: SoundScriptManager.h:356
RoR::SS_TRIG_TURBOBOV
@ SS_TRIG_TURBOBOV
Definition: SoundScriptManager.h:63
RoR::SoundScriptTemplate::gain_multiplier
float gain_multiplier
Definition: SoundScriptManager.h:217
RoR::SS_TRIG_HORN
@ SS_TRIG_HORN
Definition: SoundScriptManager.h:59
RoR::SS_TRIG_AVICHAT05
@ SS_TRIG_AVICHAT05
Definition: SoundScriptManager.h:109
RoR::SoundScriptInstance::stop_sound
SoundPtr stop_sound
Definition: SoundScriptManager.h:281
RoR::SS_TRIG_GPWS_100
@ SS_TRIG_GPWS_100
Definition: SoundScriptManager.h:75
RoR::SS_TRIG_AVICHAT08
@ SS_TRIG_AVICHAT08
Definition: SoundScriptManager.h:112
RoR::SoundScriptInstance::start_sound
SoundPtr start_sound
Definition: SoundScriptManager.h:280
RoR::SS_TRIG_AEROENGINE5
@ SS_TRIG_AEROENGINE5
Definition: SoundScriptManager.h:93
RoR::SoundManager::isDisabled
bool isDisabled()
Definition: SoundManager.h:63
RoR::Sound::stop
void stop()
Definition: Sound.cpp:119
RoR::SS_TRIG_BREAK
@ SS_TRIG_BREAK
Definition: SoundScriptManager.h:82
RoR::SoundScriptTemplate::start_sound_name
Ogre::String start_sound_name
Definition: SoundScriptManager.h:229
RoR::SoundScriptInstance::sounds_pitchgain
float sounds_pitchgain[MAX_SOUNDS_PER_SCRIPT]
Definition: SoundScriptManager.h:285
instance
or anywhere else will not be considered a but parsed as regular data ! Each line is treated as values separated by separators Possible i e animators Multiline description Single instance
Definition: ReadMe.txt:53
RoR::SoundScriptTemplate::pitch_square
float pitch_square
Definition: SoundScriptManager.h:224
RoR::Sound::setVelocity
void setVelocity(Ogre::Vector3 vel)
Definition: Sound.cpp:161
RoR::SS_MOD_AIRSPEED
@ SS_MOD_AIRSPEED
Definition: SoundScriptManager.h:151
RoR::SoundScriptInstance::start_sound_pitchgain
float start_sound_pitchgain
Definition: SoundScriptManager.h:283
RoR::SoundScriptManager::trigStart
void trigStart(int actor_id, int trig, int linkType=SL_DEFAULT, int linkItemID=-1)
Definition: SoundScriptManager.cpp:142
RoR::SS_MOD_THROTTLE5
@ SS_MOD_THROTTLE5
Definition: SoundScriptManager.h:143
RoR::SoundScriptInstance
Definition: SoundScriptManager.h:238
RoR::SoundScriptManager::free_pitches
std::array< int, SS_MAX_MOD > free_pitches
Definition: SoundScriptManager.h:359
RoR::SS_MOD_THROTTLE4
@ SS_MOD_THROTTLE4
Definition: SoundScriptManager.h:142
RoR::SS_TRIG_SHIFT
@ SS_TRIG_SHIFT
Definition: SoundScriptManager.h:79
RoR::SS_TRIG_AVICHAT12
@ SS_TRIG_AVICHAT12
Definition: SoundScriptManager.h:116
RoR::SoundScriptTemplate::has_start_sound
bool has_start_sound
Definition: SoundScriptManager.h:213
RoR::SoundScriptManager::loading_base
bool loading_base
Definition: SoundScriptManager.h:345
RoR::SoundManager::setCamera
void setCamera(Ogre::Vector3 position, Ogre::Vector3 direction, Ogre::Vector3 up, Ogre::Vector3 velocity)
Definition: SoundManager.cpp:138
RoR::SS_TRIG_GEARSLIDE
@ SS_TRIG_GEARSLIDE
Definition: SoundScriptManager.h:80
RoR::Sound::play
void play()
Definition: Sound.cpp:113
RoR::SS_MOD_CREAK
@ SS_MOD_CREAK
Definition: SoundScriptManager.h:135
RoR::SoundScriptTemplate::parseModulation
int parseModulation(Ogre::String str)
Definition: SoundScriptManager.cpp:1023
RoR::SS_TRIG_AEROENGINE7
@ SS_TRIG_AEROENGINE7
Definition: SoundScriptManager.h:95
RoR::EraseIf
void EraseIf(std::vector< T, A > &c, Predicate pred)
Definition: Utils.h:74
RoR::SoundScriptInstance::sounds
SoundPtr sounds[MAX_SOUNDS_PER_SCRIPT]
Definition: SoundScriptManager.h:282
RoR::SoundScriptTemplate::trigger_source
int trigger_source
Definition: SoundScriptManager.h:234
RoR::SimState::RUNNING
@ RUNNING
RoR::SoundScriptTemplate::setParameter
bool setParameter(Ogre::StringVector vec)
Definition: SoundScriptManager.cpp:582
Ogre
Definition: ExtinguishableFireAffector.cpp:35
RoR::SS_TRIG_TURN_SIGNAL
@ SS_TRIG_TURN_SIGNAL
Definition: SoundScriptManager.h:100
RoR::SoundScriptManager::pitches
std::array< SoundScriptInstancePtr, SS_MAX_MOD *MAX_INSTANCES_PER_GROUP > pitches
Definition: SoundScriptManager.h:360
RoR::SoundScriptManager::modulate
void modulate(int actor_id, int mod, float value, int linkType=SL_DEFAULT, int linkItemID=-1)
Definition: SoundScriptManager.cpp:274
RoR::SS_MOD_ENGINE
@ SS_MOD_ENGINE
Definition: SoundScriptManager.h:125
RoR::SS_MOD_BREAK
@ SS_MOD_BREAK
Definition: SoundScriptManager.h:136
RoR::SS_TRIG_REPAIR
@ SS_TRIG_REPAIR
Definition: SoundScriptManager.h:67
RoR::SS_TRIG_AVICHAT02
@ SS_TRIG_AVICHAT02
Definition: SoundScriptManager.h:106
RoR::SS_TRIG_AFTERBURNER7
@ SS_TRIG_AFTERBURNER7
Definition: SoundScriptManager.h:91
RoR::SoundScriptManager::update
void update(float dt_sec)
Definition: SoundScriptManager.cpp:308
RoR::SS_TRIG_IGNITION
@ SS_TRIG_IGNITION
Definition: SoundScriptManager.h:98
RoR::SS_TRIG_AVICHAT10
@ SS_TRIG_AVICHAT10
Definition: SoundScriptManager.h:114
RoR::SoundScriptManager::getScriptPatterns
const Ogre::StringVector & getScriptPatterns(void) const
Definition: SoundScriptManager.cpp:331
RoR::SS_MOD_AEROENGINE6
@ SS_MOD_AEROENGINE6
Definition: SoundScriptManager.h:148
RoR::SS_TRIG_AVICHAT07
@ SS_TRIG_AVICHAT07
Definition: SoundScriptManager.h:111
RoR::SS_TRIG_AFTERBURNER3
@ SS_TRIG_AFTERBURNER3
Definition: SoundScriptManager.h:87
RoR::SoundScriptInstance::stop_sound_pitchgain
float stop_sound_pitchgain
Definition: SoundScriptManager.h:284
RoR::SoundScriptManager::skipToNextOpenBrace
void skipToNextOpenBrace(Ogre::DataStreamPtr &chunk)
Definition: SoundScriptManager.cpp:539
RoR::SS_TRIG_NONE
@ SS_TRIG_NONE
Definition: SoundScriptManager.h:53
RoR::SS_MOD_THROTTLE2
@ SS_MOD_THROTTLE2
Definition: SoundScriptManager.h:140
RoR::SS_MOD_AEROENGINE3
@ SS_MOD_AEROENGINE3
Definition: SoundScriptManager.h:129
RoR::SS_TRIG_AFTERBURNER8
@ SS_TRIG_AFTERBURNER8
Definition: SoundScriptManager.h:92
RoR::SoundScriptManager::getLoadingOrder
Ogre::Real getLoadingOrder(void) const
Definition: SoundScriptManager.cpp:336
RoR
Definition: AppContext.h:36
RoR::SS_MOD_TORQUE
@ SS_MOD_TORQUE
Definition: SoundScriptManager.h:133
RoR::SoundScriptInstance::templ
SoundScriptTemplatePtr templ
Definition: SoundScriptManager.h:278
RoR::SoundScriptInstance::setPosition
void setPosition(Ogre::Vector3 pos)
Definition: SoundScriptManager.cpp:1310
RoR::SoundScriptManager::trigToggle
void trigToggle(int actor_id, int trig, int linkType=SL_DEFAULT, int linkItemID=-1)
Definition: SoundScriptManager.cpp:233
RoR::SoundScriptManager::state_map
std::map< int, std::map< int, std::map< int, std::map< int, bool > > > > state_map
Definition: SoundScriptManager.h:367
RoR::SoundScriptManager::trigStop
void trigStop(int actor_id, int trig, int linkType=SL_DEFAULT, int linkItemID=-1)
Definition: SoundScriptManager.cpp:173
RoR::SS_MOD_THROTTLE8
@ SS_MOD_THROTTLE8
Definition: SoundScriptManager.h:146
RoR::SS_TRIG_STARTER
@ SS_TRIG_STARTER
Definition: SoundScriptManager.h:62
RoR::SS_TRIG_AFTERBURNER1
@ SS_TRIG_AFTERBURNER1
Definition: SoundScriptManager.h:85
RoR::SoundScriptInstance::SoundScriptInstance
SoundScriptInstance(int actor_id, SoundScriptTemplatePtr templ, SoundManager *sm, Ogre::String instancename, int soundLinkType=SL_DEFAULT, int soundLinkItemId=-1)
Definition: SoundScriptManager.cpp:1093
RoR::SoundScriptInstance::actor_id
int actor_id
Definition: SoundScriptManager.h:288
RoR::SoundScriptManager::trigs
std::array< SoundScriptInstancePtr, SS_MAX_TRIG *MAX_INSTANCES_PER_GROUP > trigs
Definition: SoundScriptManager.h:357
RoR::SS_TRIG_AOA
@ SS_TRIG_AOA
Definition: SoundScriptManager.h:97
RoR::SoundScriptManager::script_patterns
Ogre::StringVector script_patterns
Definition: SoundScriptManager.h:350
RoR::SoundScriptManager::instances
std::vector< SoundScriptInstancePtr > instances
Definition: SoundScriptManager.h:353