With tasker you can have pretty good control p of your sound. You can establish various conditions which adjust volume of the audio streams for notification, ringer, media, alarm, etc. And you can adjust these stream volumes at a given time based on presence or absence off a particular app in foreground and perhaps even background. However if you have two apps running at three same time and outputting to the same stream (example media), then you can't use stream volume control to silence one and not the other. By the way, tasker has a steep learning curve compared to most other apps a user might encounter, but it can do amazing things.