Trio sonata

A trio sonata is a type of music for four instruments which was very popular during the 17th century and early 18th century: the period known as the Baroque period.
A trio sonata is written for three voices (three parts), in other words, it can be played by three different instruments. The two upper voices share the same musical themes. They often imitate one another. They are of equal importance. The third part, the lowest part, is played by basso continuo, which means the accompaniment. This continuo is usually played by two instruments: typically a cello or bass viol and a keyboard instrument such as the harpsichord. That makes four players, of course. However, the harpsichord player’s left hand notes are the same as the cello’s notes. This is the “third” part of the trio.
Some of the best trio sonatas are those by Arcangelo Corelli. His collection of trio sonatas numbered opus 1 and 3 are sonata da chiesa: four movements (slow-fast-slow-fast) finishing with a fugue. His op 2 and 4 sonatas are sonata da camera type: each movement is a kind of dance. Corelli’s trio sonatas are for two violins and continuo. 
Johann Sebastian Bach wrote a trio sonata in "The Musical Offering" for violin, flute and continuo. 
Bach also wrote six trio sonatas for organ. These are played by one player. The organist’s two hands each play on different manuals (keyboards) so that they sound like two different instruments. The organist’s feet play the third part on the pedals. Each part is strictly a single line (no chords, never more than three notes at a time) so that these works can also be played by other instruments (e.g. two violins and cello with harpsichord).
Bach also wrote sonatas for one melodic instrument and harpsichord. These pieces are really trio sonatas, although he does not call them trio sonatas. The melodic instrument (normally violin or flute) plays the top part, the harpsichordist plays the second part with his right hand, and the third part is the lowest part of his left hand notes.
Some other composers who wrote trio sonatas are Tomaso Albinoni, Henry Purcell, Dieterich Buxtehude, George Frideric Handel, Georg Philipp Telemann, Johann Pachelbel and Antonio Vivaldi.