Howto:Reload sound configuration without restarting: Difference between revisions

Jump to navigation Jump to search
no edit summary
mNo edit summary
No edit summary
Line 4: Line 4:


Every time that line is executed, the sound subsystem ("fx") is restarted and the config file reloaded, enabling you to test your changes instantly.  Just remember to actually save your sound config file each time you want to test so that FG sees the most recent changes.
Every time that line is executed, the sound subsystem ("fx") is restarted and the config file reloaded, enabling you to test your changes instantly.  Just remember to actually save your sound config file each time you want to test so that FG sees the most recent changes.
Here is a Nasal function which will automatically reload the sound xml file when you make a change...
var reload_sound = func {
  var sf = getprop('/tmp/sound-xml/path');
  if(sf == nil)
  {
    sf = getprop('/sim/fg-root') ~ getprop('/sim/sound/path');
    setprop('/tmp/sound-xml/path', sf);
  }
  var st = io.stat(sf);
  var lm = getprop('/tmp/sound-xml/modified');
  if(lm == nil)
  {
    lm = st[9];
    setprop('/tmp/sound-xml/modified', lm);
  }
  elsif(lm < st[9])
  {
    setprop('/tmp/sound-xml/modified', st[9]);
    fgcommand('reinit', props.Node.new({ subsystem: "fx" }));
  }
  settimer(reload_sound, 2);
}
reload_sound();


[[Category:Howto|Reload_sound_config_without_restarting_FG]]
[[Category:Howto|Reload_sound_config_without_restarting_FG]]
1

edit

Navigation menu