My Trek 1.2 had a similiar loud cracking noise that seems to come from the drivetrain, despite changing the chain, chain rings and cassette at one point as I had worn them out, the cracking noise was still evident with the new components and usually I can get three or four cracks one after the other then nothing.
But about a couple of months ago, I gave my bike a good clean, no more than usual, and it seems to have resolved the problem, but occasionally I still get just a small cracking sound.