I use an app called AutomateIt for doing things like this.
I have it set up to detect my work wifi and if found then it mutes my phone. When it doesn't detect my work wifi then it turns the sound back on.
It also silences my phone between 10pm and 7am and sends a text message when it detects a certain NFC tag.
It has lots of triggers and actions that it can handle. Highly recommended!
Can you tell it to shut up your phone EXCEPT text messages/phone calls?
AutomateIt does have an action called "Set Volume for Single Stream", which I think might do what you want.