Apart from directly buying digital music files, there are a few ways in which you could possess such files legally (at least in my country):
- Creating them from CDs you legally own, to make listening on the go more convenient. I believe this is legal in the U.S.
- Receiving them from a close acquaintance, who have a legal right to possess those files. This is legal in my country, but I'm not so sure it is in the U.S.
While at least the first category (as far as I know) is legal in the U.S. as well, there really is no way for border agents to know, for any given music file, whether I'm legally allowed to have it or not.
If I, a foreign national from a visa waiver program country, were to arrive from overseas at a U.S. airport while carrying a phone, laptop or other storage device containing files in either of these two categories, how likely am I to get in trouble (as in, getting held up or detained, having devices confiscated, etc.) with the CBP?