You might look into OBS and/or VoiceMeeter to see how streamers selectively route audio while livestreaming/recording video/audio streams.
https://obsproject.com/
https://voicemeeter.com/