Forgotten composer who played for Polish king and co-founded Edinburgh Festival rediscovered after distant relative finds online ad for his rare piano