The Musical Offering ( German title Musikalisches Opfer or Das Musikalische Opfer ) , BWV 1079 , is a collection of several pieces of music by Johann Sebastian Bach . The Musical Offering ( German title Musikalisches Opfer or Das Musikalische Opfer ) , BWV 1079 , is a collection of canons and fugues and other pieces of music by Johann Sebastian Bach , all based on a single musical theme given to him by Frederick II of Prussia ( Frederick the Great ) , to whom they are dedicated .