When fighting Ganon, if the Ocarina is played on the same frame that a bat begins to move, the bat will freeze in place. When the Nightmare of Ganon and Nightmare of Lanayru are defeated, the bat will turn into a copy of Dethyl and explode, allowing for the actual Dethyl fight to be skipped.
Though there are three Ocarina songs in the game, it is possible to perform this trick without having a song since Link will play the Ocarina regardless. This is particularly useful for Low% and Any% runs. The only Ocarina song that cannot be used is Manbo's Mambo because you will warp to the start of the Wind Fish's Egg if you play it.
In Link's Awakening DX you can use the Start and Select buttons to buffer the game. The frame you want to play the Ocarina on when you buffer is precise, but the following inputs will work every time:
In the original Link's Awakening you cannot Start Buffer due to differences in pause mechanics. Therefore, to pull the trick off you must play the Ocarina on the correct frame. If you play the Ocarina too early it is possible to continue playing the Ocarina on every frame until you hit the desired frame. If the trick is done correctly the bat will stop moving and remain in place.