Assigning a specific colour to a specific musical note played by a buzzer?

Hey, I'm new to the whole maker thing and I'm actually taking a class at my college on arduino programming. I'm having a little trouble with one of the thing's I'm working on where we had to compose a song on our arduino leonardo's with 321 make boards. I got through most of it just fine (assigning a button press to play a 15 second song loop) but I'm having trouble with the second part. I'm supposed to map a colour to each tone that's played so each time a note is played it makes it's own little light show.I tried using an if statement with something to the effect of

if (tone(buzzerPin, NOTE_F4, 500)){
    digitalWrite (RGBRedpin, HIGH);
  }

I've cut out most of the song so you guys don't have to sift through as much. I appreciate any help that I can get.

#include "pitches.h";
int buzzerPin  = 5 ;  //The buzzerPin is connected to pin 5 of the Arduino.
int button1Pin = 2;   //The SW1 button is connect to pin 2 of the Arduino.
int RGBRedPin = 9;    //The red RGB LED is connected pin 9 of the Arduino.
int RGBGreenPin = 10; //The green RGB LED is connected pin 10 of the Arduino.
int RGBBluePin = 11;  //The blue RGB LED is connected pin 11 of the Arduino.
int Color;



void setup() { //The Setup function runs once.
  pinMode(buzzerPin, OUTPUT);  //Setup red LED pin as an output pin.
  pinMode(button1Pin, INPUT);  //Setup button1 pin as an input pin.
  pinMode(RGBRedPin, OUTPUT);    //Setup red RGB LED pin as an output pin.
  pinMode(RGBGreenPin, OUTPUT);  //Setup green RGB LED pin as an output pin.
  pinMode(RGBBluePin, OUTPUT);   //Setup blue RGB LED pin as an output pin.
  Serial.begin(9600);
}

void loop() { //The loop function runs forever.
  if (digitalRead(button1Pin) == LOW) { //Check to see if button1 is pressed.

    //Opening repeating thing
    tone(buzzerPin, NOTE_D4, 500);
    delay(204);
    tone(buzzerPin, NOTE_D4, 500);
    delay(204);
    tone(buzzerPin, NOTE_D5, 500);
    delay(204);
    tone(buzzerPin, NOTE_A4, 500);
    delay(204);

}
}

Hi

When you doif (tone(buzzerPin, NOTE_F4, 500)){what do you think the if is testing? What does tone() return that is important for you to test?

If instead of calling the built-in tone() function you were writing your own function, which would call tone(), then in that function you would have access to the frequency, may be you could do something smart with it...

I'll admit, I really am bad at this. I was assuming that the if statement would be checking if that statement was true/running. I know theres probably a value I need to use but I'm completely lost on this

Read again above, was editing as you typed and there is also this reference material worth checking

I'm sorry, I'm still not sure if i'm following

The tone() function is non blocking so right after calling a tone() and before the delay you could handle the RGB led the way you want

    //Opening repeating thing
    tone(buzzerPin, NOTE_D4, 500);
    analogWrite(RGBRedPin, RRR);
    analogWrite(RGBGreenPin, GGG);
    analogWrite(RGBBluePin, BBB);
    delay(204);

But If instead of doing

    //Opening repeating thing
    tone(buzzerPin, NOTE_D4, 500); // the 500 is useless by the way since you delay less than 500
    delay(204);
    tone(buzzerPin, NOTE_D4, 500);
    delay(204);
    tone(buzzerPin, NOTE_D5, 500);

you were doing

    //Opening repeating thing
    myTone(buzzerPin, NOTE_D4, 500);
    delay(204);
    myTone(buzzerPin, NOTE_D4, 500);
    delay(204);
    myTone(buzzerPin, NOTE_D5, 500);

and in the code above the setup() if you were to define

void myTone(uint8_t pin, unsigned int frequency, unsigned long duration)
{
  tone(pin, frequency, duration);
  //... SOMETHING ELSE HERE ...
}

what could that SOMETHING ELSE be?