Do woodpeckers live in your vicinity ?
That rattling sound with a few slower bangs after it really sounds like a woodpecker hammering.
The other noises are certainly birds.
That isn't necessarily inside your attic. You be surprised how sound can carry through a structure if it is being knocked on from the outside. And an attic in particular can act like a sound-box amplifying sounds in a strange way.
I would take a flash-light and get into the attic space.
Wait until it starts again (might take a while) while keeping still. You might see movement from bird activity or get a better feel from where the sounds are really come from.