Duplicate Code in PX4Firmware - is it neccessary?

Hello, I was modifying some of the tone_alarm tunes and nothing was working. I eventually realized that I was modifying the tone_alarm.cpp file in:
\ardupilot\modules\PX4Firmware\src\platforms\posix\drivers\tonealrmsim

There was however a second tone_alarm file in:
\ardupilot\modules\PX4Firmware\src\drivers\stm32\tone_alarm

Modifying this file resulted in the changes I wanted. So my question is, why is this file duplicated? If they are both under PX4Firmware/src/ doesn’t that mean that they both get compiled and loaded onto the board?

Also, I have been looking through the tone_alarm class, searching for a method to pass a string containing a tune too. It would be nice to be able to play tunes from the main loop. If this is currently not possible I will write a method that enables this. In order to do this I would appreciate anyone pointing me to the location where the init tone alarm tune is first called from. Then I can mimic the call, but add some logic to the tone alarm class that allows a string with a valid tune to be passed to it.

Sorry for the double question, I will appreciate any knowledge people pass my way.

Thanks-

DCraig