Arduino does not play the whole music sequence on the buzzer

I recently looked up on some code that plays music on buzzer and found the super mario theme on this site:

Thinking I could do other songs, I tried transcribing the song Last Surprise Last Surprise from Persona 5 (treble, C) Sheet music for Piano (Solo) Easy | Musescore.com but I found that the Arduino doesn't play every note and stops after a certain time even though the play music function is set on void loop()

Here's my code on the array

int melody[] = {/*

N_E5,N_F5,N_E5, N_D5,0, N_C5,N_D5, N_C5,N_A4,0,N_G4,N_A4,//1

N_E5,N_F5,N_E5, N_D5,0, N_C5,N_D5, N_C5,N_A4,0,N_GS4,//2

N_E5,N_F5,N_E5, N_D5,0, N_C5,N_D5, N_C5,N_A4,0,N_G4,N_A4,//3

N_E5,N_F5,N_E5, N_D5, 0, N_C5, 0, N_D5, 0, N_A5, 0, N_G5, 0, N_F5,//4

N_E5,N_F5,N_E5, N_D5,0, N_C5,N_D5, N_C5,N_A4,0,N_G4,N_A4,//5

N_E5,N_F5,N_E5, N_D5, 0, N_C5, 0, N_D5, 0, N_A5, 0, N_G5, 0, N_F5,//6

E7,F7,E7, D7,0, C7,D7, C7,A6,0,G6,A6,//7

E7,F7,E7, D7, 0, C7, 0, D7, 0, A7, 0, G7, 0, F7,//8

//START

*/

0,G7, E7, A6, C7, D7, E7, 0, E7, D7,

0,C7, C7, C7, 0 , C7, C7, C7,

0,C7,E7,D7, A6, 0,

0,G7, E7, A6, C7, D7, E7, 0, E7, D7,

0,C7, C7, C7, 0 , C7, C7, C7,

0, A6, A6, A6, 0, A6, A6, A6,

0, A6, C7, D7, E7, E7, E7, E7,

E7, C7, A6, E7, E7, D7,

D7, D7, G7, G7, E7, C7 ,

A6, G6, A6, 0,

0, A6, C7, D7, E7, E7, E7, E7,

C7, A6, E7, E7, D7,

D7, D7, G7, G7, E7, C7,

A6, C7, D7, 0, D7, D7,

//YOULLNEVER

D7, F7, D7, A7, C8,

};

//Mario main them tempo

int tempo[] = {

/*

24,24,24,24,24,24,24,24,12,12,

24,24,24,24,24,24,24,24,6,

24,24,24,24,24,24,24,24,12,12,

24,24,24,24, 24, 24, 24, 24, 24,

24,24,24,24,24,24,24,24,12,12,

24, 24, 24, 24, 24, 24, 24, 24, 6,

24,24,24,24,24,24,24,24,12,12,

24,24,24,24, 24, 24, 24, 24, 24,//8

*/

//START

24, 24, 24, 12, 12, 16, 16, 16,//9

12, 24, 24, 12, 24, 24,

12, 24, 12, 24,

24, 24, 24, 12, 12, 16, 16, 16,

12, 24, 24, 12, 24, 24,

12, 24, 24, 12, 24, 24,

12, 12, 12, 12, 12, 12, 12,

12, 12, 12, 6, 6, 24,

12, 12, 6, 12, 12, 12,

12, 12, 12,

12, 12, 12, 12, 12, 12, 12,

12, 12, 6, 6, 6,

12, 12, 6, 12, 12, 6,

12, 12, 6, 12, 12,

//LAST SURPRISE

12, 12, 6, 3

};

Everything down and up mostly remains the same

Full code here: /* Arduino Mario Bros Tunes With Piezo Buzzer and PWM Connect the pos - Pastebin.com

I intentionally put some comment markers to test if it does play and found out it stops after a few notes. I checked the Super Mario theme and found it wasn't very note heavy. I also found someone doing the Titanic music link here and found it plays for more than 30 seconds while mine could barely last 30 seconds. I couldn't understand the code though since it seems to be in Spanish. Could anyone help?

How did you even do that quote thing? I can't imagine.

:o

Seriously, :o :o

Maybe i could imagine worse ways of posting code, but I don't want to.

But anyway, the sizes of melody[] and tempo[] don't match.

oqibidipo:
:o

Seriously, :o :o

Maybe i could imagine worse ways of posting code, but I don't want to.

But anyway, the sizes of melody[] and tempo[] don't match.

I get it, the mario guy did put a tempo even for the 0 notes. Thanks for pointing it out. Sorry about the terrible code posting, I don't see a post code option on the forum