Im trying to make lights fade between colors and cut out w/ music [Help]

// color swirl! connect an RGB LED to the PWM pins as indicated
// in the #defines
// public domain, enjoy!
 
#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3
 
#define FADESPEED 5    // make this higher to slow down
 
#define SENSORPIN 9
 
void setup() {
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);
  pinMode(SENSORPIN, INPUT);
}
int LIGHT
{
  boolean soundstate = digitalRead(9);
    //delay the lights to the beat of a song
    int LIGHT1
  if (soundstate == 1) {
         analogWrite(REDPIN, 0);
         analogWrite(BLUEPIN, 0);
         analogWrite(GREENPIN, 0):
    }
  else{
    void loop() {
            int r, g, b;
 
  // fade from blue to violet
            for (r = 0; r < 256; r++) {
                analogWrite(REDPIN, r);
                delay(FADESPEED);
    }
 // fade from violet to red
            for (b = 255; b > 0; b--) {
                analogWrite(BLUEPIN, b);
                delay(FADESPEED);
    }
  // fade from red to yellow
            for (g = 0; g < 256; g++) {
                analogWrite(GREENPIN, g);
                delay(FADESPEED);
    }
  // fade from yellow to green
            for (r = 255; r > 0; r--) {
                analogWrite(REDPIN, r);
                delay(FADESPEED);
    }
  // fade from green to teal
             for (b = 0; b < 256; b++) {
                analogWrite(BLUEPIN, b);
                 delay(FADESPEED);
    }
  // fade from teal to blue
             for (g = 255; g > 0; g--) {
                 analogWrite(GREENPIN, g);
                 delay(FADESPEED);
  }
 }
}

Aside from the fact that you don’t seem to know what you are doing, what is the problem?

The code you posted won’t even compile.

The digitalRead() function does NOT return a boolean. DO not use the value as such.

You can NOT declare a function (loop()) inside another function.