I've learned a ton about copyright law as it applies to music in school through several classes and I figured I'd share here for everyone's benefit. Most of these are specific to the US although I suspect its pretty similar elsewhere.
Every piece of recorded music is composed of two copyrights.
The first one is the song's copyright. This is the copyright on any and all recorded versions of the music and lyrics and is handled by the songwriter and his or her publishing company. Generally (but not always) it's broken down as follows:
-50% owned by the songwriter(s)
-25% owned by the songwriter(s) publishing company - songwriters in this day and age, if they're smart, generally create their own corporation to publish their songs. This entity then signs with a larger publishing company. Basically, its a legal device so the songwriter can avoid claims on their personal possessions in court and so that they can hold on to more of their copyright in negotiations with larger publishing companies and therefore make more money.
-25% owned by the larger publishing company that the artist is signed to.
You can get into legal trouble with the songwriters OR their publishing companies if the part of the recording you sample is a recognizable part of the song (i.e. a major hook or an a capella), or if you write a song that lifts major musical/lyrical passages from a previously published work, or if you put out a cover version of someone else's song and don't pay them royalties.
Things to keep in mind:
-The songwriter is often not the same person as the artist on the recording.
-The songwriter's publishing company owns part of their song, and can therefore take legal action against you EVEN IF THE ARTIST IS COOL WITH IT. Make sure to cover all your bases because it's certainly happened before.
The other copyright is the copyright on the sound recording itself. This pertains to the particular recording you're sampling from. If an artist is signed to a label big or small, the label most likely owns this copyright one hundred percent. If the artist is unsigned, they own this copyright. You can get into legal trouble with this any time you sample from someone else's published recording (royalty-free samples you find online or on a sample CD don't fall under this category).
Things to keep in mind:
-If the artist is signed to a label, they don't own this copyright, so the label can take legal action against you EVEN IF THE ARTIST IS COOL WITH YOU SAMPLING. Like I said before, its happened in the past.
-Even if the sample you take sounds completely different in its new context, it's still subject to this copyright and you can still get taken to court over it.
This all sounds threatening, but usually these things don't go to court. Court cases are a major time commitment for everyone, create hard feelings, and usually make everyone except the lawyers poorer. Usually, the following things happen.
-You'll get a cease-and-desist notice informing you that you're violating someone's copyright and asking you to pull your tune from the market. If you comply with this, it'll probably be the last you'll hear of it.
-If you want to keep your tune out there, you can negotiate for an out-of-court settlement, wherein you come to an agreement with the party whose copyright you're violating. This usually involves money changing hands and consultations with lawyers, but it avoids the prolonged pain and suffering of actually going to court and is usually a better option than losing a court case.
-If you really believe you have the legal high ground and are not violating anyone's rights, you can consult a lawyer. This will be pricey and painful, but if the lawyers decide you've got a case, there are non-profits out there that will help you fight it with their money and legal clout in the name of setting precedents, etc. If you win, you'll have done a service for samplers everywhere.
Keep in mind relationships are very important to most people in the music business, especially among smaller artists and labels looking to get ahead, so small artists are often willing to work with you. If you're sampling from a fairly unknown recording, ASK IN ADVANCE. This avoids hard feelings, often gets you permission, and can make you a new ally in the industry - all good things. Worst case, they'll ask for money or tell you no, which sucks but it beats the hell out of finding out later.
On the flip side, major labels and larger indie labels care less about their relationship with an unknown artist than they do about squeezing you for money. Plus, they're already butthurt over copyright violations thanks to the whole piracy thing and are looking to make an example out of anyone they can lay their hands on. Besides which, they're losing money in many cases. Be very careful if you get in trouble with one of these companies as this is a situation that could actually lead to you being sued for absurd amounts of money (often completely out of proportion to the actual damages your violation of the copyright caused, which are probably negligible). These bigger players are also less likely to grant you permission to sample without asking for large sums of money in return, although you can certainly still ask. Their ignoring you doesn't constitute permission, though.
Either way, make sure you GET PERMISSION IN WRITING and SAVE IT in case the sampled party decides they wanna try and screw you over later. It avoids a your-word-against-theirs situation if you actually have evidence they gave you permission.
Finally, if you're starting to make any sort of serious headway/money with your music, I'd strongly advise you consult an entertainment lawyer. It'll cost money but they're more knowledgeable than I am about steps you can take to protect yourself from getting screwed by a sleazy operator/getting sued for everything you own and then some and could be very helpful in the long run.
Exceptions from Copyright Law
There are two major exceptions to copyright law. The first is fair use. This basically states that there are certain ways you can take from copyrighted works that will not harm the owner and therefore don't have to be cleared. (Thanks to skinsvideos21 for this info)
The following things are considered in determining whether use of copyrighted material constitutes "fair use" and therefore is not a violation of the copyright holder's rights:
-The purpose and character of the use, including whether such use is of a commercial nature or is for nonprofit educational purposes;(this one has become less important with time though as most works are intended to be commercial)
-The nature of the copyrighted work;
-The amount and substantiality of the portion used in relation to the copyrighted work as a whole; and
-The effect of the use upon the potential market for or value of the copyrighted work.
This is all very technical but two things to keep in mind:
-These are all (except for the educational one) fairly subjective and labels, especially larger ones, take a very narrow view of fair use, so you might have to fight a case even if you're right.
-Win or lose, going to court sucks, so that's probably not something you want to do unless you really feel passionately about copyright issues.
So don't lean too heavily on the fair use doctrine.
The second is public domain. Copyrights don't last forever, and once they expire, the work passes into the public domain and can be taken from freely. However, they last a long time - 70 years after the death of the LAST person with a stake in the copyright. If the stakeholders are corporations, the copyright is valid for 90 years after the date of publication. Both these terms were extended in the late 90s as some of the first copyrighted mass media symbols (Mickey Mouse, for example) neared the end of their copyrighted life, and it would not surprise me if the same thing happened again - Disney will not wanna give that one up considering they make millions on it to this day.
Anyways, stuff outside that time frame is free for the taking. A few things to keep in mind though:
-Most stuff from the rock and roll and even the jazz age is still protected.
-Sound recordings are copyrighted separately from songs, so a sample of a classical recording done last year is still technically a violation of the sound recording's copyright (although it would be difficult to tell which of the countless recordings of every famous piece was being sampled)
Anyways, if anyone has anything else or any questions, post in this thread and I'll try and include stuff/answer questions here.