I found this difficult to word well so I'll elaborate: I'm familiar with siege warfare up to the middle ages, where gunpowder wasn't a factor (except perhaps cannons) and am also familiar with the modern concept of siege warfare as was practiced in WW2, but in between there's a gap. How did sieges work in the musket and pike/full musket adoption periods where troops usually fought by standing in line to shoot each other?
With the advent of gunpowder, and particulary with the advent of mobile siege artillery, the castle became obsolete as a successful defensive structure, and a new type of defense, the "Star Fort", or "Trace Italienne" was invented.
The Star Fort was more resistant to cannon than castles, but they still could be besieged and taken. There evolved an entire military science around how to besiege Star Forts.
The traditional Medieval Castle was generally a fortified residence, offering protection for a knight and his family, and the inhabitants of the surrounding countryside. Larger castles were built by noblemen and kings. Most castles were residences, but the term was also used to describe fortifications built the same way (high walls, towers, a keep) for mostly military rather than residential purposes.
It became obvious that traditional Castles had become obsolete for defense during the "Italian Wars", 1494-1559.
These were a series of wars in Italy, involving the Italian city states and the French and Spanish.
When Charles VIII of France invaded Italy, in 1494, he brought with him the first highly mobile siege train of cannon. These soon proved to be able to very quickly defeat castles. The city of Monte San Giovanni, in the kingdom of Naples had its city walls and its castle shot to rubble after the defenders killed the French envoys. The French army then massacred the defenders. Many other, previously strong medieval castles and defenses were demonstrated to be equally vulnerable.
Castles had been shown to be unable to resist modern cannon.
By the 1520s, the "Trace Italienne" or "Star Fort" had been developed as an effective defense against cannon. Over the next 100 years, these forts spread across Europe and around the world.
The Star Fort had much lower, thicker, sloped walls, more resistant to cannon fire than the high walls of a castle. The star design and moats outside the walls were to protect the star fort from infantry assault (to which they were more vulnerable than high walled castles) by allowing cannon and musket fire from inside the walls to sweep the bases of all the walls and destroy attacking infantry.
Star forts, with their own cannon, requiring large cannon crews, were rarely built as residences. They were more often city, or purely military defenses.
The castle had been made obsolete by cannon and a new type of fortification, more effective in defending against artillery, had been developed.
http://militaryrevolution.s3.amazonaws.com/Primary%20sources/TraceItalienMR.pdf
The siege of a Star Fort involved building defensive trenches (initially outside the range of the Fort's cannon), and then advancing trenches in zig zag patterns towards the fort until the besiegers could advance their own cannon into entrenched positions in range of the Fort.
The cannon would then work to create a breach in the walls. When sufficient breach was created, an assault (led by a desperate body known as "The forlorn hope") would attack.
Military engineers were said to be able to predict quite accurately, once they knew the strength of the Fort's defenses, and the forces available to the besiegers, exactly how long it would take to advance the siege works, position the siege guns, create a workable breach, and capture the Fort.
It took a long time. And this was the purpose of the Star Fort, just as it had been for the castle before, to enable a relatively small garrison to hold out against superior numbers for a long time, to delay an advancing army, to allow defensive armies to be mustered, to hope that a relieving force would come.