Detecting presence of music in ambient sound
This is a tough problem. The music identification service Shazam actually has a database of acoustic fingerprints for songs. Music is composed of many variable acoustic components and there are a slew of algorithms that may be used to estimate several components. One simple example would be the zero crossing rate, which is a time domain algorithm. I would refer to this link on the subject for a brief overview of pitch detection algorithms and go from there.