How/where can i do record function

I made a synthesizer from the audio programmers tutorial.

I would like to make my standalone application able to record midi or audio. How can I do it and where to put the code in the program?
I’m a programming idiot. I need help.