From b4a94c266f85d2c9dc4fe456bb12889f6d900876 Mon Sep 17 00:00:00 2001
From: Eric Rosenbaum <eric.rosenbaum@gmail.com>
Date: Mon, 20 Mar 2017 17:01:44 -0400
Subject: [PATCH] Add loudness block

---
 src/blocks/scratch3_sensing.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/blocks/scratch3_sensing.js b/src/blocks/scratch3_sensing.js
index 1601fc650..574d6a020 100644
--- a/src/blocks/scratch3_sensing.js
+++ b/src/blocks/scratch3_sensing.js
@@ -26,7 +26,8 @@ Scratch3SensingBlocks.prototype.getPrimitives = function () {
         sensing_mousedown: this.getMouseDown,
         sensing_keypressed: this.getKeyPressed,
         sensing_current: this.current,
-        sensing_dayssince2000: this.daysSince2000
+        sensing_dayssince2000: this.daysSince2000,
+        sensing_loudness: this.getLoudness
     };
 };
 
@@ -125,6 +126,11 @@ Scratch3SensingBlocks.prototype.daysSince2000 = function () {
     return mSecsSinceStart / msPerDay;
 };
 
+Scratch3SensingBlocks.prototype.getLoudness = function () {
+    if (typeof this.runtime.audioEngine === 'undefined') return 0;
+    return this.runtime.audioEngine.getLoudness();
+};
+
 Scratch3SensingBlocks.prototype.getAttributeOf = function (args) {
     var attrTarget;