For example, every scale has a given set of notes. But is it possible that there's a composition which doesn't fall into one particular scale?
No, not all songs have to be in a major or minor scale. All that it takes to prove this is to find one example that goes against the rule:
This melody, which has both C♯ and C♮, cannot belong to a single major scale. (It also has both F♯ and F♮.)
Most compositions, however, do have what we call a tonic. This is a pitch center, a "home base" of sorts, to which most works will return. However, all pitches in a work do not have to belong to a member of the tonic pitch's scale.
The pitches that belong to the tonic scale are what we call diatonic pitches. Chromatic pitches are pitches that don't belong to the tonic scale, and they are very, very common.
A composition can certainly have random notes that don't belong to the tonic's major or minor scale, but often there is an underlying logic to which pitches are used. Thus the pitches aren't "random," but often have some function that relates to the sounding pitches.
Your question is well-formed and a good one, but I will make one correction: "Can a song have random notes that belong to any major or minor scale?" The fact is that any pitch will belong to some major or minor scale (however theoretical), so it's impossible (as I see it) for a note not to belong to any scale.
The answer is basically you can do what you want, nothing has to be anything in music.
The less trivial answer depends a bit on what you mean. Pieces generally are not described as being in a scale. They are often described as being in a key which has a scale associated with it, but any piece that's more than a simple tune will certainly have notes that are not in the scale associated with the key. Take for example the second note of Beethoven's Für Elise - the piece is in the key of A minor, the second note is a D-sharp. D-sharp is not part of the A-minor scale, but the piece is clearly in A-minor.
It's also possible for a piece not to be in a key, or for the key it is in to be ambiguous. 19th century European music has many example of pieces where the key is difficult to pin down as the composer exploits ambiguity in tonal relationships. A classic example is the first song in Robert Schumann's song cycle Dicterliebe — Im wunderschönen Monat Mai. The key signature has three sharps suggesting A major or F-sharp minor, but it neither begins nor ends on one of those chords and most of the piece shifts between tonalities.
In the 20th century, of course, we get works from a lot of composers including those of the New Viennese School, like Schoenberg and Webern, that explicitly avoids any association with keys writing music described as atonal. You also find microtonal which truly has notes that are not part of any major or minor scale because the composer is asking for smaller divisions of the octave than major or minor scales can accommodate.
There's alot of different types of scales, apart from major and minor. For example: you cannot produce the song, Misirlou in a major or minor scale; you'd have to play it in a special scale called the Phrygian Dominant. And this song, Scarborough Fair, is in Dorian.
But to go to the essence of your question, every song (for the most part) has a certain scale, basically everything you hear on the radio.
There was a study on this on Spotify. Where 66.1% of songs accounted for a major scale, and 33.7% were minor. Which comes out to 99.8% either being in a major and minor scale where the rest 0.2% is other scales or modes (which are also scales btw). 0.2% that seems low. maybe there's a problem in their study. not sure. But regardless, major and minor scales seem to be the most "popular" in western culture.
Similarly, if you look at National Anthems Map. The majority are either in major or minor.
Also there's another study that hooktheory did who analyzed 1300 songs.
Songs may have notes that go outside of a scale from time to time (due to secondary dominants, chromaticism, mode mixing, etc), but the majority of the notes will fall into a certain scale and songs are generally identifiable by their scale/key. That's why musicians spend many hours learning and practicing scales, because they are the basis of music, as both the melody and harmony is derived from a scale. If a song shifts between multiple scales it's called a modulation.
There are no laws forbidding you to include anything in a composition. Any note is allowed, even "false" notes. Some examples are (I suggest doing some googling):
- Twelve-tone technique
In some genres of music, the conventions are more rigid in some less. In beginning music theory you will learn about some of these more or less traditional conventions. One example is staying in a certain key or succession of keys: say I, V, IV (example C,G,F). Another example might be staying in a specific scale: say Mixolydian. Learning and knowing how to use these conventions is one part of the handicraft of composing. It might help, or it might hinder depending on where you want to go.
Do all songs have to be in a major or minor scale?
No, definitely not! Have a look at https://en.wikipedia.org/wiki/List_of_musical_scales_and_modes to start to get an idea of the possibilities...
every scale has a given set of notes
Hmmm.... I don't think even that's necessarily true - or to put it another way, a scale isn't necessarily only defined as a given set of notes. For example, the blues scale, when played on instruments that allow it, implies bending certain notes within certain ranges - and that can be seen as part of what it means to use that scale.
But is it possible that there's a composition which doesn't fall into 1 particular scale?
It depends what you mean. Often when we talk about the scale used by a piece, it's only an approximation of the tonality of the piece, and notes outside the scale are expected. Outside of that, a piece might use a definite set of notes without a well-known name, or it might not restrict itself to a definite set of notes. Many songs also use sounds with timbres that might make identification of exact pitch uncertain.
And of course, some compositions have one or more obvious key changes - meaning that they move from using one scale to using another.
No, they don‘t: Even if there no scale exists the composer may everytime invent an own new scale.
Most of the answers seem to imply that 'keys' are central to music. There are also some conflicting definitions involved - Bach's famous C-major Prelude has sharps and flats everywhere, but most musicians would say that the piece is definitely in C-major, with some "accidentals" thrown in. Most music derived from European cultures works this way, with a central key departed from by harmonies or accidentals to create tension, which then is released by returning to some simple harmony based on that key. But there are other kinds of scales, in, e.g., Iranian or Chinese music; other kinds of criteria for creating satisfying music, in, say, Indonesian gamelan or Indian raga music; and even just doing without any kind of center the way many modernists do. This last kind of music can sound cacophonous, but can also be beautiful, singable, and approachable. Examples:
Bach, 1st C Major Prelude, BWV846:Iranian: some classical Persian folk music: Chinese: Ballad of North Henan Province: Gamelan: Sound Tracker [?]: Raga: Anoushka Shankar et al., "Joug"[?]: Anything Goes: William Schuman, “Prayer”, from his opera The Mighty Casey:
Wikipedia has a lot of information about these forms and, of course, a whole heck of a lot of other stuff, related and not.
Yes, if your intention is to commercialize it. No, if you don't care that no one will ever want to listen to it.
Most commercial music fits rather nicely into a scale; in that way, often music written with the purpose of making money tends to "play by the rules" more than music that is written without that intent, as it is more of a safe bet to stick to the basics (listeners tend to like familiar things).