From a6439559e584a59ea0e3d8b073d638b4532e57bf Mon Sep 17 00:00:00 2001 From: jmoenig Date: Sun, 10 Mar 2019 15:04:45 +0100 Subject: [PATCH] tweaked pitch detection to smoothen low audio signals --- HISTORY.md | 1 + src/objects.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index aa1f07f3..7d38f485 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -51,6 +51,7 @@ * Objects, Blocks, Threads: added microphone note and pitch detection * Tweaked note detection to only change when the audio signal is strong enough * updated German translation for pitch-detection +* tweaked pitch detection to smoothen low audio signals ### 2019-03-07 * AudioComp lib: added block to set the microphone's buffer and fft sizes diff --git a/src/objects.js b/src/objects.js index 6a27acf4..48bfa500 100644 --- a/src/objects.js +++ b/src/objects.js @@ -9065,7 +9065,7 @@ Microphone.prototype.detectPitch = function (buf, sampleRate) { } rms = Math.sqrt(rms/SIZE); if (rms < 0.01) - return -1; + return this.pitch; // -1; lastCorrelation = 1; for (offset = this.MIN_SAMPLES; offset < MAX_SAMPLES; offset += 1) { @@ -9095,7 +9095,7 @@ Microphone.prototype.detectPitch = function (buf, sampleRate) { if (best_correlation > 0.01) { return sampleRate / best_offset; } - return -1; + return this.pitch; // -1; }; // CellMorph //////////////////////////////////////////////////////////