How to record output audio

I have an app that produce kind of sounds / music taping buttons. I need to record those sounds as I play with the app. I cannot find any doc or example about this issue. I have tried with many approaches but I couldn't get any good result. Any insight ?

How to record output audio
 
 
Q