Variable not recognized

I'm trying to make a program to play Jingle bells, but it doesn't recognize the variable 'song'. Attached is a picture of the code. Any help is appreciated, thanks!

here is the code:

const int piezoPin = 2 ;
void playSong(char songname){
int duration = 26;
int notes[]={261,294,329,349,392,440,493,523};
char notenames[]={'c','d','e','f','g','a','b','C'};
if(songname == "JingleBells"){
char song[]={'e','e','e','e','e','e','e','g','c','d','e',' ','f','f','f','f','f','e','e','e','e','d','d','e','d','g'};
int beat[]={1,2,1,1,2,1,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,};
int tempo = 300;}

int x = 0;
int y = 0;
while (x < 26){
if (song[x] == notenames[y]){
tone(piezoPin,notes[y],beat[x]*tempo);
x++;
y=0;
}
else{
y++;
}
}
void setup{
pinMode(piezoPin,OUTPUT);
}
void loop{
playSong("JingleBells")
}

the error is: " 'song' was not declared in this scope"

(deleted)

Even better, post your code in code tags along with the full error message, also in code tags. Look at your original post to see why the code tags are necessary.

int beat[]={1,2,1,1,2,1,1,1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,};

Why is there a comma before the bracket?

playSong("JingleBells")

You're missing a semicolon as well.

The playSong function expects a char (i.e. a single character) and you give it a string (array of chars).
Using strings to select a song is not a good idea. You could use enum or constants instead.

Pieter

PieterP:
Why is there a comma before the bracket?

I don't think that it matters.

This is the error I get:
crosses initialization of 'int tempo'

And here is the code:

int piezo=2;
void play(int songID){
  float bpms = 315.78;
  int a=0;
  int b=0;
  int tones[]={261,294,329,349,392,440,493};
  char notenames[]={'c','d','e','f','g','a','b'};
  switch(songID){
    case 1: 
    {float beat[]={1,1,2,1,1,2,1,1,1.5,0.5,4,1,1,1.5,0.5,1,1,0.5,0.5,1,1,1,1,2,2,1,1,2,1,1,2,1,1,1.5,0.5,4,1,1,1,1,1,1,1,0.5,0.5,1,1,1,1,4};
    char notes[]={'e','e','e','e','e','e','e','g','c','d','e',' ','f','f','f','f','f','e','e','e','e','e','d','d','e','d','g','f','f','f','f','f','e','e','e','e','f','f','f','f','f','e','e','e','e','f','f','f','f','f','e','e','e','e','f','f','f','f','f','e','e','e','e','g','g','f','d','c'};
    int duration= 51;
    int tempo=190;  // this is where the error is
    break;}
    case 2:
    {int beat[]={};
    char notes[]={};
    int duration= ;
    break;}
    case 3:
    {int beat[]={};
    char notes={};
    int duration= ;
    break;}
  }
  while(b<duration){
    if(notes[b] == notenames[a]){
      tone(piezo,tones[a],beat[b]*bpms);
      b++;
      a=0;
    }
    else{
      a++;
    }
  }
}

It worked. thanks

Wrap the contents of the case in braces ({}).

pert:
Wrap the contents of the case in braces ({}).

And, then you'll see that the new variables go out of scope before you use them.

That is NOT how to assign values to global arrays.