How can i record audio played from speakers while game is running?

What i need is to record audio from speakers while game is running and save it to .wav file.

You could use an audio editor such as Audacity to record the signal, there are tons of tutorials on Youtube that show how to record the “what you hear” mix.

Alternatively, if you have some video capture software you could just record a video of what you’re after and export the audio from it as a separate wav file.

Thanks for response Rusty_1607.
I just wanted to know is there any method that i can do it programmatically using c++ and UE4 engine API, wihtout any 3rd party programs, like access rawPCMdata of audio buffers while game is running.
I found this plugin GitHub - kwstasg/WAC: UE4 Visualization Plugin - Windows Audio Capture (WAC) is an Unreal Engine 4 plugin that captures live audio from the windows default audio device and analyse it to frequency values. , but its using WASAPI to capture audio real time. And problem with it that , it will capture everything playing at that moment. All i need is to capture only in-game audio and record it.