A numerical model for linearized gravity and acoustic waves