I'm not sure if
#if !defined(UBRR1H)
is defined or not. The hash
# before the
if indicates that the code between that line and the
#endif will only be copied to the ESP32 if
UBRR1H is not configured in the code somewhere. The ESP32 itself won't use that IF statement.
In your code you appear to have different references to serial -
mySerial ... Serial ... Serial1 ....
You can probably tidy the code to only reference one name, unless you are really using multiple serials.
It's possible that your program is using more than one serial interface, but only one can be hardware, so that is why there is a software serial. At a guess the program is using hardware serial to drive an MP3 module and software serial to output debug code.
Debug code doesn't need to be fast or partially efficient, but the MP3 module does.