You don't want "acoustical foam".
You want Owens Corning 703 insulation, or Roxul R6 Comfortboard. Both absorb a much broader frequency spectrum than the crap that Auralex etc. tries to pass off as acoustic treatment, plus they cost far less per square foot. And they're easy to cut, shape, and mount.
Check your preferred hardware stores.