The mechanics of dunes and antidunes in erodible-bed channels