How to listen for two whistle patterns simultaneously?

I just finished using a public secret knock pattern program to activate a series of different led strips, but I can't for the life of me figure out how to get the program to listen for two different patterns at once. I have been able to get them stored, but the program only listens for the first one in the loop. Please help! Here's the void setup and loop code. The full code is attached.

void setup() {
pinMode(leftBlinker, OUTPUT);
pinMode(rightBlinker, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(leftprogramSwitch, INPUT);
pinMode(rightprogramSwitch, INPUT);

Serial.begin(9600); // Uncomment the Serial.bla lines for debugging.
Serial.println("Program start."); // but feel free to comment them out after it's working right.

digitalWrite(greenLED, HIGH); // Green LED on, everything is go.
}

void loop() {
// Listen for any whistle at all.
whistleSensorValue = analogRead(whistleSensor);

if (digitalRead(leftprogramSwitch)==HIGH){ // is the left program button pressed?
programLeftButtonPressed = true; // Yes, so lets save that state
digitalWrite(redLED, HIGH); // and turn on the red light too so we know we're programming.
} else {
programLeftButtonPressed = false;
digitalWrite(redLED, LOW);
}

if (digitalRead(rightprogramSwitch)==HIGH){ // is the right program button pressed?
programRightButtonPressed = true; // Yes, so lets save that state
digitalWrite(redLED, HIGH); // and turn on the red light too so we know we're programming.
} else {
programRightButtonPressed = false;
digitalWrite(redLED, LOW);
}

if ((whistleSensorValue >=threshold) && (digitalRead(rightprogramSwitch)==LOW)){
listenToSecretLeftWhistle();
}
if ((whistleSensorValue >=threshold) && (digitalRead(leftprogramSwitch)==LOW)){
listenToSecretRightWhistle();
}
}

Bike_Blinkers_Left_and_Right.ino (16.9 KB)

Please modify your post and add code tags => # button above the smileys.

For Whistle patterns you might need to do an FFT to get the frequency out ?
For knocking you can simply stick with amplitude.

If you just want to check the Whistle on amplitude (so the rythm/pattern) an FFT is not needed, it should work similar to the knock sketch.

First thing to do is to start listen for a time and create an array of timestamps a whistle is detected. If it has no sound for e.g. 3 seconds it creates from the timestamps an interval array consisting of three letters. Short Medium, Long
Short being every interval between 0.1 and 0.3 second, Medium everything between 0.3 and 0.7 second and Long everything between 0.7 and 1 second. (or just use S and L)

Then you compares this "SML"-array with one or more predefined "SML" arrays.
If there is a match => action;
else => nothing
clear input arrays

Thanks for the reply, but I like having the setup be "tunable" on the go. This way each user can determine their own whistle sequence to activate each LED and it can be easily tested in the field. I still think that I have an issue within my loop. Could I set up a function to allow the program to compare the whistle with the left LED first and if it fails, then compare it to the right one? Thanks!

How does a knock pattern relate to your post title about whistle patterns ?

I believe a filter is a must to make your gadget whistle specific. Whistle 500-5000 Hz...so you may need to add a bandpass filter after the Mic, then into the arduino input pin.

I think the pattern referred to is the envelop, not the waveform of the whistle.. Then its very like detecting
a knock pattern.

The way to match several possible patterns at once that's simple is to record the pattern (of the envelope)
and then compare it several times looking for a match.

To match on the fly simultaneously is a fuzzy parsing problem which is rather more complex, as its
probably best done using multi-processing if the hardware supports this.

Alternatively you can record on the fly stopping regularly to try matching the possibillities, so long as
the matching is quick enough not to mess up the recording.