You can try cleaning it with a Rug Doctor thing that you can rent from most grocery stores (if you don't have a deep cleaner). If that doesn't work your only option is to remove the carpet...which I would strongly suggest. That musty smell may be mold.
The carpet might be dry, but what about the padding underneath the carpet. I'm guessing that's where the smell is coming from. You could try cleaning the floors with some sort of mold killing chemical and a vacuum. Or you might just have to rip up the carpet and replace the pad.
As others have stated, the carpet pad could be causing the odor even though the carpet is thoroughly dry. Replace the pad and buy some containers of damprid and place around the basement. Damprid is highly effective at removing the musty smell you described.