I want to write a couple of methods that generate simple, but specific tone patterns or melodies on a piezo with an UNO board, while still allowing a central process to run. This central process generally will consist of 1) printing to serial output, 2) waiting for user serial input, and 3) reading pin values. Think video games where the sound output is independent from user input or the program state.
The first thing came to me was protothreading or RTOS, but I want to know if there is a simpler method of accomplishing an independent sound output without going down that rabbit hole. The blink w/o delay method isn't what I want since it relies on polling within the main loop to enforce intervals; I want a method that is called once and accurately plays a melody until called to stop.
I'm not sure if what I want is even possible without protothreading, which is why I'm turning the the community for help. Suggestions on possible approaches are welcome, and if protothreading really is the best method, that is good info to know as well.