I recently came across a short piece which I decided to try and analyze, but I have some questions about it. I am still a bit new to music theory but if I'm correct, most instances of non-diatonic notes/chords are instances of secondary dominants or borrowing from the parallel minor key.
However, measure 21 confuses me. In the measures leading up to it, E and C are played with a "bass note" which steps down chromatically from A to Ab (or is it G#) then to G then to Gb. The way I interpret this is using a vi chord, then the Ab is borrowed from the minor key in the context of the very common iv chord, then we have the I chord, then this mysterious Gb/F# shows up.
Thus my question: Why does this sharp 4, then followed by a 3, sharp 4, and a 1 work well? Is it just the chromaticism set up by the previous measures, or is there more going on? Maybe something lydian related?
Also, on more than one occasion, the song uses the notes Bb, E, and G to form what I believe is a diminished chord. It is then followed by the V/ii, as in measures 5-6 and 12-14. Again, chromaticism supports the Bb in the previous measures.
In short: What is "going on" with 1-3-#4 and 3-5-b7 chords in a major key? Why do they work well? Also, do you know of any other pieces which have these?