xxxxxxxx does not name a type when defining a structure in a header file

Hello all.

For a school project I've been building what essentially equates to a digital tuning machine with audio and LCD output. This project requires a list of perfect pitch notes and their respective frequencies. However, since I need to call both the note name to the LCD and the frequency to the speaker via the tone() function, I decided it would be best to define a structure with those components, and then build an array to contain it.

Since we are considering using octaves 2-6, that's quite a lot of elements, so to save room I decided to define and build the array in a header file and simply include it in the .ino file. However, I keep getting the error mentioned in the title, and I cannot figure out why. It seems to imply that I'm defining my structure incorrectly, but I can't quite find an issue.

The structure is defined as follows in pitches.h:

typedef struct {
  int frequency;
  String noteName;
} noteData; 

noteData notelist[59];

Every piece of data is placed in the array in the same format, so here's a quick example of that. It's at these lines that the compiler gives me this error ('notelist' does not name a type), and does so at every one.

notelist[45] = {880, "A5"};

Do you have any idea what I might be doing wrong? Any help would be greatly appreciated. Also I'm a bit new to arduino as well, so I might have trouble understanding reasoning behind more complex solutions if some detail isn't given. Hopefully it's a simple fix.

I'm betting that the lines you say are giving an error aren't in a function and are just sitting out at global scope. They can't be there. They have to be in a function.

Progenitor:
Since we are considering using octaves 2-6, that's quite a lot of elements, so to save room I decided to define and build the array in a header file and simply include it in the .ino file.

If by "save room" you mean "save RAM", it won't.

Delta_G:
I'm betting that the lines you say are giving an error aren't in a function and are just sitting out at global scope. They can't be there. They have to be in a function.

Ah I gotcha. I didn't realize that. Since I'm trying to "keep the main pretty" as it were by defining them in the header and avoid a giant list of predetermined definitions, how would you suggest I go about this? Or is it just better to drop them in the main regardless?

gfvalvo:
If by "save room" you mean "save RAM", it won't.

No I didn't, that was probably bad phrasing on my part. I meant I'd rather not define 59 terms in the main file due to it being almost longer than the actual program. By "save space" I meant literal lines on the screen so it's easier to follow.

Define a function in the header that populates the array OR put all the initializers into braces when you create it.

NoteData notelist[numberOfNotes] = { {880, "A5"}, {440, "A4"}, {220, "A3"} };

Thanks, that helped a lot.