As the old saying goes, “A good composer does not imitate; he steals.” But don’t expect that argument to hold up when you wind up in copyright court. Incidentally, copyright law varies, so investigate ...