Under certain circumstances, it is possible to use copyrighted material without asking permission from the creator. This concept is called fair use.
In the case of Girl Talk, the artist claimed the use of samples of 372 songs was not a violation of copyright due to the fair use exception.
Fair use is a relatively subjective determination, and is decided by the “four factor analysis.”
According to the U.S. Code, fair use claims are based on:
These considerations are guidelines for courts, but different judges weigh these factors in different ways. There are online tools available to help you determine if your situation qualifies as fair use.
A word to the wise:
There are also specific exceptions for educational purposes.