divorce- who keeps the music? My ex and I were together for 10 years.  in all that time we had a joint iTunes account. I want to be separate from his account but still be able to keep the music we have jointly accumulated and paid for over the years.
is there any way this can be done? or will he gain custody of our library?
Yes, there is a way for you both to still share the music you have jointly accumulated and paid for over the years. However, this can only happen with his agreement.

Basically it involves the use of Family Sharing. 

The way you would set this up is to create a separate Apple ID for yourself (which you want to do anyway) and then invite him to be part of your Family Group (or he could create one and invite you to his).

Now, despite the above Apple page stating that all members of the Family Group pay for family purchases with the same credit card, the way to get around this is to ensure you have credit on your account (via gift cards). Below is an example of how this works.

EXAMPLE

You create an Apple ID and then create a Family Group. You then invite your Ex to be a part of that Family Group and technically this means that you agree to pay for any purchases they make via iTunes, iBooks, and the App Store. However, if your Ex has credit on his Apple ID (via iTunes gift cards) then any purchases they make directly using their Apple ID will come off their account credit. In other words, it would never come off your credit card unless they no longer had enough credit to cover the purchase. Of course, the roles could be reversed (i.e. he creates the Family Group and technically covers your purchases). Another option would be to just set up a specific debit card (e.g. Visa Debit Card) that is used for nothing else but your Family Sharing and, because it's a debit card (i.e. not a credit card), it can only spend money that's already in the account. You could each agree to put x$ into it every month etc to maintain it.

Now, I should point out that besides the fact you would both have to agree to this, this approach also means when you purchase music, an iBook, app, etc that he will be able to also download and use it (unless the author/developer has opted not to allow family sharing for that particular product). This may not be a big deal, or it may be (especially if you're concerned about privacy) because they will be able to see what you've purchased (if they go looking at the Purchased tab within iTunes, iBooks, the App Store, etc) unless you've manually chosen to hide it. Also, going down this path means you may want to selectively choose what you do activate at your end (e.g. you may not want to share your location, photos, etc).

For more information refer to:


Family Sharing
10 Things to Know Before Enabling Apple's Family Sharing