diff --git a/Aircraft/Generic/soaring-instrumentation-sdk.nas b/Aircraft/Generic/soaring-instrumentation-sdk.nas index fcce506d5..a08a151bd 100644 --- a/Aircraft/Generic/soaring-instrumentation-sdk.nas +++ b/Aircraft/Generic/soaring-instrumentation-sdk.nas @@ -409,3 +409,34 @@ var SpeedCmdVario = { if (me.on_update != nil) me.on_update(me.output); } }; + +# Vario sound pitch controller +# Computes the frequency factor for a variometer sound. +# +# var vario_sound = SoundPitchController.new( +# input: Object connected to the pitch controller input, e.g. a variometer reading. +# max_pitch: (optional) Maximum sound frequency factor, the output will be +# in the range [1/max_pitch, max_pitch], default 2. +# max_input: Value of input for which max_pitch is reached. +# on_update: (optional) function to call whenever a new output is available + +var SoundPitchController = { + parents: [InstrumentComponent], + + new: func(input, max_input, max_pitch = 2, on_update = nil) { + return { + parents: [me], + input: input, + max_pitch: max_pitch, + max_input: max_input, + on_update: on_update, + }; + }, + + update: func { + var input = math.clamp(me.input.output, -me.max_input, me.max_input); + me.output = math.pow(me.max_pitch, input / me.max_input); + + if (me.on_update != nil) me.on_update(me.output); + }, +}; diff --git a/Aircraft/Instruments-3d/glider/vario/ilec-sc7/README_install b/Aircraft/Instruments-3d/glider/vario/ilec-sc7/README_install index dce9c1af1..e9b87e50c 100644 --- a/Aircraft/Instruments-3d/glider/vario/ilec-sc7/README_install +++ b/Aircraft/Instruments-3d/glider/vario/ilec-sc7/README_install @@ -7,60 +7,57 @@ You will need to : * modify your sound.xml, including the following lines : - variometer-up - looped - Instruments-3d/glider/vario/ilec-sc7/vario.wav - - - - instrumentation/ilec-sc7/audio - 0 - - - instrumentation/ilec-sc7/te-reading-mps - 0.01 - - - - - instrumentation/ilec-sc7/te-reading-mps - 0.246 - 1.0 - - - instrumentation/ilec-sc7/volume - 1 - - - - - variometer-down - looped - Instruments-3d/glider/vario/ilec-sc7/vario2.wav - + variometer-up + looped + Instruments-3d/glider/vario/ilec-sc7/vario.wav + - - instrumentation/ilec-sc7/audio - 2 - - - instrumentation/ilec-sc7/te-reading-mps - -10.66 - - - instrumentation/ilec-sc7/te-reading-mps - -0.01 - + + instrumentation/ilec-sc7/audio + 0 + + + instrumentation/ilec-sc7/te-reading-mps + 0.01 + - - - instrumentation/ilec-sc7/te-reading-neg - -0.05 - 1.0 - - - instrumentation/ilec-sc7/volume - 1 - - + + + /instrumentation/ilec-sc7/sound-pitch + 0 + + + instrumentation/ilec-sc7/volume + 1 + + + + + variometer-down + looped + Instruments-3d/glider/vario/ilec-sc7/vario2.wav + + + + instrumentation/ilec-sc7/audio + 2 + + + instrumentation/ilec-sc7/te-reading-mps + -10.66 + + + instrumentation/ilec-sc7/te-reading-mps + -0.01 + + + + + /instrumentation/ilec-sc7/sound-pitch + 0 + + + instrumentation/ilec-sc7/volume + 1 + diff --git a/Aircraft/Instruments-3d/glider/vario/ilec-sc7/ilec-sc7.nas b/Aircraft/Instruments-3d/glider/vario/ilec-sc7/ilec-sc7.nas index a8bc30d05..1c7d66f7a 100644 --- a/Aircraft/Instruments-3d/glider/vario/ilec-sc7/ilec-sc7.nas +++ b/Aircraft/Instruments-3d/glider/vario/ilec-sc7/ilec-sc7.nas @@ -9,6 +9,7 @@ setprop("/instrumentation/ilec-sc7/lcd-digits-abs", 0); setprop("/instrumentation/ilec-sc7/lcd-digits-sgn", 0); setprop("/instrumentation/ilec-sc7/te-reading-mps", 0); setprop("/instrumentation/variometer/te-reading-mps", 0); +setprop("/instrumentation/ilec-sc7/sound-pitch", 1); # Helper function for updating lcd display var update_lcd_props = func(value) { @@ -34,6 +35,11 @@ var sc7_needle = Dampener.new( dampening: 3, on_update: update_prop("/instrumentation/ilec-sc7/te-reading-mps")); +var sc7_sound = SoundPitchController.new( + input: sc7_needle, + max_input: 5, + on_update: update_prop("/instrumentation/ilec-sc7/sound-pitch")); + var extra_needle = Dampener.new( input: probe, dampening: 2.7, @@ -66,7 +72,7 @@ setlistener("instrumentation/ilec-sc7/sensitivity", # Wrap everything together into an instrument var fast_instruments = UpdateLoop.new( update_period: 0, - components: [probe, sc7_needle, extra_needle], + components: [probe, sc7_needle, sc7_sound, extra_needle], enable: 1); var slow_instruments = UpdateLoop.new(