Language and music as cognitive systems