Record audio from sketch P5

Hello!

I am developing a sketch with p5.js that simulates playing drums and my idea is to play drum sounds when you press keys (already done) and to be able to record it.
The only recording examples/tutoriales that I’ve found are recording from mic but I want to record the sounds that come from my sketch. Is that possible?

Thank you!

If you already output Sounds, you could just use the variable for your output.