Sounds like something is going on with your transmission/flywheel/torque converter, not a mechanic but sounds like somethings slipping inside.
I gather that since it only happens when its in gear and your applying the brake.
You should apply your parking break, put your car in gear, then carefully check the engine and try to find exactly where this sound is coming from. Just make sure your car does not roll away, or have someone be inside while you check, you may or may not hear the knocking sound with the parking brake vs the pedal brake, if the noise only occurs when applying the pedal brake, you will have to get someone to press it for you, or prop it down with something while you check.
Old Car: Chevy Cobalt 2006 LS Sedan base (Automatic)
New Car: Chevy Impala 2011 LT Fully Loaded (Automatic)