# Arduino Tone Project (More Complex)

I am wanting to run a project similar to the Arduino Tone project. I have an amplifier circuit connected to an 8 ohm speaker to play the tones. My problem is dealing with larger songs and wanting to make them simpler. I need help with the 2D arrays. For Example:

Rockabye Baby

int RockabyeMelody = {
{NOTE_A4, NOTE_C5, NOTE_A5, NOTE_G5, NOTE_F5, NOTE_A4, NOTE_C5, NOTE_F5, NOTE_E5},
{NOTE_AS4, NOTE_C5, NOTE_AS5, NOTE_A5, NOTE_G5, NOTE_G5, NOTE_F5, NOTE_D5, NOTE_C5},
{NOTE_A4, NOTE_C5, NOTE_A5, NOTE_G5, NOTE_F5, NOTE_A4, NOTE_C5, NOTE_F5, NOTE_E5},
{NOTE_D5, NOTE_C5, NOTE_F5, NOTE_AS5, NOTE_A5, NOTE_F5, NOTE_G5, NOTE_D5, NOTE_E5, NOTE_F5}
}

int RockabyeTiming = {
{4, 4, 4, 2, 4, 4, 4, 1},
{4, 4, 4, 2, 4, 4, 4, 4, 1},
{4, 4, 4, 2, 4, 4, 4, 1},
{4, 4, 4, 4, 2, 4, 4, 4, 4, 1}
}

Now my problem is that I am unsure whether I have to declare the exact size of the 2D array or not? Some of the lines or the song are longer than other so how can I have a perfectly square 2D array?

Would the suggestion be to add zeros at the end of the array and then when looping through, if a 0 is found then skip to the next loop?

I am hoping that I can set it up similar to below and run itâ€¦

void setup() {
for (int row = 0; row < 4; row++) {
for (int note = 0; note < 10; note++) {
int noteDuration = 1000/RockabyeTiming[row][note];
tone(8, RockabyeMelody[row][note],noteDuration);

int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
}
}
}