Musical improvisation (also known as musical extemporization) is the creative activity of immediate ("in the moment") musical composition, which combines performance with communication of emotions and instrumental technique as well as spontaneous response to other musicians. Sometimes musical ideas in improvisation are spontaneous, but may be based on chord changes in classical music and many other kinds of music. One definition is a "performance given extempore without planning or preparation". Another definition is to "play or sing (music) extemporaneously, by inventing variations on a melody or creating new melodies, rhythms and harmonies". Encyclopædia Britannica defines it as "the extemporaneous composition or free performance of a musical passage, usually in a manner conforming to certain stylistic norms but unfettered by the prescriptive features of a specific musical text. Improvisation is often done within (or based on) a pre-existing harmonic framework or chord progression. Improvisation is a major part of some types of 20th-century music, such as blues, rock music, jazz, and jazz fusion, in which instrumental performers improvise solos, melody lines and accompaniment parts.
Throughout the eras of the Western art music tradition, including the Medieval, Renaissance, Baroque, Classical, and Romantic periods, improvisation was a valued skill. J. S. Bach, Handel, Mozart, Beethoven, Chopin, Liszt, and many other famous composers and musicians were known especially for their improvisational skills. Improvisation might have played an important role in the monophonic period. The earliest treatises on polyphony, such as the Musica enchiriadis (ninth century), indicate that added parts were improvised for centuries before the first notated examples. However, it was only in the fifteenth century that theorists began making a hard distinction between improvised and written music.
Some classical music forms contained sections for improvisation, such as the cadenza in solo concertos, or the preludes to some keyboard suites by Bach and Handel, which consist of elaborations of a progression of chords, which performers are to use as the basis for their improvisation. Handel, Scarlatti, and Bach all belonged to a tradition of solo keyboard improvisation, in which they improvised on the harpsichord or pipe organ. In the Baroque era, performers improvised ornaments and basso continuo keyboard players improvised chord voicings based on figured bass notation. However, in the 20th and early 21st century, as "common practice" Western art music performance became institutionalized in symphony orchestras, opera houses and ballets, improvisation has played a smaller role. At the same time, some contemporary composers from the 20th and 21st century have increasingly included improvisation in their creative work.
In Indian classical music, improvisation is a core component and an essential criterion of performances. In Iranian,Indian, Afghan, Pakistani, and Bangladeshi classical music, raga is the "tonal framework for composition and improvisation". The Encyclopædia Britannica defines a raga as "a melodic framework for improvisation and composition".