Shock formation in acoustic gravity waves