For example, in 何曲か歌った (I sang several songs), is it なに or なん?
IIUC from here (I hope it's correct?), it is なに before nouns (except 何曜日、何日、何月), and なん before counters. But 曲 can be either, so I'm not sure.
A couple other links I found are this one and SE, but they don't seem to cover this case.