It looks as if your code waits for each note to complete before it goes back to handling the inputs. If you want to control the notes while they are playing, you need to play them asynchronously i.e. start them playing and then have your code go on to do other things.