The anisotropic and heterogeneous N -dimensional wave equation, controlled and observed at the boundary, is considered as a port-Hamiltonian system. A recent structure-preserving mixed Galerkin method is applied, leading directly to a finite-dimensional port-Hamiltonian system: its numerical analysis is carried out in a general framework. Optimal choices of mixed finite elements are then proved to reach the best trade-off between the convergence rate and the number of degrees of freedom for the state error. Exta compatibility conditions are identified for the Hamiltonian error to be twice that of the state error, and numerical evidence is provided that some combinations of finite element families meet these conditions. Numerical simulations are performed in 2D to illustrate the main theorems among several choices of classical finite element families. Several test cases are provided, including non-convex domain, anisotropic or heterogeneous cases and absorbing boundary conditions.