micro-nova / AmpliPi

Whole House Audio System 🔊
https://amplipi.com
GNU General Public License v3.0
289 stars 23 forks source link

Feature Request: Per Zone Volume for Announcements #292

Open bs42 opened 2 years ago

bs42 commented 2 years ago

I recently started to use the Announcements feature (love it BTW) and find that I would really like the ability to have the volume configured per zone.

Use Case:

I have automations that change the volume in the house based on time of day, so at night I have the volume low, daytime higher, etc. This precludes the option to use the "current" volume for any high priority type announcement such as "Exterior Security Door Opened!" as I don't want that to be a whisper obviously.

Then there are the pre-out zones, those need to be 100% volume all the time because their volume is controlled by the device they are connected to.

Implementation idea:

Since no one likes breakage, I was looking over the existing methods and I think potentially the easiest method to implement this request would be to leverage the "presets", (not knowing the backend of this I could be wrong), but the idea being that /api/announce would add an option along side zones or groups called preset and it would exclude vol,zones,groups if provided and would be able to have a list of zones and their volumes for this announcement call, and then restore back to the previous values when done.

linknum23 commented 2 years ago

Adding a preset option should be very easy to implement for announcements especially since behind the scenes announcements actually create a temporary preset for the specific purpose of setting volumes. The preset option would just replace that.

Here's where presets are used in the announcements: https://github.com/micro-nova/AmpliPi/blob/main/amplipi/ctrl.py#L929

It looks like we would just need to make a temporary copy of the preset given and configure the source id of each of the groups and zones in the preset. Using this idea missing zones from the preset given would likely not get the announcement.

linknum23 commented 2 years ago

Something similar is possible in 0.1.8 by using the vol_f (instead of the vol) field and changing the max volume of each of the zones max volumes using the vol_max field. For your use case I would recommend having a preset for each time of day that configured each of the zone's max volumes and add automation to execute the preset on each time transition.

Here's what a couple of the presets would look like in Jason's (simplified) house:

Sleeptime

    {
      "name": "Sleeptime",
      "state": {
        "zones": [
          { "id": 0, "vol_max": -40, "name": "Dining" },
          { "id": 1, "vol_max": -40, "name": "Living"  },
          { "id": 2, "vol_max": -40, "name": "Kitchen"  },
          { "id": 3, "vol_max": -40, "name": "Basement Workshop"  },
          { "id": 4, "vol_max": -40, "name": "SW Office"  },
          { "id": 5, "vol_max": -40, "name": "HW Office"  }
        ] 
      }
    }

Office Hours

    {
      "name": "Office Hours",
      "state": {
        "zones": [
          { "id": 0, "vol_max": -20, "name": "Dining" },
          { "id": 1, "vol_max": -20, "name": "Living"  },
          { "id": 2, "vol_max": -20, "name": "Kitchen"  },
          { "id": 3, "vol_max": -10, "name": "Basement Workshop"  },
          { "id": 4, "vol_max": -25, "name": "SW Office"  },
          { "id": 5, "vol_max": -25, "name": "HW Office"  }
        ] 
      }
    }

A basic announcement using vol_f, uses vol_max to adjust the volume proportionally for each zone, would look like:

{
  "media": "https://www.nasa.gov/mp3/640149main_Computers%20are%20in%20Control.mp3",
  "vol_f": 0.5
}

PS: You can also try increasing a zone's vol_min adjustment to make the full volume range more useful per zone

bs42 commented 2 years ago

I'll have to give that a try.

One minor nit though, I notice it's not possible to set the min vol to 100%, do you think we could get that in an update? For the line-out I need 100% or else it's almost inaudible.

linknum23 commented 2 years ago

Right now the API actively prevents the user from making a configuration that has a range less than 20dB to keep the volume slider from becoming too granular. This is a use case we did not consider. Let me talk to the guys and see if this makes sense. We could probably just add a message in the UI instead of actively preventing a 0dB range.

linknum23 commented 2 years ago

We added an issue for this: #328