From 2601db8fd44f3a05dc8d298bc971362268ab21ba Mon Sep 17 00:00:00 2001 From: annabunches Date: Sun, 29 Aug 2021 17:26:56 -0400 Subject: [PATCH] Add tones, including a launch countdown sequence. --- lib/launch_rocket.ks | 4 +++- lib/sound.ks | 32 ++++++++++++++++++++++++++++++++ prog/launchpad.ks | 4 ++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 lib/sound.ks diff --git a/lib/launch_rocket.ks b/lib/launch_rocket.ks index c18ae2d..6c47c33 100644 --- a/lib/launch_rocket.ks +++ b/lib/launch_rocket.ks @@ -1,6 +1,7 @@ RunOncePath("lib/throttle"). RunOncePath("lib/navigation"). RunOncePath("lib/navball"). +RunOncePath("lib/sound"). // Calculate the direction to lock during ascent. function getClampedDir { @@ -43,9 +44,10 @@ function Launch { // Countdowns are cute. print "Initiating automated launch sequence.". + PlayCountdown(). from { local x is 5. } until x = 0 step { set x to x - 1. } do { print "..." + x. - wait 0.5. + wait 1.0. } // staging logic. Stage as many times as needed until we finish ascent. diff --git a/lib/sound.ks b/lib/sound.ks new file mode 100644 index 0000000..32ef88e --- /dev/null +++ b/lib/sound.ks @@ -0,0 +1,32 @@ + +// An informational tone. +function InfoTone { + local v is GetVoice(0). + set v:VOLUME to 0.75. + set v:WAVE to "sine". + set v:ATTACK to 0.1. + set v:DECAY to 0.05. + set v:SUSTAIN to 0.7. + set v:RELEASE to 0.25. + + v:Play(Note("C4", 1, 0.75)). +} + +function PlayCountdown { + local v is GetVoice(0). + set v:VOLUME to 0.9. + set v:WAVE to "sine". + set v:ATTACK to 0.05. + set v:DECAY to 0.001. + set v:SUSTAIN to 0.7. + set v:RELEASE to 0.05. + + local notes is List( + Note("E4", 1, 0.25), + Note("E4", 1, 0.25), + Note("E4", 1, 0.25), + Note("E4", 1, 0.25), + Note("B5", 1, 0.45) + ). + v:Play(notes). +} diff --git a/prog/launchpad.ks b/prog/launchpad.ks index 6b4b8c8..17b8ea7 100644 --- a/prog/launchpad.ks +++ b/prog/launchpad.ks @@ -11,6 +11,7 @@ RunOncePath("/lib/systems"). RunOncePath("/lib/ui"). +RunOncePath("/lib/sound"). ClearGuis(). @@ -38,6 +39,9 @@ function preLaunch { // turn on generator and fuel flow enableLaunchpadFlow(). + InfoTone(). + wait 2. + local duration is options["Spool-up Time"]:TEXT:ToNumber(). lock THROTTLE to 0. stage.