dnd 5e – Does playing magical music count as casting a spell?

Only your DM can answer this question

It seems that this musical fragment is a homebrew creation of your DM. If your DM has given you an actual item description with precise mechanics, look over them carefully to see if it is mechanically casting a spell. Regardless, you must check with your DM for this, because they are the one who created the item and decided how it works. You can ask out of character (“Does this count as casting a spell?”) or in character (“Does this feel similar to my normal bardic spellcasting, or is it different?”), but your DM is the only one who can answer this.

It might not actually matter as much as you think

Given that this musical fragment deals damage, it seems quite likely that your DM will declare that breaks invisibility like an attack or spell, even if it isn’t considered one. Furthermore, even if the DM allows you to remain invisible, keep in mind that once you play the fragment, you are no longer hidden — that is, enemies now know your position from the sound you made, even if they can’t see you. And unless you’re a rogue who can hide as a bonus action, you’re likely going to remain un-hidden while the enemies take their turns. They’ll have disadvantage to attack you, but you can still be attacked, and hit with most spells.