If function is called too many times

i’m using ml5 for a project, and what i’m trying to achieve is everytime my nose is detected inside an ellipse, a song starts and the ellipse moves with a perlin noise effect.

The problem is the “if function” is called too many times and I think it deteriorates the sound bc I think it starts it multiple times. Also even when my nose is inside the ellipse it keeps saying “false” and then “true” in the console and I don’t know why? What would be the best way to code this to make it work smoothly?

checkCollision(points) {
    points.forEach((keypoints) => {
      keypoints.forEach((keypoint) => {
        const pos = keypoint.position;
        const d = dist(pos.x, pos.y, this.x, this.y);
        const hasTriggered = d <= this.radius * 0.5;
        if (hasTriggered) {
          this.sound.play();
          this.maxnoise = lerp(this.maxnoise, 50, 0.05);
          console.log("true");
        } else {
          console.log("false");
          this.sound.stop();
          this.maxnoise = lerp(this.maxnoise, this.maxnoiseafter, 0.05);
        }
      });
    });
}

this is what my console looks like when i’m inside the ellipse and supposed to trigger the effect and the sound
this is what my console looks like when i'm inside the ellipse and supposed to trigger the effect and the sound