From the time the Bet Hamikdash was destroyed, our Sages prohibited listening to songs accompanied by musical instruments (see Gittin 7a). This means that while merely singing vocally is permissible, hearing songs with musical accompaniment is forbidden, excluding a celebration of a Mitzvah in which case there is room for leniency. Indeed, the prevalent custom throughout the entire Jewish nation is to bring musicians who play and sing songs of praise and gratitude to Hashem at celebrations of a Mitzvah, such as at weddings and the like.
In more recent generations, the great Poskim have discussed this matter lengthily and they conclude that, according to the letter of the law, it is permissible to listen to songs with musical accompaniment when this music is recorded, such as on the radio, tape, etc. even if this is not being done in the context of a celebration of a Mitzvah. This custom is widespread among many great and pious luminaries who listen to recorded holy songs and music which uplift one in the service of Hashem and bring peace an tranquility to the soul.
Nevertheless, regarding the days of the Omer counting period when, as we have explained previously, the tragic event of the death of Rabbi Akiva’s twenty-four thousand students occurred, Hagaon Harav Moshe Feinstein zt”l (see Igrot Moshe, Orach Chaim, Volume 1, Chapter 166) writes that one must act stringently and not listen even to recorded music. Several other great Poskim rule likewise, including Maran Rabbeinu Ovadia Yosef zt”l.
Thus, although we rule leniently throughout the rest of the year and allow listening to recorded music, during the Omer period, one should act stringently and abstain from doing so.
Nevertheless, during a Mitzvah celebration, such as a Bar Mitzvah, Berit Milah, Siyum Masechet (meal marking the completion of a Talmudical tractate), and the like, it is permissible to play and listen to songs of holiness with musical accompaniment since even when our Sages prohibited playing instrumental music after the destruction of the Bet Hamikdash, they ruled leniently regarding Mitzvah celebrations. Thus, the same would apply to the days of the Omer in that there is room for leniency in this regard.
Maran Rabbeinu Ovadia Yosef zt”l adds (in his Chazon Ovadia-Yom Tov, page 259) that if one wishes to hold a Hachnassat Sefer Torah (Torah dedication celebration) during the Omer, it will be permissible to do so even with musical accompaniment since this celebration is considered a great Mitzvah.