Play Melody

If I hook it up to a speaker will I have to rewrite my whole code??