At a German royal court, what would a 'Kapellmeister' have been in charge of?

History Trivia: At a German royal court, what would a 'Kapellmeister' have been in charge of?