メロディーのついでみたいに
Actually, there is に there. みたい is just inserted between ついで and に.
ついで performs as a noun, so メロディーのついで has the same structure as 学校に行くついで or そこへ行ったついで in the dictionary. (You can think it as メロディーを弾くついで.)
「音楽室の匂いって、今も昔も変わらないわね」先生はそういうと、今度は両手でピアノを引きはじめた。
これは、、、校歌?
「先生は晴小の卒業生なのよ」
メロディのついでみたいにこぼれた先生のことばに、ノンが反応した。
「先生、このへんに住んでいたんですか」
「そう、高校生のときに引越してしまったけれど」
Read carefully the line after 「先生は晴小の卒業生なのよ」, and notice the function of the sentence final particle よ. This is the teacher's words, not the narrator's question.