Seperated some of the often-used code into functions in playNote.