Action triggered by a sound level

edited February 2016 in Library Questions

I'm building an art installation controlled my processing. In the previous version of it, the sound played was triggered by a mouse press and a key press using MakeyMakey keyboard durning a test run. As my research is done about the reactions of the users to the experience, i'm shifting the code to something different. I'd like to make a final installation be triggered not by a key or mouse press, but by a sound of surrounding environment, so a sound would be played when the noise level captured by a microphone reaches a certain level.

What code could I use for it? Is there any tutorial about the microphone triggers?

Here is my code from the previous run if anyone would be keen to suggest changes.

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
import processing.sound.*;
Minim minim;
AudioPlayer one; //variable name
AudioPlayer male;
Capture cam;

void setup(){

 cam = new Capture(this,1280,720,30);

  minim = new Minim(this);
  one =minim.loadFile("german.wav");


void draw(){

 if (cam.available()) {;
if (mousePressed == true);    



void mousePressed(){
 //if (mousePressed == true);;
  //  saveFrame();

void mouseReleased()
  if (mousePressed || true);
  one =minim.loadFile("german.wav");

void keyPressed()
  if (key == ' ' );;


void keyReleased(){
  male =minim.loadFile("male.wav");


Sign In or Register to comment.