When your diaper have a 'litterbox' or 'barn-smell' it's because they are not getting completely sanitized in the wash.
Poop has a chemical called urease which reacts immediately with a chemical in pee called urea. When urease is left behind after washing, the moment it comes into contact with pee you get a chemical reaction that immediately produces ammonia. Mother nature's way of breaking down barnyard waste.
The solution is to dial in the wash routine. Common solutions are:
1) Proper dosing detergents. Diaper manufacturers know detergents take a toll on fabrics so they often recommend low dosing to extend their product's life. Low dosing=low-cleansing, always follow the instructions on the detergent box/bottle -- not the diaper.
2) If you have hard water, you might need to change to a big-box-brand. Botique detergents are quite capable in soft water, but most perform poorly in moderate to hard water situations.
3) Tumble dry. Tumble drying mechanically loosens particles left behind after washing, the heat also helps kill off any residual bacteria that may be in the diaper.